Weld SVN: r4221 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2009-10-22 08:02:04 -0400 (Thu, 22 Oct 2009)
New Revision: 4221
Removed:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/ProcessInjectionTargetEventObserver.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/ProcessInjectionTargetEventTest.java
Log:
Cleanup
Deleted: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/ProcessInjectionTargetEventObserver.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/ProcessInjectionTargetEventObserver.java 2009-10-22 11:53:26 UTC (rev 4220)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/ProcessInjectionTargetEventObserver.java 2009-10-22 12:02:04 UTC (rev 4221)
@@ -1,30 +0,0 @@
-package org.jboss.jsr299.tck.tests.lookup.injection.enterprise;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-
-public class ProcessInjectionTargetEventObserver implements Extension
-{
-
- private static ProcessInjectionTarget<Farm> sessionBeanEvent = null;
- private static ProcessInjectionTarget<FarmInterceptor> ejbInterceptorEvent = null;
-
- public void observeSessionBean(@Observes ProcessInjectionTarget<Farm> event) {
- sessionBeanEvent = event;
- }
-
- public void observeEJBInterceptor(@Observes ProcessInjectionTarget<FarmInterceptor> event) {
- ejbInterceptorEvent = event;
- }
-
- public static ProcessInjectionTarget<Farm> getSessionBeanEvent()
- {
- return sessionBeanEvent;
- }
-
- public static ProcessInjectionTarget<FarmInterceptor> getEjbInterceptorEvent()
- {
- return ejbInterceptorEvent;
- }
-}
Deleted: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/ProcessInjectionTargetEventTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/ProcessInjectionTargetEventTest.java 2009-10-22 11:53:26 UTC (rev 4220)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/enterprise/ProcessInjectionTargetEventTest.java 2009-10-22 12:02:04 UTC (rev 4221)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.jsr299.tck.tests.lookup.injection.enterprise;
-
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
-import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.testng.annotations.Test;
-
-/**
- * This test verifies that ProcessInjectionTarget event is fired for a session bean and EJB interceptor.
- * @author Jozef Hartinger
- *
- */
-
-@Artifact
-@Resource(source = "javax.enterprise.inject.spi.Extension", destination = "WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension")
-@IntegrationTest
-@SpecVersion(spec="cdi", version="20091018")
-public class ProcessInjectionTargetEventTest extends AbstractJSR299Test
-{
- @Test(groups = "ri-broken")
- @SpecAssertions({
- @SpecAssertion(section = "11.5.6", id = "aab"),
- @SpecAssertion(section = "11.5.6", id = "abb")})
- public void testEventFiredForSessionBean()
- {
- ProcessInjectionTarget<Farm> event = ProcessInjectionTargetEventObserver.getSessionBeanEvent();
- assert event != null;
- assert event.getAnnotatedType().getBaseType().equals(Farm.class);
- assert event.getAnnotatedType().getFields().size() == 2;
- }
-
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "11.5.6", id = "aaf"),
- @SpecAssertion(section = "11.5.6", id = "abf")})
- public void testEventFiredForTagHandler()
- {
- ProcessInjectionTarget<FarmInterceptor> event = ProcessInjectionTargetEventObserver.getEjbInterceptorEvent();
- assert event != null;
- assert event.getAnnotatedType().getBaseType().equals(FarmInterceptor.class);
- assert event.getAnnotatedType().getFields().size() == 1;
- }
-}
15 years, 1 month
Weld SVN: r4220 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2009-10-22 07:53:26 -0400 (Thu, 22 Oct 2009)
New Revision: 4220
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ContainerEventTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessAnnotatedTypeObserver.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetObserver.java
Removed:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventObserver.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventTest.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/TestTagHandler.java
Log:
Tests for 11.5.6 and 12.3
Copied: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ContainerEventTest.java (from rev 4053, cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventTest.java)
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ContainerEventTest.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ContainerEventTest.java 2009-10-22 11:53:26 UTC (rev 4220)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.lookup.injection.non.contextual;
+
+import java.util.EventListener;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.GenericServlet;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContextListener;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.jsp.tagext.JspTag;
+import javax.servlet.jsp.tagext.SimpleTag;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
+import org.testng.annotations.Test;
+
+/**
+ * This test verifies that ProcessAnnotatedType and ProcessInjectionTarget events are fired
+ * for various Java EE components and tests the AnnotatedType implementation.
+ * @author Jozef Hartinger
+ *
+ */
+@Artifact
+@Resources( {
+ @Resource(destination = WarArtifactDescriptor.WEB_XML_DESTINATION, source = "web.xml"),
+ @Resource(destination = "WEB-INF/faces-config.xml", source = "faces-config.xml"),
+ @Resource(destination = "WEB-INF/TestLibrary.tld", source = "TestLibrary.tld"),
+ @Resource(destination = "TagPage.jsp", source = "TagPage.jsp"),
+ @Resource(destination = "ManagedBeanTestPage.jsp", source = "ManagedBeanTestPage.jsp"),
+ @Resource(source = "javax.enterprise.inject.spi.Extension", destination = "WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension") })
+@IntegrationTest
+@SpecVersion(spec = "cdi", version = "20091018")
+public class ContainerEventTest extends AbstractJSR299Test
+{
+ @Test(groups = "ri-broken")
+ @SpecAssertions({
+ @SpecAssertion(section = "11.5.6", id = "aac"),
+ @SpecAssertion(section = "11.5.6", id = "abc"),
+ @SpecAssertion(section = "12.3", id = "de")})
+ //WELD-204
+ public void testProcessInjectionTargetEventFiredForServletListener()
+ {
+ assert ProcessInjectionTargetObserver.getListenerEvent() != null;
+ validateServletListenerAnnotatedType(ProcessInjectionTargetObserver.getListenerEvent().getAnnotatedType());
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "11.5.6", id = "aad"),
+ @SpecAssertion(section = "11.5.6", id = "abd"),
+ @SpecAssertion(section = "12.3", id = "df")})
+ public void testProcessInjectionTargetEventFiredForTagHandler()
+ {
+ assert ProcessInjectionTargetObserver.getTagHandlerEvent() != null;
+ validateTagHandlerAnnotatedType(ProcessInjectionTargetObserver.getTagHandlerEvent().getAnnotatedType());
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertions({
+ @SpecAssertion(section = "11.5.6", id = "aae"),
+ @SpecAssertion(section = "11.5.6", id = "abe"),
+ @SpecAssertion(section = "12.3", id = "dg")})
+ //WELD-204
+ public void testProcessInjectionTargetEventFiredForTagLibraryListener()
+ {
+ assert ProcessInjectionTargetObserver.getTagLibraryListenerEvent() != null;
+ validateTagLibraryListenerAnnotatedType(ProcessInjectionTargetObserver.getTagLibraryListenerEvent().getAnnotatedType());
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertions({
+ @SpecAssertion(section = "11.5.6", id = "aah"),
+ @SpecAssertion(section = "11.5.6", id = "abh"),
+ @SpecAssertion(section = "12.3", id = "dj")})
+ //WELD-204
+ public void testProcessInjectionTargetEventFiredForServlet()
+ {
+ assert ProcessInjectionTargetObserver.getServletEvent() != null;
+ validateServletAnnotatedType(ProcessInjectionTargetObserver.getServletEvent().getAnnotatedType());
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertions({
+ @SpecAssertion(section = "11.5.6", id = "aai"),
+ @SpecAssertion(section = "11.5.6", id = "abi"),
+ @SpecAssertion(section = "12.3", id = "dk")})
+ //WELD-204
+ public void testProcessInjectionTargetEventFiredForFilter()
+ {
+ assert ProcessInjectionTargetObserver.getFilterEvent() != null;
+ validateFilterAnnotatedType(ProcessInjectionTargetObserver.getFilterEvent().getAnnotatedType());
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "12.3", id = "dd")
+ public void testProcessInjectionTargetEventFiredForJsfManagedBean()
+ {
+ assert ProcessInjectionTargetObserver.getJsfManagedBeanEvent() != null;
+ validateJsfManagedBeanAnnotatedType(ProcessInjectionTargetObserver.getJsfManagedBeanEvent().getAnnotatedType());
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertions({
+ @SpecAssertion(section = "11.5.6", id = "aas"),
+ @SpecAssertion(section = "11.5.6", id = "aao"),
+ @SpecAssertion(section = "11.5.6", id = "aan"),
+ @SpecAssertion(section = "11.5.6", id = "aap")})
+ //WELD-204
+ public void testTypeOfProcessInjectionTargetParameter() {
+ assert !ProcessInjectionTargetObserver.isStringObserved();
+ assert ProcessInjectionTargetObserver.isTagHandlerSubTypeObserved();
+ assert !ProcessInjectionTargetObserver.isTagHandlerSuperTypeObserved();
+ assert !ProcessInjectionTargetObserver.isServletSuperTypeObserved();
+ assert ProcessInjectionTargetObserver.isServletSubTypeObserved();
+ assert !ProcessInjectionTargetObserver.isListenerSuperTypeObserved();
+ }
+
+ @Test
+ @SpecAssertion(section = "12.3", id = "be")
+ public void testProcessAnnotatedTypeEventFiredForServletListener() {
+ assert ProcessAnnotatedTypeObserver.getListenerEvent() != null;
+ validateServletListenerAnnotatedType(ProcessAnnotatedTypeObserver.getListenerEvent().getAnnotatedType());
+ }
+
+ @Test
+ @SpecAssertion(section = "12.3", id = "bf")
+ public void testProcessAnnotatedTypeEventFiredForTagHandler() {
+ assert ProcessAnnotatedTypeObserver.getTagHandlerEvent() != null;
+ validateTagHandlerAnnotatedType(ProcessAnnotatedTypeObserver.getTagHandlerEvent().getAnnotatedType());
+ }
+
+ @Test
+ @SpecAssertion(section = "12.3", id = "bg")
+ public void testProcessAnnotatedTypeEventFiredForTagLibraryListener() {
+ assert ProcessAnnotatedTypeObserver.getTagLibraryListenerEvent() != null;
+ validateTagLibraryListenerAnnotatedType(ProcessAnnotatedTypeObserver.getTagLibraryListenerEvent().getAnnotatedType());
+ }
+
+ @Test
+ @SpecAssertion(section = "12.3", id = "bj")
+ public void testProcessAnnotatedTypeEventFiredForServlet() {
+ assert ProcessAnnotatedTypeObserver.getServletEvent() != null;
+ validateServletAnnotatedType(ProcessAnnotatedTypeObserver.getServletEvent().getAnnotatedType());
+ }
+
+ @Test
+ @SpecAssertion(section = "12.3", id = "bk")
+ public void testProcessAnnotatedTypeEventFiredForFilter() {
+ assert ProcessAnnotatedTypeObserver.getFilterEvent() != null;
+ validateFilterAnnotatedType(ProcessAnnotatedTypeObserver.getFilterEvent().getAnnotatedType());
+ }
+
+ @Test
+ @SpecAssertion(section = "12.3", id = "bd")
+ public void testProcessAnnotatedTypeEventFiredForJsfManagedBean() {
+ assert ProcessAnnotatedTypeObserver.getJsfManagedBeanEvent() != null;
+ validateJsfManagedBeanAnnotatedType(ProcessAnnotatedTypeObserver.getJsfManagedBeanEvent().getAnnotatedType());
+ }
+
+ private void validateServletListenerAnnotatedType(AnnotatedType<TestListener> type) {
+ assert type.getBaseType().equals(TestListener.class);
+ assert type.getAnnotations().isEmpty();
+ assert type.getMethods().size() == 2;
+ assert type.getFields().iterator().next().isAnnotationPresent(Inject.class);
+ assert type.getAnnotations().isEmpty();
+ }
+
+ private void validateTagHandlerAnnotatedType(AnnotatedType<TestTagHandler> type) {
+ assert type.getBaseType().equals(TestTagHandler.class);
+ assert typeSetMatches(type.getTypeClosure(), TestTagHandler.class, SimpleTagSupport.class, SimpleTag.class, JspTag.class);
+ assert type.getAnnotations().size() == 1;
+ assert type.isAnnotationPresent(Any.class);
+ }
+
+ private void validateTagLibraryListenerAnnotatedType(AnnotatedType<TagLibraryListener> type) {
+ assert type.getBaseType().equals(TagLibraryListener.class);
+ assert typeSetMatches(type.getTypeClosure(), TagLibraryListener.class, ServletContextListener.class, EventListener.class, Object.class);
+ assert type.getFields().size() == 1;
+ assert type.getFields().iterator().next().getJavaMember().getName().equals("sheep");
+ assert type.getConstructors().size() == 1;
+ assert type.getMethods().size() == 2;
+ }
+
+ private void validateServletAnnotatedType(AnnotatedType<TestServlet> type) {
+ assert type.getBaseType().equals(TestServlet.class);
+ assert typeSetMatches(type.getTypeClosure(), TestServlet.class, HttpServlet.class, GenericServlet.class, Servlet.class, ServletConfig.class, Object.class);
+ assert type.getAnnotations().isEmpty();
+ }
+
+ private void validateFilterAnnotatedType(AnnotatedType<TestFilter> type) {
+ assert type.getBaseType().equals(TestFilter.class);
+ assert typeSetMatches(type.getTypeClosure(), TestFilter.class, Filter.class, Object.class);
+ assert type.getFields().size() == 2;
+ assert type.getConstructors().size() == 1;
+ assert type.getConstructors().iterator().next().getParameters().isEmpty();
+ assert type.getMethods().size() == 3;
+ }
+
+ private void validateJsfManagedBeanAnnotatedType(AnnotatedType<Farm> type) {
+ assert type.getFields().size() == 1;
+ assert type.getFields().iterator().next().getJavaMember().getName().equals("sheep");
+ assert type.getFields().iterator().next().isAnnotationPresent(Inject.class);
+ assert type.getMethods().size() == 1;
+ assert type.getMethods().iterator().next().getBaseType().equals(boolean.class);
+ }
+}
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessAnnotatedTypeObserver.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessAnnotatedTypeObserver.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessAnnotatedTypeObserver.java 2009-10-22 11:53:26 UTC (rev 4220)
@@ -0,0 +1,69 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.non.contextual;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+public class ProcessAnnotatedTypeObserver implements Extension
+{
+ private static ProcessAnnotatedType<TestServlet> servletEvent = null;
+ private static ProcessAnnotatedType<TestListener> listenerEvent = null;
+ private static ProcessAnnotatedType<TestFilter> filterEvent = null;
+ private static ProcessAnnotatedType<TagLibraryListener> tagLibraryListenerEvent = null;
+ private static ProcessAnnotatedType<TestTagHandler> tagHandlerEvent = null;
+ private static ProcessAnnotatedType<Farm> jsfManagedBeanEvent = null;
+
+ public void observeServlet(@Observes ProcessAnnotatedType<TestServlet> event) {
+ servletEvent = event;
+ }
+
+ public void observeFilter(@Observes ProcessAnnotatedType<TestFilter> event) {
+ filterEvent = event;
+ }
+
+ public void observeListener(@Observes ProcessAnnotatedType<TestListener> event) {
+ listenerEvent = event;
+ }
+
+ public void observeTagHandler(@Observes ProcessAnnotatedType<TestTagHandler> event) {
+ tagHandlerEvent = event;
+ }
+
+ public void observeTagLibraryListener(@Observes ProcessAnnotatedType<TagLibraryListener> event) {
+ tagLibraryListenerEvent = event;
+ }
+
+ public void observeJsfManagedBean(@Observes ProcessAnnotatedType<Farm> event) {
+ jsfManagedBeanEvent = event;
+ }
+
+ public static ProcessAnnotatedType<TestServlet> getServletEvent()
+ {
+ return servletEvent;
+ }
+
+ public static ProcessAnnotatedType<TestListener> getListenerEvent()
+ {
+ return listenerEvent;
+ }
+
+ public static ProcessAnnotatedType<TestFilter> getFilterEvent()
+ {
+ return filterEvent;
+ }
+
+ public static ProcessAnnotatedType<TagLibraryListener> getTagLibraryListenerEvent()
+ {
+ return tagLibraryListenerEvent;
+ }
+
+ public static ProcessAnnotatedType<TestTagHandler> getTagHandlerEvent()
+ {
+ return tagHandlerEvent;
+ }
+
+ public static ProcessAnnotatedType<Farm> getJsfManagedBeanEvent()
+ {
+ return jsfManagedBeanEvent;
+ }
+}
Deleted: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventObserver.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventObserver.java 2009-10-22 11:29:58 UTC (rev 4219)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventObserver.java 2009-10-22 11:53:26 UTC (rev 4220)
@@ -1,65 +0,0 @@
-package org.jboss.jsr299.tck.tests.lookup.injection.non.contextual;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-import javax.servlet.Filter;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContextListener;
-import javax.servlet.jsp.tagext.SimpleTag;
-
-public class ProcessInjectionTargetEventObserver implements Extension
-{
-
- private static ProcessInjectionTarget<Servlet> servletEvent = null;
- private static ProcessInjectionTarget<ServletContextListener> listenerEvent = null;
- private static ProcessInjectionTarget<Filter> filterEvent = null;
- private static ProcessInjectionTarget<ServletContextListener> tagLibraryListenerEvent = null;
- private static ProcessInjectionTarget<SimpleTag> tagHandlerEvent = null;
-
- public void observeServlet(@Observes ProcessInjectionTarget<Servlet> event) {
- servletEvent = event;
- }
-
- public void observeFilter(@Observes ProcessInjectionTarget<Filter> event) {
- filterEvent = event;
- }
-
- public void observeListener(@Observes ProcessInjectionTarget<ServletContextListener> event) {
- listenerEvent = event;
- }
-
- public void observeTagHandler(@Observes ProcessInjectionTarget<SimpleTag> event) {
- tagHandlerEvent = event;
- }
-
- public void observeTagLibraryListener(@Observes ProcessInjectionTarget<ServletContextListener> event) {
- tagLibraryListenerEvent = event;
- }
-
- public static ProcessInjectionTarget<Servlet> getServletEvent()
- {
- return servletEvent;
- }
-
- public static ProcessInjectionTarget<ServletContextListener> getListenerEvent()
- {
- return listenerEvent;
- }
-
- public static ProcessInjectionTarget<Filter> getFilterEvent()
- {
- return filterEvent;
- }
-
- public static ProcessInjectionTarget<ServletContextListener> getTagLibraryListenerEvent()
- {
- return tagLibraryListenerEvent;
- }
-
- public static ProcessInjectionTarget<SimpleTag> getTagHandlerEvent()
- {
- return tagHandlerEvent;
- }
-}
Deleted: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventTest.java 2009-10-22 11:29:58 UTC (rev 4219)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventTest.java 2009-10-22 11:53:26 UTC (rev 4220)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.jsr299.tck.tests.lookup.injection.non.contextual;
-
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-import javax.servlet.Filter;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContextListener;
-import javax.servlet.jsp.tagext.SimpleTag;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
-import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.IntegrationTest;
-import org.jboss.testharness.impl.packaging.Resource;
-import org.jboss.testharness.impl.packaging.Resources;
-import org.jboss.testharness.impl.packaging.war.WarArtifactDescriptor;
-import org.testng.annotations.Test;
-
-@Artifact
-@Resources( { @Resource(destination = WarArtifactDescriptor.WEB_XML_DESTINATION, source = "web.xml"),
- @Resource(destination = "WEB-INF/faces-config.xml", source = "faces-config.xml"),
- @Resource(destination = "WEB-INF/TestLibrary.tld", source = "TestLibrary.tld"),
- @Resource(destination = "TagPage.jsp", source = "TagPage.jsp"),
- @Resource(destination = "ManagedBeanTestPage.jsp", source = "ManagedBeanTestPage.jsp"),
- @Resource(source = "javax.enterprise.inject.spi.Extension", destination = "WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension") })
-@IntegrationTest
-@SpecVersion(spec="cdi", version="20091018")
-public class ProcessInjectionTargetEventTest extends AbstractJSR299Test
-{
- @Test(groups = "ri-broken")
- @SpecAssertions({
- @SpecAssertion(section = "11.5.6", id = "aac"),
- @SpecAssertion(section = "11.5.6", id = "abc")})
- public void testEventFiredForServletListener()
- {
- ProcessInjectionTarget<ServletContextListener> event = ProcessInjectionTargetEventObserver.getListenerEvent();
- assert event != null;
- assert event.getAnnotatedType().getBaseType().equals(TestListener.class);
- }
-
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "11.5.6", id = "aad"),
- @SpecAssertion(section = "11.5.6", id = "abd")})
- public void testEventFiredForTagHandler()
- {
- ProcessInjectionTarget<SimpleTag> event = ProcessInjectionTargetEventObserver.getTagHandlerEvent();
- assert event != null;
- assert event.getAnnotatedType().getBaseType().equals(TestTagHandler.class);
- }
-
- @Test(groups = "ri-broken")
- @SpecAssertions({
- @SpecAssertion(section = "11.5.6", id = "aae"),
- @SpecAssertion(section = "11.5.6", id = "abe")})
- public void testEventFiredForTagLibraryListener()
- {
- ProcessInjectionTarget<ServletContextListener> event = ProcessInjectionTargetEventObserver.getTagLibraryListenerEvent();
- assert event != null;
- assert event.getAnnotatedType().getBaseType().equals(TagLibraryListener.class);
- }
-
- @Test(groups = "ri-broken")
- @SpecAssertions({
- @SpecAssertion(section = "11.5.6", id = "aah"),
- @SpecAssertion(section = "11.5.6", id = "abh")})
- public void testEventFiredForServlet()
- {
- ProcessInjectionTarget<Servlet> event = ProcessInjectionTargetEventObserver.getServletEvent();
- assert event != null;
- assert event.getAnnotatedType().getBaseType().equals(TestServlet.class);
- }
-
- @Test(groups = "ri-broken")
- @SpecAssertions({
- @SpecAssertion(section = "11.5.6", id = "aai"),
- @SpecAssertion(section = "11.5.6", id = "abi")})
- public void testEventFiredForFilter()
- {
- ProcessInjectionTarget<Filter> event = ProcessInjectionTargetEventObserver.getFilterEvent();
- assert event != null;
- assert event.getAnnotatedType().getBaseType().equals(TestFilter.class);
- }
-}
Copied: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetObserver.java (from rev 4053, cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetEventObserver.java)
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetObserver.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/ProcessInjectionTargetObserver.java 2009-10-22 11:53:26 UTC (rev 4220)
@@ -0,0 +1,135 @@
+package org.jboss.jsr299.tck.tests.lookup.injection.non.contextual;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessInjectionTarget;
+import javax.servlet.ServletContextListener;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.jsp.tagext.SimpleTag;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+
+public class ProcessInjectionTargetObserver implements Extension
+{
+
+ private static ProcessInjectionTarget<TestServlet> servletEvent = null;
+ private static ProcessInjectionTarget<TestListener> listenerEvent = null;
+ private static ProcessInjectionTarget<TestFilter> filterEvent = null;
+ private static ProcessInjectionTarget<TagLibraryListener> tagLibraryListenerEvent = null;
+ private static ProcessInjectionTarget<TestTagHandler> tagHandlerEvent = null;
+ private static ProcessInjectionTarget<Farm> jsfManagedBeanEvent = null;
+
+ private static boolean servletSuperTypeObserved = false;
+ private static boolean servletSubTypeObserved = false;
+ private static boolean listenerSuperTypeObserved = false;
+ private static boolean tagHandlerSuperTypeObserved = false;
+ private static boolean tagHandlerSubTypeObserved = false;
+ private static boolean stringObserved = false;
+
+ public void observeServlet(@Observes ProcessInjectionTarget<TestServlet> event) {
+ servletEvent = event;
+ }
+
+ public void observeFilter(@Observes ProcessInjectionTarget<TestFilter> event) {
+ filterEvent = event;
+ }
+
+ public void observeListener(@Observes ProcessInjectionTarget<TestListener> event) {
+ listenerEvent = event;
+ }
+
+ public void observeTagHandler(@Observes ProcessInjectionTarget<TestTagHandler> event) {
+ tagHandlerEvent = event;
+ }
+
+ public void observeTagLibraryListener(@Observes ProcessInjectionTarget<TagLibraryListener> event) {
+ tagLibraryListenerEvent = event;
+ }
+
+ public void observeJsfManagedBean(@Observes ProcessInjectionTarget<Farm> event) {
+ jsfManagedBeanEvent = event;
+ }
+
+ public void observeServletSuperType(@Observes ProcessInjectionTarget<? super HttpServlet> event) {
+ servletSuperTypeObserved = true;
+ }
+
+ public void observeServletSubType(@Observes ProcessInjectionTarget<? extends HttpServlet> event) {
+ servletSubTypeObserved = true;
+ }
+
+ public void observeListenerSuperType(@Observes ProcessInjectionTarget<? super ServletContextListener> event) {
+ listenerSuperTypeObserved = true;
+ }
+
+ public void tagHandlerSuperType(@Observes ProcessInjectionTarget<? super SimpleTagSupport> event) {
+ tagHandlerSuperTypeObserved = true;
+ }
+
+ public void tagHandlerSubType(@Observes ProcessInjectionTarget<? extends SimpleTag> event) {
+ tagHandlerSubTypeObserved = true;
+ }
+
+ public void stringObserver(@Observes ProcessInjectionTarget<String> event) {
+ stringObserved = true;
+ }
+
+ public static ProcessInjectionTarget<TestServlet> getServletEvent()
+ {
+ return servletEvent;
+ }
+
+ public static ProcessInjectionTarget<TestListener> getListenerEvent()
+ {
+ return listenerEvent;
+ }
+
+ public static ProcessInjectionTarget<TestFilter> getFilterEvent()
+ {
+ return filterEvent;
+ }
+
+ public static ProcessInjectionTarget<TagLibraryListener> getTagLibraryListenerEvent()
+ {
+ return tagLibraryListenerEvent;
+ }
+
+ public static ProcessInjectionTarget<TestTagHandler> getTagHandlerEvent()
+ {
+ return tagHandlerEvent;
+ }
+
+ public static ProcessInjectionTarget<Farm> getJsfManagedBeanEvent()
+ {
+ return jsfManagedBeanEvent;
+ }
+
+ public static boolean isServletSuperTypeObserved()
+ {
+ return servletSuperTypeObserved;
+ }
+
+ public static boolean isServletSubTypeObserved()
+ {
+ return servletSubTypeObserved;
+ }
+
+ public static boolean isListenerSuperTypeObserved()
+ {
+ return listenerSuperTypeObserved;
+ }
+
+ public static boolean isTagHandlerSuperTypeObserved()
+ {
+ return tagHandlerSuperTypeObserved;
+ }
+
+ public static boolean isTagHandlerSubTypeObserved()
+ {
+ return tagHandlerSubTypeObserved;
+ }
+
+ public static boolean isStringObserved()
+ {
+ return stringObserved;
+ }
+}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/TestTagHandler.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/TestTagHandler.java 2009-10-22 11:29:58 UTC (rev 4219)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injection/non/contextual/TestTagHandler.java 2009-10-22 11:53:26 UTC (rev 4220)
@@ -2,10 +2,12 @@
import java.io.IOException;
+import javax.enterprise.inject.Any;
import javax.inject.Inject;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
+@Any
public class TestTagHandler extends SimpleTagSupport
{
private static final long serialVersionUID = -3048065065359948044L;
15 years, 1 month
Weld SVN: r4219 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2009-10-22 07:29:58 -0400 (Thu, 22 Oct 2009)
New Revision: 4219
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
Log:
Updated spec version
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java 2009-10-22 08:11:06 UTC (rev 4218)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java 2009-10-22 11:29:58 UTC (rev 4219)
@@ -45,7 +45,7 @@
@Resource(source="javax.enterprise.inject.spi.Extension", destination="WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension")
})
@IntegrationTest
-@SpecVersion(spec="cdi", version="PFD2")
+@SpecVersion(spec="cdi", version="20091018")
public class AlternativeMetadataTest extends AbstractJSR299Test
{
@Test(groups = "ri-broken")
15 years, 1 month
Weld SVN: r4218 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2009-10-22 04:11:06 -0400 (Thu, 22 Oct 2009)
New Revision: 4218
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
Log:
Marked tests as broken
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java 2009-10-22 06:05:30 UTC (rev 4217)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java 2009-10-22 08:11:06 UTC (rev 4218)
@@ -103,7 +103,7 @@
assert getInstanceByType(Grocery.class, new AnyLiteral()).isConstructorWithParameterUsed();
}
- @Test
+ @Test(groups = "ri-broken")
@SpecAssertion(section = "11.4", id = "t")
//WELD-219
public void testPreviouslyNonInjectAnnotatedFieldIsInjected() {
@@ -111,7 +111,7 @@
}
@SuppressWarnings("unchecked")
- @Test
+ @Test(groups = "ri-broken")
@SpecAssertion(section = "11.4", id = "u")
//WELD-219
public void testExtraQualifierIsAppliedToInjectedField() {
15 years, 1 month
Weld SVN: r4217 - in core/trunk: impl/src/main/java/org/jboss/weld/bean and 5 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-22 02:05:30 -0400 (Thu, 22 Oct 2009)
New Revision: 4217
Added:
core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java
core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java
core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java
core/trunk/impl/src/main/java/org/jboss/weld/context/DependentContext.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
Log:
ContextualStore, SerializableContextual and SerializableContextualInstance are implementations of the SPI-provided interfaces.
Modified: core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/BeanManagerImpl.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -64,8 +64,9 @@
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.events.AbstractProcessInjectionTarget;
import org.jboss.weld.context.CreationalContextImpl;
-import org.jboss.weld.context.SerializableContextual;
import org.jboss.weld.context.WeldCreationalContext;
+import org.jboss.weld.serialization.spi.ContextualStore;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
import org.jboss.weld.ejb.EjbDescriptors;
import org.jboss.weld.ejb.spi.EjbDescriptor;
import org.jboss.weld.el.Namespace;
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -1,125 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.inject.spi.PassivationCapable;
-
-import org.jboss.weld.bootstrap.api.Service;
-
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Maps;
-
-/**
- * Application wide contextual identifier service which allows a serializable
- * reference to a contextual to be obtained, and the contextual to be returned
- * for a given id.
- *
- * If the contextual implements PassivationCapable, the id will be obtained
- * from it, in which case the Contextual can be activated in any container.
- * If not, the Contextual can only be activated in this container.
- *
- * Note that this allows a Bean object to be loaded regardless
- * of the bean's accessiblity from the current module, and should not be abused
- * as a way to ignore accessibility rules enforced during resolution.
- *
- * @author Pete Muir
- *
- *
- */
-public class ContextualStore implements Service
-{
-
- private static final String GENERATED_ID_PREFIX = ContextualStore.class.getName();
-
- // The map containing container-local contextuals
- private final BiMap<Contextual<?>, String> contextuals;
-
- // The map containing passivation capable contextuals
- private final ConcurrentMap<String, Contextual<?>> passivationCapableContextuals;
-
- private final AtomicInteger idGenerator;
-
- public ContextualStore()
- {
- this.idGenerator = new AtomicInteger(0);
- BiMap<Contextual<?>, String> map = HashBiMap.create();
- // TODO Somehow remove this sync if it shows bad in a profiler
- this.contextuals = Maps.synchronizedBiMap(map);
- this.passivationCapableContextuals = new ConcurrentHashMap<String, Contextual<?>>();
- }
-
- /**
- * Given a particular id, return the correct contextual. For contextuals
- * which aren't passivation capable, the contextual can't be found in another
- * container, and null will be returned.
- *
- * @param id An identifier for the contextual
- * @return the contextual
- */
- @SuppressWarnings("unchecked")
- public <C extends Contextual<I>, I> C getContextual(String id)
- {
- if (id.startsWith(GENERATED_ID_PREFIX))
- {
- return (C) contextuals.inverse().get(id);
- }
- else
- {
- return (C) passivationCapableContextuals.get(id);
- }
- }
-
- /**
- * Add a contextual (if not already present) to the store, and return
- * it's id. If the contextual is passivation capable, it's id will
- * be used, otherwise an id will be generated
- *
- * @param contextual the contexutal to add
- * @return the current id for the contextual
- */
- public String putIfAbsent(Contextual<?> contextual)
- {
- if (contextual instanceof PassivationCapable)
- {
- PassivationCapable passivationCapable = (PassivationCapable) contextual;
- passivationCapableContextuals.putIfAbsent(passivationCapable.getId(), contextual);
- return passivationCapable.getId();
- }
- else if (contextuals.containsKey(contextual))
- {
- return contextuals.get(contextual);
- }
- else
- {
- String id = new StringBuilder().append(GENERATED_ID_PREFIX).append(idGenerator.incrementAndGet()).toString();
- contextuals.put(contextual, id);
- return id;
- }
- }
-
- public void cleanup()
- {
- contextuals.clear();
- passivationCapableContextuals.clear();
- }
-}
Copied: core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java (from rev 4215, core/trunk/impl/src/main/java/org/jboss/weld/ContextualStore.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.PassivationCapable;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Maps;
+
+import org.jboss.weld.serialization.spi.ContextualStore;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
+import org.jboss.weld.context.SerializableContextualImpl;
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
+
+/**
+ * Implementation of {@link org.jboss.weld.serialization.spi.ContextualStore}
+ *
+ * @author Pete Muir
+ *
+ */
+public class ContextualStoreImpl implements ContextualStore
+{
+
+ private static final String GENERATED_ID_PREFIX = ContextualStoreImpl.class.getName();
+
+ // The map containing container-local contextuals
+ private final BiMap<Contextual<?>, String> contextuals;
+
+ // The map containing passivation capable contextuals
+ private final ConcurrentMap<String, Contextual<?>> passivationCapableContextuals;
+
+ private final AtomicInteger idGenerator;
+
+ public ContextualStoreImpl()
+ {
+ this.idGenerator = new AtomicInteger(0);
+ BiMap<Contextual<?>, String> map = HashBiMap.create();
+ // TODO Somehow remove this sync if it shows bad in a profiler
+ this.contextuals = Maps.synchronizedBiMap(map);
+ this.passivationCapableContextuals = new ConcurrentHashMap<String, Contextual<?>>();
+ }
+
+ /**
+ * Given a particular id, return the correct contextual. For contextuals
+ * which aren't passivation capable, the contextual can't be found in another
+ * container, and null will be returned.
+ *
+ * @param id An identifier for the contextual
+ * @return the contextual
+ */
+ @SuppressWarnings("unchecked")
+ public <C extends Contextual<I>, I> C getContextual(String id)
+ {
+ if (id.startsWith(GENERATED_ID_PREFIX))
+ {
+ return (C) contextuals.inverse().get(id);
+ }
+ else
+ {
+ return (C) passivationCapableContextuals.get(id);
+ }
+ }
+
+ /**
+ * Add a contextual (if not already present) to the store, and return
+ * it's id. If the contextual is passivation capable, it's id will
+ * be used, otherwise an id will be generated
+ *
+ * @param contextual the contexutal to add
+ * @return the current id for the contextual
+ */
+ public String putIfAbsent(Contextual<?> contextual)
+ {
+ if (contextual instanceof PassivationCapable)
+ {
+ PassivationCapable passivationCapable = (PassivationCapable) contextual;
+ passivationCapableContextuals.putIfAbsent(passivationCapable.getId(), contextual);
+ return passivationCapable.getId();
+ }
+ else if (contextuals.containsKey(contextual))
+ {
+ return contextuals.get(contextual);
+ }
+ else
+ {
+ String id = new StringBuilder().append(GENERATED_ID_PREFIX).append(idGenerator.incrementAndGet()).toString();
+ contextuals.put(contextual, id);
+ return id;
+ }
+ }
+
+ public <C extends Contextual<I>, I> SerializableContextual<C, I> getSerializableContextual(Contextual<I> contextual)
+ {
+ return new SerializableContextualImpl(contextual);
+ }
+
+ public <C extends Contextual<I>, I> SerializableContextualInstance<C, I> getSerializableContextualInstance(Contextual<I> contextual, I instance, CreationalContext<I> creationalContext)
+ {
+ return new SerializableContextualInstanceImpl(contextual, instance, creationalContext);
+ }
+
+ public void cleanup()
+ {
+ contextuals.clear();
+ passivationCapableContextuals.clear();
+ }
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/impl/src/main/java/org/jboss/weld/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/Validator.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/Validator.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -46,13 +46,12 @@
import org.jboss.weld.bean.AbstractProducerBean;
import org.jboss.weld.bean.DecoratorImpl;
import org.jboss.weld.bean.DisposalMethod;
-import org.jboss.weld.bean.ManagedBean;
import org.jboss.weld.bean.NewManagedBean;
import org.jboss.weld.bean.NewSessionBean;
import org.jboss.weld.bean.RIBean;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.bootstrap.api.Service;
-import org.jboss.weld.context.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
import org.jboss.weld.introspector.WeldAnnotated;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.resolution.ResolvableWeldClass;
@@ -135,7 +134,7 @@
InterceptionModel<Class<?>, Class<?>> ejbInterceptorModel = beanManager.getClassDeclaredInterceptorsRegistry().getInterceptionModel(((AbstractClassBean<?>) classBean).getType());
if (ejbInterceptorModel != null)
{
- Class<?>[] classDeclaredInterceptors = ejbInterceptorModel.getAllInterceptors().toArray(new Class<?>[0]);
+ Class<?>[] classDeclaredInterceptors = ejbInterceptorModel.getAllInterceptors().toArray(new Class<?>[ejbInterceptorModel.getAllInterceptors().size()]);
if (classDeclaredInterceptors != null)
{
for (Class<?> interceptorClass: classDeclaredInterceptors)
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -46,11 +46,13 @@
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.DefinitionException;
import org.jboss.weld.DeploymentException;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
+import org.jboss.weld.context.SerializableContextualImpl;
import org.jboss.weld.ejb.EJBApiAbstraction;
import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
-import org.jboss.weld.context.SerializableContextual;
-import org.jboss.weld.context.SerializableContextualInstance;
import org.jboss.weld.injection.FieldInjectionPoint;
import org.jboss.weld.injection.MethodInjectionPoint;
import org.jboss.weld.introspector.WeldClass;
@@ -184,7 +186,7 @@
DecoratorImpl<Object> decoratorBean = (DecoratorImpl<Object>) decorator;
Object decoratorInstance = getManager().getReference(ip, decorator, creationalContext);
- decoratorInstances.add(new SerializableContextualInstance<DecoratorImpl<Object>, Object>(decoratorBean, decoratorInstance, null));
+ decoratorInstances.add(new SerializableContextualInstanceImpl<DecoratorImpl<Object>, Object>(decoratorBean, decoratorInstance, null));
ip = decoratorBean.getDelegateInjectionPoint();
}
else
@@ -442,7 +444,7 @@
{
if (Beans.findInterceptorBindingConflicts(manager, classBindingAnnotations))
throw new DeploymentException("Conflicting interceptor bindings found on " + getType() + "." + method.getName() + "()");
-
+
if (method.isAnnotationPresent(manager.getServices().get(EJBApiAbstraction.class).TIMEOUT_ANNOTATION_CLASS))
{
List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_TIMEOUT, methodBindingAnnotations.toArray(new Annotation[]{}));
@@ -518,7 +520,7 @@
List<SerializableContextual> serializableContextuals = new ArrayList<SerializableContextual>();
for (Interceptor<?> interceptor: interceptors)
{
- serializableContextuals.add(new SerializableContextual(interceptor));
+ serializableContextuals.add(new SerializableContextualImpl(interceptor));
}
return serializableContextuals.toArray(new SerializableContextual[]{});
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -49,7 +49,7 @@
import org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler;
import org.jboss.weld.bean.proxy.Marker;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
-import org.jboss.weld.context.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
import org.jboss.weld.ejb.InternalEjbDescriptor;
import org.jboss.weld.ejb.api.SessionObjectReference;
import org.jboss.weld.ejb.spi.BusinessInterfaceDescriptor;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -5,7 +5,7 @@
import javax.enterprise.inject.spi.Interceptor;
import org.jboss.interceptor.proxy.AbstractClassInterceptionHandler;
-import org.jboss.weld.context.SerializableContextualInstance;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
/**
* @author Marius Bogoevici
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -23,8 +23,8 @@
import org.jboss.interceptor.proxy.InterceptionHandler;
import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
import org.jboss.weld.BeanManagerImpl;
-import org.jboss.weld.context.SerializableContextualInstance;
-import org.jboss.weld.context.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
/**
* @author Marius Bogoevici
@@ -45,10 +45,11 @@
return manager;
}
+ @SuppressWarnings("unchecked")
public InterceptionHandler createFor(final SerializableContextual<Interceptor<Object>, Object> serializableContextual)
{
Object instance = getManager().getReference(serializableContextual.get(), creationalContext);
- return new CdiInterceptorHandler(new SerializableContextualInstance<Interceptor<Object>, Object>(serializableContextual, instance, creationalContext),
+ return new CdiInterceptorHandler(new SerializableContextualInstanceImpl<Interceptor<Object>, Object>(serializableContextual, instance, creationalContext),
serializableContextual.get().getBeanClass());
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -19,10 +19,6 @@
import java.util.Collection;
import java.util.List;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import java.util.Arrays;
import java.util.ArrayList;
import java.lang.reflect.Method;
@@ -30,7 +26,7 @@
import javax.enterprise.inject.spi.InterceptionType;
import org.jboss.weld.ejb.spi.InterceptorBindings;
-import org.jboss.weld.context.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
import org.jboss.interceptor.model.InterceptionModel;
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -25,7 +25,7 @@
import javassist.util.proxy.MethodHandler;
import org.jboss.weld.bean.DecoratorImpl;
-import org.jboss.weld.context.SerializableContextualInstance;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
import org.jboss.weld.introspector.MethodSignature;
import org.jboss.weld.introspector.WeldMethod;
import org.jboss.weld.introspector.jlr.MethodSignatureImpl;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -26,7 +26,7 @@
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.Container;
-import org.jboss.weld.ContextualStore;
+import org.jboss.weld.ContextualStoreImpl;
import org.jboss.weld.Validator;
import org.jboss.weld.bean.builtin.ManagerBean;
import org.jboss.weld.bootstrap.api.Bootstrap;
@@ -51,6 +51,7 @@
import org.jboss.weld.context.SessionContext;
import org.jboss.weld.context.SingletonContext;
import org.jboss.weld.context.api.BeanStore;
+import org.jboss.weld.serialization.spi.ContextualStore;
import org.jboss.weld.ejb.EJBApiAbstraction;
import org.jboss.weld.ejb.EjbDescriptors;
import org.jboss.weld.jsf.JsfApiAbstraction;
@@ -236,7 +237,7 @@
services.add(TypeStore.class, new TypeStore());
services.add(ClassTransformer.class, new ClassTransformer(services.get(TypeStore.class)));
services.add(MetaAnnotationStore.class, new MetaAnnotationStore(services.get(ClassTransformer.class)));
- services.add(ContextualStore.class, new ContextualStore());
+ services.add(ContextualStore.class, new ContextualStoreImpl());
return services;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/AbstractMapContext.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -24,7 +24,7 @@
import javax.enterprise.context.spi.CreationalContext;
import org.jboss.weld.Container;
-import org.jboss.weld.ContextualStore;
+import org.jboss.weld.serialization.spi.ContextualStore;
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.api.ContextualInstance;
import org.jboss.weld.log.LogProvider;
@@ -76,13 +76,13 @@
if (getBeanStore() == null)
{
return null;
- }
+ }
if (contextual == null)
{
throw new IllegalArgumentException("Must provide a contextual to get");
}
String id = getId(contextual);
- ContextualInstance<T> beanInstance = getBeanStore().get(id);
+ ContextualInstance<T> beanInstance = getBeanStore().get(id);
if (beanInstance != null)
{
return beanInstance.getInstance();
@@ -104,7 +104,7 @@
T instance = contextual.create(creationalContext);
if (instance != null)
{
- beanInstance = new SerializableContextualInstance<Contextual<T>, T>(contextual, instance, creationalContext);
+ beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext);
getBeanStore().put(id, beanInstance);
}
return instance;
@@ -134,9 +134,9 @@
if (getBeanStore() == null)
{
throw new IllegalStateException("No bean store available for " + toString());
- }
+ }
ContextualInstance<T> beanInstance = getBeanStore().get(id);
- beanInstance.getContextual().destroy(beanInstance.getInstance(), beanInstance.getCreationalContext());
+ beanInstance.getContextual().destroy(beanInstance.getInstance(), beanInstance.getCreationalContext());
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/DependentContext.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/DependentContext.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/DependentContext.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -62,8 +62,8 @@
T instance = contextual.create(creationalContext);
if (creationalContext instanceof WeldCreationalContext<?>)
{
- WeldCreationalContext<T> creationalContextImpl = (WeldCreationalContext<T>) creationalContext;
- ContextualInstance<T> beanInstance = new SerializableContextualInstance<Contextual<T>, T>(contextual, instance, creationalContext);
+ WeldCreationalContext<T> creationalContextImpl = (WeldCreationalContext<T>) creationalContext;
+ ContextualInstance<T> beanInstance = new SerializableContextualInstanceImpl<Contextual<T>, T>(contextual, instance, creationalContext);
creationalContextImpl.getParentDependentInstancesStore().addDependentInstance(beanInstance);
}
return instance;
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -1,94 +0,0 @@
-package org.jboss.weld.context;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.spi.Contextual;
-
-import org.jboss.weld.Container;
-import org.jboss.weld.ContextualStore;
-
-/**
- * A serializable version of contextual that knows how to restore the
- * original bean if necessary
- *
- * @author pmuir
- *
- */
-public class SerializableContextual<C extends Contextual<I>, I> extends ForwardingContextual<I> implements Serializable
-{
-
- @Override
- protected Contextual<I> delegate()
- {
- return get();
- }
-
- private static final long serialVersionUID = 9161034819867283482L;
-
- // A directly serializable contextual
- private C serialiazable;
-
- // A cached, transient version of the contextual
- private transient C cached;
-
- // the id of a non-serializable, passivation capable contextual
- private String id;
-
- public SerializableContextual(C contextual)
- {
- if (contextual instanceof Serializable)
- {
- // the contextual is serializable, so we can just use it
- this.serialiazable = contextual;
- }
- else
- {
- // otherwise, generate an id (may not be portable between container instances
- this.id = Container.instance().deploymentServices().get(ContextualStore.class).putIfAbsent(contextual);
- }
- // cache the contextual
- this.cached = contextual;
- }
-
- public C get()
- {
- if (cached == null)
- {
- loadContextual();
- }
- return cached;
- }
-
- private void loadContextual()
- {
- if (serialiazable != null)
- {
- this.cached = serialiazable;
- }
- else if (id != null)
- {
- this.cached = Container.instance().deploymentServices().get(ContextualStore.class).<C, I>getContextual(id);
- }
- }
-
- @Override
- public boolean equals(Object obj)
- {
- // if the arriving object is also a SerializableContextual, then unwrap it
- if (obj instanceof SerializableContextual<?, ?>)
- {
- return delegate().equals(((SerializableContextual<?, ?>) obj).get());
- }
- else
- {
- return delegate().equals(obj);
- }
- }
-
- @Override
- public int hashCode()
- {
- return delegate().hashCode();
- }
-
-}
\ No newline at end of file
Copied: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java (from rev 4215, core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextual.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -0,0 +1,95 @@
+package org.jboss.weld.context;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.spi.Contextual;
+
+import org.jboss.weld.Container;
+import org.jboss.weld.serialization.spi.ContextualStore;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+
+/**
+ * A serializable version of contextual that knows how to restore the
+ * original bean if necessary
+ *
+ * @author pmuir
+ *
+ */
+public class SerializableContextualImpl<C extends Contextual<I>, I> extends ForwardingContextual<I> implements SerializableContextual<C, I>
+{
+
+ @Override
+ protected Contextual<I> delegate()
+ {
+ return get();
+ }
+
+ private static final long serialVersionUID = 9161034819867283482L;
+
+ // A directly serializable contextual
+ private C serialiazable;
+
+ // A cached, transient version of the contextual
+ private transient C cached;
+
+ // the id of a non-serializable, passivation capable contextual
+ private String id;
+
+ public SerializableContextualImpl(C contextual)
+ {
+ if (contextual instanceof Serializable)
+ {
+ // the contextual is serializable, so we can just use it
+ this.serialiazable = contextual;
+ }
+ else
+ {
+ // otherwise, generate an id (may not be portable between container instances)
+ this.id = Container.instance().deploymentServices().get(ContextualStore.class).putIfAbsent(contextual);
+ }
+ // cache the contextual
+ this.cached = contextual;
+ }
+
+ public C get()
+ {
+ if (cached == null)
+ {
+ loadContextual();
+ }
+ return cached;
+ }
+
+ private void loadContextual()
+ {
+ if (serialiazable != null)
+ {
+ this.cached = serialiazable;
+ }
+ else if (id != null)
+ {
+ this.cached = Container.instance().deploymentServices().get(ContextualStore.class).<C, I>getContextual(id);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ // if the arriving object is also a SerializableContextual, then unwrap it
+ if (obj instanceof SerializableContextualImpl<?, ?>)
+ {
+ return delegate().equals(((SerializableContextualImpl<?, ?>) obj).get());
+ }
+ else
+ {
+ return delegate().equals(obj);
+ }
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld.context;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
-
-import org.jboss.weld.context.api.ContextualInstance;
-
-public class SerializableContextualInstance<C extends Contextual<I>, I> implements ContextualInstance<I>, Serializable
-{
-
- private static final long serialVersionUID = -6366271037267396256L;
-
- private final SerializableContextual<C, I> contextual;
- private final I instance;
- private final CreationalContext<I> creationalContext;
-
- public SerializableContextualInstance(C contextual, I instance, CreationalContext<I> creationalContext)
- {
- this.contextual = new SerializableContextual<C, I>(contextual);
- this.instance = instance;
- this.creationalContext = creationalContext;
- }
-
- public SerializableContextualInstance(SerializableContextual<C, I> contextual, I instance, CreationalContext<I> creationalContext)
- {
- this.contextual = contextual;
- this.instance = instance;
- this.creationalContext = creationalContext;
- }
-
- public SerializableContextual<C, I> getContextual()
- {
- return contextual;
- }
-
- public I getInstance()
- {
- return instance;
- }
-
- public CreationalContext<I> getCreationalContext()
- {
- return creationalContext;
- }
-
- @Override
- public String toString()
- {
- return "Bean: " + contextual + "; Instance: " + instance + "; CreationalContext: " + creationalContext;
- }
-
-}
Copied: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java (from rev 4215, core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstance.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.context;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
+
+public class SerializableContextualInstanceImpl<C extends Contextual<I>, I> implements SerializableContextualInstance<C,I>
+{
+
+ private static final long serialVersionUID = -6366271037267396256L;
+
+ private final SerializableContextual<C, I> contextual;
+ private final I instance;
+ private final CreationalContext<I> creationalContext;
+
+ public SerializableContextualInstanceImpl(C contextual, I instance, CreationalContext<I> creationalContext)
+ {
+ this.contextual = new SerializableContextualImpl<C, I>(contextual);
+ this.instance = instance;
+ this.creationalContext = creationalContext;
+ }
+
+ public SerializableContextualInstanceImpl(SerializableContextual<C, I> contextual, I instance, CreationalContext<I> creationalContext)
+ {
+ this.contextual = contextual;
+ this.instance = instance;
+ this.creationalContext = creationalContext;
+ }
+
+ public SerializableContextual<C, I> getContextual()
+ {
+ return contextual;
+ }
+
+ public I getInstance()
+ {
+ return instance;
+ }
+
+ public CreationalContext<I> getCreationalContext()
+ {
+ return creationalContext;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Bean: " + contextual + "; Instance: " + instance + "; CreationalContext: " + creationalContext;
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/context/SerializableContextualInstanceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/AccessibleManagerResolutionTest.java 2009-10-22 06:03:57 UTC (rev 4216)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/deployment/structure/AccessibleManagerResolutionTest.java 2009-10-22 06:05:30 UTC (rev 4217)
@@ -5,7 +5,9 @@
import javax.enterprise.inject.spi.Bean;
import org.jboss.weld.BeanManagerImpl;
-import org.jboss.weld.ContextualStore;
+
+import org.jboss.weld.ContextualStoreImpl;
+import org.jboss.weld.serialization.spi.ContextualStore;
import org.jboss.weld.bean.ManagedBean;
import org.jboss.weld.bean.RIBean;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
@@ -32,7 +34,7 @@
this.classTransformer = new ClassTransformer(new TypeStore());
this.services = new SimpleServiceRegistry();
this.services.add(MetaAnnotationStore.class, new MetaAnnotationStore(classTransformer));
- this.services.add(ContextualStore.class, new ContextualStore());
+ this.services.add(ContextualStore.class, new ContextualStoreImpl());
}
private void addBean(BeanManagerImpl manager, Class<?> c)
15 years, 1 month
Weld SVN: r4216 - in api/trunk/weld-spi/src/main/java/org/jboss/weld: serialization and 2 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-22 02:03:57 -0400 (Thu, 22 Oct 2009)
New Revision: 4216
Added:
api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/
api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/
api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/ContextualStore.java
api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/
api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextual.java
api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextualInstance.java
Log:
Adding serialization SPI to weld-spi
Added: api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/ContextualStore.java
===================================================================
--- api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/ContextualStore.java (rev 0)
+++ api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/ContextualStore.java 2009-10-22 06:03:57 UTC (rev 4216)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.serialization.spi;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.weld.bootstrap.api.Service;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
+
+/**
+ * Application wide contextual identifier service which allows a serializable
+ * reference to a contextual to be obtained, and the contextual to be returned
+ * for a given id.
+ * <p/>
+ * If the contextual implements PassivationCapable, the id will be obtained
+ * from it, in which case the Contextual can be activated in any container.
+ * If not, the Contextual can only be activated in this container.
+ * <p/>
+ * Note that this allows a Bean object to be loaded regardless
+ * of the bean's accessiblity from the current module, and should not be abused
+ * as a way to ignore accessibility rules enforced during resolution.
+ *
+ * @author Pete Muir
+ * @author Marius Bogoevici
+ */
+public interface ContextualStore extends Service
+{
+ /**
+ * Given a particular id, return the correct contextual. For contextuals
+ * which aren't passivation capable, the contextual can't be found in another
+ * container, and null will be returned.
+ *
+ * @param id An identifier for the contextual
+ * @return the contextual
+ */
+
+ <C extends Contextual<I>, I> C getContextual(String id);
+
+ /**
+ * Add a contextual (if not already present) to the store, and return
+ * it's id. If the contextual is passivation capable, it's id will
+ * be used, otherwise an id will be generated
+ *
+ * @param contextual the contexutal to add
+ * @return the current id for the contextual
+ */
+ String putIfAbsent(Contextual<?> contextual);
+
+ /**
+ * Returns a {@link SerializableContextual} that corresponds to the given {@link Contextual}
+ *
+ * @param contextual the contextual for which the serializable contextual is created
+ * @return a serializable contextual
+ */
+ <C extends Contextual<I>, I> SerializableContextual<C, I> getSerializableContextual(Contextual<I> contextual);
+
+ /**
+ * Returns a {@link org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance} that corresponds to the given instance and {@link Contextual}
+ *
+ * @param contextual the contextual for which the serializable contextual instance is returned
+ * @param instance the instance
+ * @param creationalContext the creational context of the instance
+ * @return the serializable contextual instance
+ */
+ <C extends Contextual<I>, I>SerializableContextualInstance<C, I> getSerializableContextualInstance(Contextual<I> contextual, I instance, CreationalContext<I> creationalContext);
+}
Added: api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextual.java
===================================================================
--- api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextual.java (rev 0)
+++ api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextual.java 2009-10-22 06:03:57 UTC (rev 4216)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.weld.serialization.spi.helpers;
+
+import javax.enterprise.context.spi.Contextual;
+import java.io.Serializable;
+
+/**
+ * A serializable version of contextual that knows how to restore the
+ * original bean if necessary.
+ *
+ * @author Pete Muir
+ * @author Marius Bogoevici
+ */
+public interface SerializableContextual<C extends Contextual<I>, I> extends Serializable, Contextual<I>
+{
+ C get();
+}
Added: api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextualInstance.java
===================================================================
--- api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextualInstance.java (rev 0)
+++ api/trunk/weld-spi/src/main/java/org/jboss/weld/serialization/spi/helpers/SerializableContextualInstance.java 2009-10-22 06:03:57 UTC (rev 4216)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.serialization.spi.helpers;
+
+import org.jboss.weld.context.api.ContextualInstance;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import java.io.Serializable;
+
+/**
+ * A Serializable wrapper for a {@link ContextualInstance}
+ *
+ * @author Pete Muir
+ * @author Marius Bogoevici
+ */
+public interface SerializableContextualInstance<C extends Contextual<I>, I> extends ContextualInstance<I>, Serializable
+{
+ SerializableContextual<C, I> getContextual();
+
+ I getInstance();
+
+ CreationalContext<I> getCreationalContext();
+}
15 years, 1 month
Weld SVN: r4215 - in core/trunk: impl/src/main/java/org/jboss/weld/bean and 6 other directories.
by weld-commits@lists.jboss.org
Author: marius.bogoevici
Date: 2009-10-21 12:17:44 -0400 (Wed, 21 Oct 2009)
New Revision: 4215
Added:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Referee.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Referee.java
Modified:
core/trunk/bom/pom.xml
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/ejb/EJBApiAbstraction.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java
core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml
core/trunk/tests/unit-tests.xml
Log:
Fix detection and handling of AroundTimeout.
Modified: core/trunk/bom/pom.xml
===================================================================
--- core/trunk/bom/pom.xml 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/bom/pom.xml 2009-10-21 16:17:44 UTC (rev 4215)
@@ -76,7 +76,7 @@
<javassist.version>3.11.0.GA</javassist.version>
<cdi.tck.version>1.0.0-SNAPSHOT</cdi.tck.version>
<atinject.tck.version>1.0.0-PFD-3</atinject.tck.version>
- <jboss.interceptor.version>1.0.0-CR3</jboss.interceptor.version>
+ <jboss.interceptor.version>1.0.0-SNAPSHOT</jboss.interceptor.version>
<slf4j.version>1.5.8</slf4j.version>
</properties>
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -46,6 +46,7 @@
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.DefinitionException;
import org.jboss.weld.DeploymentException;
+import org.jboss.weld.ejb.EJBApiAbstraction;
import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.context.SerializableContextual;
@@ -432,7 +433,7 @@
builder.interceptPostActivate().with(toSerializableContextualArray(resolvedPostActivateInterceptors));
}
- List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableBusinessMethods(getAnnotatedItem());
+ List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableMethods(getAnnotatedItem());
for (WeldMethod<?, ?> method : businessMethods)
{
Set<Annotation> methodBindingAnnotations = new HashSet<Annotation>(classBindingAnnotations);
@@ -441,8 +442,17 @@
{
if (Beans.findInterceptorBindingConflicts(manager, classBindingAnnotations))
throw new DeploymentException("Conflicting interceptor bindings found on " + getType() + "." + method.getName() + "()");
- List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_INVOKE, methodBindingAnnotations.toArray(new Annotation[]{}));
- builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
+
+ if (method.isAnnotationPresent(manager.getServices().get(EJBApiAbstraction.class).TIMEOUT_ANNOTATION_CLASS))
+ {
+ List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_TIMEOUT, methodBindingAnnotations.toArray(new Annotation[]{}));
+ builder.interceptAroundTimeout(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
+ }
+ else
+ {
+ List<Interceptor<?>> methodBoundInterceptors = manager.resolveInterceptors(InterceptionType.AROUND_INVOKE, methodBindingAnnotations.toArray(new Annotation[]{}));
+ builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(toSerializableContextualArray(methodBoundInterceptors));
+ }
}
}
InterceptionModel<Class<?>,SerializableContextual<Interceptor<?>,?>> serializableContextualInterceptionModel = builder.build();
@@ -547,7 +557,7 @@
builder.interceptAll().with(classDeclaredInterceptors);
}
- List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableBusinessMethods(getAnnotatedItem());
+ List<WeldMethod<?, ?>> businessMethods = Beans.getInterceptableMethods(getAnnotatedItem());
for (WeldMethod<?, ?> method : businessMethods)
{
boolean excludeClassInterceptors = method.isAnnotationPresent(InterceptionUtils.getExcludeClassInterceptorsAnnotationClass());
@@ -562,7 +572,10 @@
}
if (methodDeclaredInterceptors != null)
{
- builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(methodDeclaredInterceptors);
+ if (method.isAnnotationPresent(manager.getServices().get(EJBApiAbstraction.class).TIMEOUT_ANNOTATION_CLASS))
+ builder.interceptAroundTimeout(((AnnotatedMethod) method).getJavaMember()).with(methodDeclaredInterceptors);
+ else
+ builder.interceptAroundInvoke(((AnnotatedMethod) method).getJavaMember()).with(methodDeclaredInterceptors);
}
}
InterceptionModel<Class<?>, Class<?>> interceptionModel = builder.build();
Modified: core/trunk/impl/src/main/java/org/jboss/weld/ejb/EJBApiAbstraction.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ejb/EJBApiAbstraction.java 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ejb/EJBApiAbstraction.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -36,12 +36,14 @@
ENTERPRISE_BEAN_CLASS = classForName("javax.ejb.EnterpriseBean");
EJB_ANNOTATION_CLASS = annotationTypeForName("javax.ejb.EJB");
RESOURCE_ANNOTATION_CLASS = annotationTypeForName("javax.annotation.Resource");
-
+ TIMEOUT_ANNOTATION_CLASS = annotationTypeForName("javax.ejb.Timeout");
}
public final Class<?> ENTERPRISE_BEAN_CLASS;
public final Class<? extends Annotation> EJB_ANNOTATION_CLASS;
public final Class<? extends Annotation> RESOURCE_ANNOTATION_CLASS;
+ public final Class<? extends Annotation> TIMEOUT_ANNOTATION_CLASS;
+
public void cleanup() {}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -224,7 +224,7 @@
}
}
- public static List<WeldMethod<?,?>> getInterceptableBusinessMethods(WeldClass<?> type)
+ public static List<WeldMethod<?,?>> getInterceptableMethods(WeldClass<?> type)
{
List<WeldMethod<?, ?>> annotatedMethods = new ArrayList<WeldMethod<?, ?>>();
for (WeldMethod<?, ?> annotatedMethod : type.getWeldMethods())
Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/BallImpl.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -18,11 +18,12 @@
package org.jboss.weld.test.unit.interceptor.ejb;
import javax.ejb.Stateless;
+import javax.ejb.Timeout;
/**
* @author <a href="mailto:mariusb@redhat.com">Marius Bogoevici</a>
*/
-@Stateless
+@Stateless @TimeBound
public class BallImpl implements Ball
{
@Shot
@@ -34,4 +35,10 @@
public void pass()
{
}
+
+ @Timeout
+ public void finishGame()
+ {
+
+ }
}
Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/EnterpriseBeanInterceptionTest.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -32,18 +32,25 @@
List<javax.enterprise.inject.spi.Interceptor> interceptors =
new ArrayList<javax.enterprise.inject.spi.Interceptor>(interceptorBindings.getAllInterceptors());
- assert interceptors.size() == 2;
- List<Class<?>> expectedInterceptors = Arrays.<Class<?>>asList(Goalkeeper.class, Defender.class);
+ assert interceptors.size() == 3;
+ List<Class<?>> expectedInterceptors = Arrays.<Class<?>>asList(Goalkeeper.class, Defender.class, Referee.class);
assert expectedInterceptors.contains(interceptors.get(0).getBeanClass());
assert expectedInterceptors.contains(interceptors.get(1).getBeanClass());
+ assert expectedInterceptors.contains(interceptors.get(2).getBeanClass());
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("shoot")).size() == 0;
assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("shoot")).size() == 1;
assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("shoot")).get(0).getBeanClass().equals(Goalkeeper.class);
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("pass")).size() == 0;
assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("pass")).size() == 1;
assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("pass")).get(0).getBeanClass().equals(Defender.class);
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, ballSessionBean.getType().getMethod("finishGame")).size() == 0;
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("finishGame")).size() == 1;
+ assert interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, ballSessionBean.getType().getMethod("finishGame")).get(0).getBeanClass().equals(Referee.class);
+
}
}
Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Referee.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Referee.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Referee.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.test.unit.interceptor.ejb;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundTimeout;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius Bogoevici</a>
+ */
+@Interceptor @TimeBound
+public class Referee
+{
+ public static boolean ballCollected = false;
+
+ @AroundTimeout
+ public Object collectBall(InvocationContext context) throws Exception
+ {
+ ballCollected = true;
+ return context.proceed();
+ }
+}
Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java (from rev 4209, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/Shot.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.weld.test.unit.interceptor.ejb;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.interceptor.InterceptorBinding;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius Bogoevici</a>
+ */
+@InterceptorBinding
+@Retention(RUNTIME)
+(a)Target({ElementType.METHOD, ElementType.TYPE})
+@Documented
+public @interface TimeBound
+{
+}
\ No newline at end of file
Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb/TimeBound.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Ball.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -25,7 +25,7 @@
/**
* @author Marius Bogoevici
*/
-(a)Interceptors(Goalkeeper.class)
+(a)Interceptors({Goalkeeper.class, Referee.class})
public class Ball
{
public static boolean played = false;
Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Referee.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Referee.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/interceptor/ejb3model/Referee.java 2009-10-21 16:17:44 UTC (rev 4215)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.test.unit.interceptor.ejb3model;
+
+import org.jboss.weld.test.unit.interceptor.ejb.TimeBound;
+
+import javax.interceptor.Interceptor;
+import javax.interceptor.AroundTimeout;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="mailto:mariusb@redhat.com">Marius Bogoevici</a>
+ */
+@Interceptor @TimeBound
+public class Referee
+{
+ public static boolean ballCollected = false;
+
+ @AroundTimeout
+ public Object collectBall(InvocationContext context) throws Exception
+ {
+ ballCollected = true;
+ return context.proceed();
+ }
+}
\ No newline at end of file
Modified: core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/test/unit/interceptor/ejb/beans.xml 2009-10-21 16:17:44 UTC (rev 4215)
@@ -2,5 +2,6 @@
<interceptors>
<class>org.jboss.weld.test.unit.interceptor.ejb.Goalkeeper</class>
<class>org.jboss.weld.test.unit.interceptor.ejb.Defender</class>
+ <class>org.jboss.weld.test.unit.interceptor.ejb.Referee</class>
</interceptors>
</beans>
Modified: core/trunk/tests/unit-tests.xml
===================================================================
--- core/trunk/tests/unit-tests.xml 2009-10-21 15:33:07 UTC (rev 4214)
+++ core/trunk/tests/unit-tests.xml 2009-10-21 16:17:44 UTC (rev 4215)
@@ -52,6 +52,10 @@
<package name="org.jboss.weld.test.unit.implementation.producer.method" />
<package name="org.jboss.weld.test.unit.implementation.proxy" />
<package name="org.jboss.weld.test.unit.implementation.proxy.enterprise" />
+ <package name="org.jboss.weld.test.unit.interceptor.ejb" />
+ <package name="org.jboss.weld.test.unit.interceptor.ejb3model" />
+ <package name="org.jboss.weld.test.unit.interceptor.passivation" />
+ <package name="org.jboss.weld.test.unit.interceptor.simple" />
<package name="org.jboss.weld.test.unit.lookup" />
<package name="org.jboss.weld.test.unit.lookup.circular" />
<package name="org.jboss.weld.test.unit.lookup.wbri279" />
15 years, 1 month
Weld SVN: r4214 - in core/trunk/tests: src/test/java/org/jboss/weld/test/unit and 1 other directories.
by weld-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-10-21 11:33:07 -0400 (Wed, 21 Oct 2009)
New Revision: 4214
Added:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/PreinstantiateBeanManagerTest.java
Removed:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/PreinstantiateBeanManager.java
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/WeldBean.java
core/trunk/tests/unit-tests.xml
Log:
[WELD-220] I hopefully have the names correct this time...
Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager (from rev 4212, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver)
Deleted: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/PreinstantiateBeanManager.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManager.java 2009-10-21 15:18:12 UTC (rev 4212)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/PreinstantiateBeanManager.java 2009-10-21 15:33:07 UTC (rev 4214)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld.test.unit.clearresolver;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.jboss.weld.mock.MockEELifecycle;
-import org.jboss.weld.mock.TestContainer;
-import org.testng.annotations.Test;
-
-/**
- * @author kkhan
- *
- */
-public class PreinstantiateBeanManager
-{
-
- @Test
- public void test()
- {
- //Start the container, but do not deploy weld yet
- List<Class<?>> classes = new ArrayList<Class<?>>();
- classes.add(WeldBean.class);
- TestContainer container = new TestContainer(new MockEELifecycle(), classes, null);
- container.startContainer(false);
-
- BeanManager bootstrapManager = container.getBeanManager();
- assert bootstrapManager != null;
-
- //Check the bean is null since it is not there yet
- Set<Bean<?>> beans = bootstrapManager.getBeans(WeldBean.class);
- assert beans == null || beans.size() == 0;
-
-
- //Start the application
- container.beginApplication();
- container.ensureRequestActive();
-
- //Check the manager is the same as before
- BeanManager manager = container.getBeanManager();
- assert manager != null;
- assert bootstrapManager == manager;
-
- //Check we can get the bean
- Bean<? extends Object> bean = manager.resolve(manager.getBeans(WeldBean.class));
- WeldBean weldBean = (WeldBean) manager.getReference(bean, WeldBean.class, manager.createCreationalContext(bean));
- assert weldBean != null;
-
- container.stopContainer();
- }
-
-}
Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/PreinstantiateBeanManagerTest.java (from rev 4213, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/PreinstantiateBeanManagerTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/PreinstantiateBeanManagerTest.java 2009-10-21 15:33:07 UTC (rev 4214)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.test.unit.preinstantiatebeanmanager;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.weld.mock.MockEELifecycle;
+import org.jboss.weld.mock.TestContainer;
+import org.testng.annotations.Test;
+
+/**
+ * @author kkhan
+ *
+ */
+public class PreinstantiateBeanManagerTest
+{
+
+ @Test
+ public void test()
+ {
+ //Start the container, but do not deploy weld yet
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ classes.add(WeldBean.class);
+ TestContainer container = new TestContainer(new MockEELifecycle(), classes, null);
+ container.startContainer(false);
+
+ BeanManager bootstrapManager = container.getBeanManager();
+ assert bootstrapManager != null;
+
+ //Check the bean is null since it is not there yet
+ Set<Bean<?>> beans = bootstrapManager.getBeans(WeldBean.class);
+ assert beans == null || beans.size() == 0;
+
+
+ //Start the application
+ container.beginApplication();
+ container.ensureRequestActive();
+
+ //Check the manager is the same as before
+ BeanManager manager = container.getBeanManager();
+ assert manager != null;
+ assert bootstrapManager == manager;
+
+ //Check we can get the bean
+ Bean<? extends Object> bean = manager.resolve(manager.getBeans(WeldBean.class));
+ WeldBean weldBean = (WeldBean) manager.getReference(bean, WeldBean.class, manager.createCreationalContext(bean));
+ assert weldBean != null;
+
+ container.stopContainer();
+ }
+
+}
Modified: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/WeldBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/WeldBean.java 2009-10-21 15:18:12 UTC (rev 4212)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/preinstantiatebeanmanager/WeldBean.java 2009-10-21 15:33:07 UTC (rev 4214)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.weld.test.unit.clearresolver;
+package org.jboss.weld.test.unit.preinstantiatebeanmanager;
/**
*
Modified: core/trunk/tests/unit-tests.xml
===================================================================
--- core/trunk/tests/unit-tests.xml 2009-10-21 15:22:22 UTC (rev 4213)
+++ core/trunk/tests/unit-tests.xml 2009-10-21 15:33:07 UTC (rev 4214)
@@ -58,6 +58,7 @@
<package name="org.jboss.weld.test.unit.lookup.wbri293" />
<package name="org.jboss.weld.test.unit.manager" />
<package name="org.jboss.weld.test.unit.noncontextual" />
+ <package name="org.jboss.weld.test.unit.preinstantiatebeanmanager" />
<package name="org.jboss.weld.test.unit.security" />
</packages>
</test>
15 years, 1 month
Weld SVN: r4213 - core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver.
by weld-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-10-21 11:22:22 -0400 (Wed, 21 Oct 2009)
New Revision: 4213
Added:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java
Log:
[WELD-220] Bad name
Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java (from rev 4212, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManager.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java 2009-10-21 15:22:22 UTC (rev 4213)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.test.unit.clearresolver;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.weld.mock.MockEELifecycle;
+import org.jboss.weld.mock.TestContainer;
+import org.testng.annotations.Test;
+
+/**
+ * @author kkhan
+ *
+ */
+public class PreinstantiateBeanManagerTest
+{
+
+ @Test
+ public void test()
+ {
+ //Start the container, but do not deploy weld yet
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ classes.add(WeldBean.class);
+ TestContainer container = new TestContainer(new MockEELifecycle(), classes, null);
+ container.startContainer(false);
+
+ BeanManager bootstrapManager = container.getBeanManager();
+ assert bootstrapManager != null;
+
+ //Check the bean is null since it is not there yet
+ Set<Bean<?>> beans = bootstrapManager.getBeans(WeldBean.class);
+ assert beans == null || beans.size() == 0;
+
+
+ //Start the application
+ container.beginApplication();
+ container.ensureRequestActive();
+
+ //Check the manager is the same as before
+ BeanManager manager = container.getBeanManager();
+ assert manager != null;
+ assert bootstrapManager == manager;
+
+ //Check we can get the bean
+ Bean<? extends Object> bean = manager.resolve(manager.getBeans(WeldBean.class));
+ WeldBean weldBean = (WeldBean) manager.getReference(bean, WeldBean.class, manager.createCreationalContext(bean));
+ assert weldBean != null;
+
+ container.stopContainer();
+ }
+
+}
15 years, 1 month
Weld SVN: r4212 - in core/trunk/tests/src: test/java/org/jboss/weld/test/unit and 1 other directories.
by weld-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-10-21 11:18:12 -0400 (Wed, 21 Oct 2009)
New Revision: 4212
Added:
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManager.java
core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/WeldBean.java
Modified:
core/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java
Log:
[WELD-220] Make it possible to obtain the bean manager before the beans are deployed in TestContainer.
Modified: core/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java
===================================================================
--- core/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java 2009-10-21 14:59:56 UTC (rev 4211)
+++ core/trunk/tests/src/main/java/org/jboss/weld/mock/TestContainer.java 2009-10-21 15:18:12 UTC (rev 4212)
@@ -39,7 +39,7 @@
private final MockServletLifecycle lifecycle;
private final Collection<Class<?>> classes;
private final Collection<URL> beansXml;
-
+
/**
* Create a container, specifying the classes and beans.xml to deploy
*
@@ -72,8 +72,20 @@
return new Status(null);
}
+ /**
+ * Starts the container and begins the application
+ */
public void startContainer()
{
+ startContainer(true);
+ }
+
+ /**
+ * Starts the container
+ * @param beginApplication whether or not beginApplication() should be called
+ */
+ public void startContainer(boolean beginApplication)
+ {
MockBeanDeploymentArchive archive = lifecycle.getDeployment().getArchive();
archive.setBeanClasses(classes);
if (beansXml != null)
@@ -81,6 +93,18 @@
archive.setBeansXmlFiles(beansXml);
}
lifecycle.initialize();
+ if (beginApplication)
+ {
+ beginApplication();
+ }
+ }
+
+ /**
+ * Deploys the application. Intended use is in conjunction with {@link #startContainer(boolean)}.
+ * {@link #startContainer()} does this step automatically
+ */
+ public void beginApplication()
+ {
lifecycle.beginApplication();
}
Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManager.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManager.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManager.java 2009-10-21 15:18:12 UTC (rev 4212)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.test.unit.clearresolver;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.weld.mock.MockEELifecycle;
+import org.jboss.weld.mock.TestContainer;
+import org.testng.annotations.Test;
+
+/**
+ * @author kkhan
+ *
+ */
+public class PreinstantiateBeanManager
+{
+
+ @Test
+ public void test()
+ {
+ //Start the container, but do not deploy weld yet
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ classes.add(WeldBean.class);
+ TestContainer container = new TestContainer(new MockEELifecycle(), classes, null);
+ container.startContainer(false);
+
+ BeanManager bootstrapManager = container.getBeanManager();
+ assert bootstrapManager != null;
+
+ //Check the bean is null since it is not there yet
+ Set<Bean<?>> beans = bootstrapManager.getBeans(WeldBean.class);
+ assert beans == null || beans.size() == 0;
+
+
+ //Start the application
+ container.beginApplication();
+ container.ensureRequestActive();
+
+ //Check the manager is the same as before
+ BeanManager manager = container.getBeanManager();
+ assert manager != null;
+ assert bootstrapManager == manager;
+
+ //Check we can get the bean
+ Bean<? extends Object> bean = manager.resolve(manager.getBeans(WeldBean.class));
+ WeldBean weldBean = (WeldBean) manager.getReference(bean, WeldBean.class, manager.createCreationalContext(bean));
+ assert weldBean != null;
+
+ container.stopContainer();
+ }
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/WeldBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/WeldBean.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/WeldBean.java 2009-10-21 15:18:12 UTC (rev 4212)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.weld.test.unit.clearresolver;
+
+/**
+ *
+ * @author <a href="kabir.khan(a)jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WeldBean
+{
+
+}
15 years, 1 month