[webbeans-commits] Webbeans SVN: r2297 - ri/trunk/impl/src/main/java/org/jboss/webbeans/util and 7 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-04 09:53:33 -0400 (Sat, 04 Apr 2009)
New Revision: 2297
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentLiteral.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Mustard.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherLiteral.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentBinding.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BakedBean_Broken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Proxies.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/ProducerFieldDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BrokenInjectedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Vanilla.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/instantiation/InstantiationByTypeTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/ResolutionByTypeTest.java
Log:
WBRI-215
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -67,20 +67,19 @@
import org.jboss.webbeans.context.ApplicationContext;
import org.jboss.webbeans.context.ContextMap;
import org.jboss.webbeans.context.CreationalContextImpl;
-import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injection.NonContextualInjector;
import org.jboss.webbeans.injection.resolution.ResolvableAnnotatedClass;
import org.jboss.webbeans.injection.resolution.Resolver;
import org.jboss.webbeans.introspector.AnnotatedItem;
-import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.manager.api.WebBeansManager;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.Reflections;
/**
@@ -661,22 +660,26 @@
currentInjectionPoint.get().push(injectionPoint);
}
AnnotatedItem<T, ?> element = ResolvableAnnotatedClass.of(injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]));
- Bean<T> bean = getBeanByType(element, element.getBindingsAsArray());
+ Bean<T> resolvedBean = getBeanByType(element, element.getBindingsAsArray());
+ if (getServices().get(MetaDataCache.class).getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(injectionPoint.getType()))
+ {
+ throw new UnproxyableDependencyException("Attempting to inject an unproxyable normal scoped bean " + resolvedBean + " into " + injectionPoint);
+ }
if (creationalContext instanceof CreationalContextImpl)
{
CreationalContextImpl<?> ctx = (CreationalContextImpl<?>) creationalContext;
- if (ctx.containsIncompleteInstance(bean))
+ if (ctx.containsIncompleteInstance(resolvedBean))
{
- return ctx.getIncompleteInstance(bean);
+ return ctx.getIncompleteInstance(resolvedBean);
}
else
{
- return getInstance(bean, ctx.getCreationalContext(bean));
+ return getInstance(resolvedBean, ctx.getCreationalContext(resolvedBean));
}
}
else
{
- return getInstance(bean);
+ return getInstance(resolvedBean);
}
}
finally
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Proxies.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Proxies.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Proxies.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -16,6 +16,8 @@
*/
package org.jboss.webbeans.util;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Iterator;
@@ -195,25 +197,33 @@
{
return true;
}
- else if (Reflections.getConstructor(clazz) == null)
- {
- return false;
- }
- else if (Reflections.isTypeOrAnyMethodFinal(clazz))
- {
- return false;
- }
- else if (Reflections.isPrimitive(clazz))
- {
- return false;
- }
- else if (Reflections.isArrayType(clazz))
- {
- return false;
- }
else
{
- return true;
+ Constructor<?> constructor = Reflections.getDeclaredConstructor(clazz);
+ if (constructor == null)
+ {
+ return false;
+ }
+ else if (Modifier.isPrivate(constructor.getModifiers()))
+ {
+ return false;
+ }
+ else if (Reflections.isTypeOrAnyMethodFinal(clazz))
+ {
+ return false;
+ }
+ else if (Reflections.isPrimitive(clazz))
+ {
+ return false;
+ }
+ else if (Reflections.isArrayType(clazz))
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -336,7 +336,7 @@
* @param parameterTypes The parameter types
* @return The matching constructor. Null is returned if none is found
*/
- public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... parameterTypes)
+ public static <T> Constructor<T> getDeclaredConstructor(Class<T> clazz, Class<?>... parameterTypes)
{
try
{
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentBinding.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentBinding.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentBinding.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -1,11 +0,0 @@
-package org.jboss.jsr299.tck.literals;
-
-import javax.inject.AnnotationLiteral;
-import javax.inject.Current;
-
-/**
- * Annotation literal for @Current
- *
- * @author Pete Muir
- */
-public class CurrentBinding extends AnnotationLiteral<Current> implements Current {}
\ No newline at end of file
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentLiteral.java (from rev 2287, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentBinding.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentLiteral.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/literals/CurrentLiteral.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.literals;
+
+import javax.inject.AnnotationLiteral;
+import javax.inject.Current;
+
+/**
+ * Annotation literal for @Current
+ *
+ * @author Pete Muir
+ */
+public class CurrentLiteral extends AnnotationLiteral<Current> implements Current {}
\ No newline at end of file
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/binding/BindingDefinitionTest.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -12,7 +12,7 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.CurrentBinding;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -129,7 +129,7 @@
{
Bean<?> model = getCurrentManager().resolveByType(Tuna.class).iterator().next();
assert model.getBindings().size() == 1;
- assert model.getBindings().contains(new CurrentBinding());
+ assert model.getBindings().contains(new CurrentLiteral());
assert false;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/ProducerFieldDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/ProducerFieldDefinitionTest.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/ProducerFieldDefinitionTest.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -11,7 +11,7 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.CurrentBinding;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -77,7 +77,7 @@
{
Set<Bean<Tarantula>> tarantulaBeans = getCurrentManager().resolveByType(Tarantula.class);
assert tarantulaBeans.size() == 1;
- assert tarantulaBeans.iterator().next().getBindings().contains(new CurrentBinding());
+ assert tarantulaBeans.iterator().next().getBindings().contains(new CurrentLiteral());
}
@Test(groups = "producerField")
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BakedBean_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BakedBean_Broken.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BakedBean_Broken.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -1,12 +0,0 @@
-package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
-
-public class BakedBean_Broken
-{
- /*
- * private constructor makes this bean unproxyable
- */
- private BakedBean_Broken()
- {
-
- }
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BrokenInjectedBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BrokenInjectedBean.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BrokenInjectedBean.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -2,7 +2,8 @@
import javax.inject.Current;
+
class BrokenInjectedBean
{
- @Current public BakedBean_Broken bakedBean;
+ public @Current Mustard mustard;
}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
-
-import javax.inject.AnnotationLiteral;
-import javax.inject.Current;
-
-class CurrentBinding extends AnnotationLiteral<Current> implements Current
-{
-
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -7,6 +7,7 @@
import java.util.HashSet;
import java.util.Set;
+import javax.context.RequestScoped;
import javax.inject.UnproxyableDependencyException;
import javax.inject.UnsatisfiedDependencyException;
import javax.inject.manager.Bean;
@@ -15,6 +16,8 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.ForwardingBean;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -84,7 +87,7 @@
Field injectedField = InjectedBean.class.getField("vanilla");
Set<Annotation> bindings = new HashSet<Annotation>();
- bindings.add(new CurrentBinding());
+ bindings.add(new CurrentLiteral());
MockInjectionPoint injectionPoint = new MockInjectionPoint(vanillaBean, Vanilla.class, injectedField, bindings);
assert getCurrentManager().getInstanceToInject(injectionPoint) instanceof Vanilla;
@@ -98,7 +101,7 @@
Field injectedField = InjectedBean.class.getField("vanilla");
Set<Annotation> bindings = new HashSet<Annotation>();
- bindings.add(new OtherBinding());
+ bindings.add(new OtherLiteral());
MockInjectionPoint injectionPoint = new MockInjectionPoint(vanillaBean, Vanilla.class, injectedField, bindings);
assert getCurrentManager().getInstanceToInject(injectionPoint) instanceof Vanilla;
@@ -112,21 +115,52 @@
Field injectedField = InjectedBean.class.getField("vanilla");
Set<Annotation> bindings = new HashSet<Annotation>();
- bindings.add(new OtherBinding());
+ bindings.add(new OtherLiteral());
MockInjectionPoint injectionPoint = new MockInjectionPoint(vanillaBean, Vanilla.class, injectedField, bindings);
getCurrentManager().getInstanceToInject(injectionPoint);
}
- @Test(expectedExceptions = UnproxyableDependencyException.class, groups = "ri-broken")
+ @Test(expectedExceptions=UnproxyableDependencyException.class)
@SpecAssertion(section = "5.7.1", id = "g")
public void testGetInstanceToInjectThrowsUnproxyableDependencyException() throws Exception
{
- Bean<BakedBean_Broken> bakedBean = getCurrentManager().resolveByType(BakedBean_Broken.class).iterator().next();
+ final Bean<Mustard> bean = getCurrentManager().resolveByType(Mustard.class).iterator().next();
+ final Set<Annotation> bindings = new HashSet<Annotation>();
+ bindings.add(new OtherLiteral());
- Field injectedField = BrokenInjectedBean.class.getField("bakedBean");
- Set<Annotation> bindings = new HashSet<Annotation>();
- bindings.add(new CurrentBinding());
- MockInjectionPoint injectionPoint = new MockInjectionPoint(bakedBean, BakedBean_Broken.class, injectedField, bindings);
+ Bean<Mustard> wrappedBean = new ForwardingBean<Mustard>(getCurrentManager())
+ {
+
+ @Override
+ protected Bean<Mustard> delegate()
+ {
+ return bean;
+ }
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return RequestScoped.class;
+ }
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return bindings;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return this == obj;
+ }
+
+ };
+
+ getCurrentManager().addBean(wrappedBean);
+
+ Field injectedField = BrokenInjectedBean.class.getField("mustard");
+ MockInjectionPoint injectionPoint = new MockInjectionPoint(bean, Mustard.class, injectedField, bindings);
getCurrentManager().getInstanceToInject(injectionPoint);
}
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Mustard.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Mustard.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Mustard.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -0,0 +1,12 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+
+public class Mustard
+{
+
+ private Mustard()
+ {
+ // TODO Auto-generated constructor stub
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Mustard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -1,8 +0,0 @@
-package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
-
-import javax.inject.AnnotationLiteral;
-
-class OtherBinding extends AnnotationLiteral<Other> implements Other
-{
-
-}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherLiteral.java (from rev 2287, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherLiteral.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherLiteral.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+import javax.inject.AnnotationLiteral;
+
+class OtherLiteral extends AnnotationLiteral<Other> implements Other
+{
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Vanilla.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Vanilla.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Vanilla.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -1,5 +1,6 @@
package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
class Vanilla
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -33,7 +33,7 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.CurrentBinding;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -60,7 +60,7 @@
@Override
protected void execute() throws Exception
{
- FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+ FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
@@ -82,7 +82,7 @@
@Override
protected void execute() throws Exception
{
- FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+ FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
assert beanWithInjectionPoint.getInjectedMetadata().getType().equals(BeanWithInjectionPointMetadata.class);
@@ -101,7 +101,7 @@
@Override
protected void execute() throws Exception
{
- FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+ FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
Set<Annotation> bindingTypes = beanWithInjectionPoint.getInjectedMetadata().getBindings();
@@ -122,7 +122,7 @@
@Override
protected void execute() throws Exception
{
- FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+ FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
assert Field.class.isAssignableFrom(beanWithInjectionPoint.getInjectedMetadata().getMember().getClass());
@@ -141,7 +141,7 @@
@Override
protected void execute() throws Exception
{
- MethodInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(MethodInjectionPointBean.class, new CurrentBinding());
+ MethodInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(MethodInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
assert Method.class.isAssignableFrom(beanWithInjectionPoint.getInjectedMetadata().getMember().getClass());
@@ -149,7 +149,7 @@
// Since the type and bindings must correspond to the parameter, check
// them
assert beanWithInjectionPoint.getInjectedMetadata().getType().equals(BeanWithInjectionPointMetadata.class);
- assert beanWithInjectionPoint.getInjectedMetadata().getBindings().contains(new CurrentBinding());
+ assert beanWithInjectionPoint.getInjectedMetadata().getBindings().contains(new CurrentLiteral());
}
}.run();
}
@@ -165,7 +165,7 @@
@Override
protected void execute() throws Exception
{
- ConstructorInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(ConstructorInjectionPointBean.class, new CurrentBinding());
+ ConstructorInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(ConstructorInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
assert Constructor.class.isAssignableFrom(beanWithInjectionPoint.getInjectedMetadata().getMember().getClass());
@@ -173,7 +173,7 @@
// Since the type and bindings must correspond to the parameter, check
// them
assert beanWithInjectionPoint.getInjectedMetadata().getType().equals(BeanWithInjectionPointMetadata.class);
- assert beanWithInjectionPoint.getInjectedMetadata().getBindings().contains(new CurrentBinding());
+ assert beanWithInjectionPoint.getInjectedMetadata().getBindings().contains(new CurrentLiteral());
}
}.run();
}
@@ -189,7 +189,7 @@
@Override
protected void execute() throws Exception
{
- FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+ FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
assert beanWithInjectionPoint.getInjectedMetadata().getAnnotation(AnimalStereotype.class) != null;
@@ -208,12 +208,12 @@
@Override
protected void execute() throws Exception
{
- FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+ FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
Set<Annotation> annotations = new HashSet<Annotation>(Arrays.asList(beanWithInjectionPoint.getInjectedMetadata().getAnnotations()));
assert annotations.size() > 0;
- assert annotations.contains(new CurrentBinding());
+ assert annotations.contains(new CurrentLiteral());
assert annotations.contains(new AnimalStereotypeAnnotationLiteral());
}
}.run();
@@ -269,7 +269,7 @@
@Override
protected void execute() throws Exception
{
- FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+ FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
assert InjectionPoint.class.isAssignableFrom(beanWithInjectionPoint.getInjectedMetadata().getClass());
@@ -290,10 +290,10 @@
@Override
protected void execute() throws Exception
{
- FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentBinding());
+ FieldInjectionPointBean beanWithInjectedBean = getCurrentManager().getInstanceByType(FieldInjectionPointBean.class, new CurrentLiteral());
BeanWithInjectionPointMetadata beanWithInjectionPoint = beanWithInjectedBean.getInjectedBean();
assert beanWithInjectionPoint.getInjectedMetadata() != null;
- assert beanWithInjectionPoint.getInjectedMetadata().getBindings().contains(new CurrentBinding());
+ assert beanWithInjectionPoint.getInjectedMetadata().getBindings().contains(new CurrentLiteral());
}
}.run();
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/instantiation/InstantiationByTypeTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/instantiation/InstantiationByTypeTest.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/instantiation/InstantiationByTypeTest.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -8,7 +8,7 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.CurrentBinding;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -49,7 +49,7 @@
@SpecAssertion(section="5.7.2", id = "j")
public void testDuplicateBindingTypesUsed()
{
- getCurrentManager().getInstanceByType(Tuna.class, new CurrentBinding(), new CurrentBinding());
+ getCurrentManager().getInstanceByType(Tuna.class, new CurrentLiteral(), new CurrentLiteral());
}
@Test(groups="resolution", expectedExceptions=IllegalArgumentException.class)
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/ResolutionByTypeTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/ResolutionByTypeTest.java 2009-04-03 20:40:25 UTC (rev 2296)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/typesafe/resolution/ResolutionByTypeTest.java 2009-04-04 13:53:33 UTC (rev 2297)
@@ -13,7 +13,7 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.CurrentBinding;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -58,7 +58,7 @@
@SpecAssertion(section="5.9", id = "d")
public void testDuplicateBindingTypesUsed()
{
- getCurrentManager().resolveByType(Tuna.class, new CurrentBinding(), new CurrentBinding());
+ getCurrentManager().resolveByType(Tuna.class, new CurrentLiteral(), new CurrentLiteral());
}
@Test(groups="resolution", expectedExceptions=IllegalArgumentException.class)
@@ -76,7 +76,7 @@
public void testResolveByType() throws Exception
{
- assert getCurrentManager().resolveByType(Tuna.class, new CurrentBinding()).size() == 1;
+ assert getCurrentManager().resolveByType(Tuna.class, new CurrentLiteral()).size() == 1;
assert getCurrentManager().resolveByType(Tuna.class).size() == 1;
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2296 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/event/transactionalObservers and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-04-03 16:40:25 -0400 (Fri, 03 Apr 2009)
New Revision: 2296
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
A few more event test implementations
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-04-03 14:34:40 UTC (rev 2295)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-04-03 20:40:25 UTC (rev 2296)
@@ -196,27 +196,47 @@
assert observer != null;
}
- @Test(groups = { "events", "broken" }, expectedExceptions = { IllegalArgumentException.class })
+ //TODO The exception is never thrown with parameterized types
+ @Test(groups = { "ri-broken", "events" }, expectedExceptions = { IllegalArgumentException.class })
@SpecAssertions( { @SpecAssertion(section = "7.3", id = "f") })
public void testManagerAddObserverWithEventTypeParametersFails()
{
- assert false;
- // ATemplatedEventType<String> anEvent = new
- // ATemplatedEventType<String>();
- // Observer<AnEventType> observer = new AnObserver();
- // getCurrentManager().addObserver(observer, anEvent.getClass());
+ ArrayList<String> anEvent = new ArrayList<String>();
+ Observer<ArrayList<String>> observer = new Observer<ArrayList<String>>() {
+
+ public void notify(ArrayList<String> event)
+ {
+ }
+
+ };
+ observerWithEventObjectContainsTypeVariables(anEvent, observer);
}
+ private <E> void observerWithEventObjectContainsTypeVariables(ArrayList<E> eventToFire, Observer<ArrayList<E>> observer)
+ {
+ getCurrentManager().addObserver(observer, new TypeLiteral<ArrayList<E>>() {});
+ }
+
@Test(groups = { "events", "broken" }, expectedExceptions = { IllegalArgumentException.class })
@SpecAssertions( { @SpecAssertion(section = "7.3", id = "g") })
public void testManagerAddObserverWithEventTypeWildcardsFails()
{
- // Although the above test is really the same as with a wildcard,
- // we will test it anyhow since the specification calls it out separately.
- ATemplatedEventType<?> anEventOnAnyType = new ATemplatedEventType<String>();
- assert false;
+// ArrayList<?> anEvent = new ArrayList<String>();
+// Observer<ArrayList<String>> observer = new Observer<ArrayList<String>>() {
+//
+// public void notify(ArrayList<String> event)
+// {
+// }
+//
+// };
+// observerWithEventObjectContainsTypeWildcard(anEvent, observer);
}
+// private void observerWithEventObjectContainsTypeWildcard(ArrayList<?> eventToFire, Observer<ArrayList<?>> observer)
+// {
+// getCurrentManager().addObserver(observer, new TypeLiteral<ArrayList<?>>() {});
+// }
+
@Test(groups = { "events", "underInvestigation" }, expectedExceptions = { IllegalArgumentException.class })
@SpecAssertions( { @SpecAssertion(section = "7.3", id = "h") })
public void testManagerRemoveObserverWithEventTypeParametersFails()
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java 2009-04-03 20:40:25 UTC (rev 2296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+class DisobedientDog
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DisobedientDog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java 2009-04-03 20:40:25 UTC (rev 2296)
@@ -0,0 +1,69 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+import static javax.ejb.TransactionManagementType.BEAN;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.event.BeforeTransactionCompletion;
+import javax.event.Observes;
+import javax.transaction.UserTransaction;
+
+@Stateless
+@TransactionManagement(BEAN)
+public class DogTrainer implements Trainer
+{
+ @Resource
+ private UserTransaction userTransaction;
+
+ public void train(@Observes @BeforeTransactionCompletion DisobedientDog dog)
+ {
+ try
+ {
+ userTransaction.setRollbackOnly();
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Failed to set transaction rollback only", e);
+ }
+ }
+
+ public void trainNewTricks(@Observes @BeforeTransactionCompletion ShowDog dog)
+ {
+ try
+ {
+ userTransaction.begin();
+ userTransaction.rollback();
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Failed to start new transaction", e);
+ }
+ }
+
+ public void trainCompanion(@Observes @BeforeTransactionCompletion SmallDog dog)
+ {
+ try
+ {
+ userTransaction.rollback();
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Failed to start new transaction", e);
+ }
+ }
+
+ public void trainSightSeeing(@Observes @BeforeTransactionCompletion LargeDog dog)
+ {
+ try
+ {
+ userTransaction.commit();
+ }
+ catch (Exception e)
+ {
+ throw new EJBException("Failed to start new transaction", e);
+ }
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/DogTrainer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java 2009-04-03 14:34:40 UTC (rev 2295)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/EventTest.java 2009-04-03 20:40:25 UTC (rev 2296)
@@ -20,6 +20,7 @@
import java.lang.annotation.Annotation;
import java.math.BigInteger;
+import javax.ejb.EJBException;
import javax.inject.AnnotationLiteral;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -42,7 +43,6 @@
@Artifact
@Packaging(PackagingType.EAR)
@IntegrationTest
-@Test
public class EventTest extends AbstractJSR299Test
{
@@ -97,8 +97,10 @@
assert dog.isCorrectTransactionState();
}
- @Test(groups = { "events", "integration", "broken" })
- @SpecAssertions( { @SpecAssertion(section = "7.5.6", id = "d"), @SpecAssertion(section = "7.5.6", id = "j") })
+ @Test(groups = { "events", "integration" })
+ @SpecAssertions( {
+ @SpecAssertion(section = "7.5.6", id = "d"),
+ @SpecAssertion(section = "7.5.6", id = "j") })
public void testAfterTransactionSuccessObserver() throws InterruptedException
{
dog.setCorrectContext(false);
@@ -110,7 +112,9 @@
}
@Test(groups = { "events", "integration", "ri-broken" })
- @SpecAssertions( { @SpecAssertion(section = "7.5.6", id = "e"), @SpecAssertion(section = "7.5.6", id = "k") })
+ @SpecAssertions( {
+ @SpecAssertion(section = "7.5.6", id = "e"),
+ @SpecAssertion(section = "7.5.6", id = "k") })
public void testAfterTransactionFailureObserver() throws InterruptedException
{
dog.setCorrectContext(false);
@@ -122,7 +126,10 @@
}
@Test(groups = { "events", "integration" })
- @SpecAssertions( { @SpecAssertion(section = "7.5.6", id = "b"), @SpecAssertion(section = "7.5.6", id = "h"), @SpecAssertion(section = "7.5.8", id = "e") })
+ @SpecAssertions( {
+ @SpecAssertion(section = "7.5.6", id = "b"),
+ @SpecAssertion(section = "7.5.6", id = "h"),
+ @SpecAssertion(section = "7.5.8", id = "e") })
public void testBeforeTransactionCompletionObserver()
{
dog.setCorrectContext(false);
@@ -211,32 +218,36 @@
{
assert false;
}
-
- @Test(groups = { "stub", "events", "integration" })
+
+ @Test(groups = { "events", "integration" })
@SpecAssertion(section = "7.4", id = "d")
public void testObserverCanSetRollbackOnlyOnTransaction()
{
- assert false;
+ Agent dogAgent = getCurrentManager().getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new DisobedientDog());
}
- @Test(groups = { "stub", "events", "integration" })
+ @Test(groups = { "ri-broken", "events", "integration" }, expectedExceptions = EJBException.class)
@SpecAssertion(section = "7.4", id = "e")
public void testObserverCannotInitiateJtaTransaction()
{
- assert false;
+ Agent dogAgent = getCurrentManager().getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new ShowDog());
}
- @Test(groups = { "stub", "events", "integration" })
+ @Test(groups = { "ri-broken", "events", "integration" }, expectedExceptions = EJBException.class)
@SpecAssertion(section = "7.4", id = "f")
public void testObserverCannotCommitJtaTransaction()
{
- assert false;
+ Agent dogAgent = getCurrentManager().getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new LargeDog());
}
- @Test(groups = { "stub", "events", "integration" })
+ @Test(groups = { "ri-broken", "events", "integration" }, expectedExceptions = EJBException.class)
@SpecAssertion(section = "7.4", id = "g")
public void testObserverCannotRollbackJtaTransaction()
{
- assert false;
+ Agent dogAgent = getCurrentManager().getInstanceByType(Agent.class);
+ dogAgent.sendInTransaction(new SmallDog());
}
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java 2009-04-03 20:40:25 UTC (rev 2296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+public class LargeDog
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/LargeDog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java 2009-04-03 20:40:25 UTC (rev 2296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+public class ShowDog
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/ShowDog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java 2009-04-03 20:40:25 UTC (rev 2296)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+public class SmallDog
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/SmallDog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java 2009-04-03 20:40:25 UTC (rev 2296)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.event.transactionalObservers;
+
+import javax.ejb.Local;
+
+@Local
+public interface Trainer
+{
+ public void train(DisobedientDog dog);
+
+ public void trainNewTricks(ShowDog dog);
+
+ public void trainSightSeeing(LargeDog dog);
+
+ public void trainCompanion(SmallDog dog);
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/transactionalObservers/Trainer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-04-03 14:34:40 UTC (rev 2295)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-04-03 20:40:25 UTC (rev 2296)
@@ -4007,8 +4007,9 @@
<section id="7.4" title="Observer notification">
- <assertion id="a">
+ <assertion id="a" testable="false">
<text>When an event is fired by the application the container must determine the observers for that event by calling |Manager.resolveObservers()|, passing the event object and all event bindings</text>
+ <note>This is not testable</note>
</assertion>
<assertion id="b">
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2295 - ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-03 10:34:40 -0400 (Fri, 03 Apr 2009)
New Revision: 2295
Modified:
ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
Log:
Fix build
Modified: ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
===================================================================
--- ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java 2009-04-03 12:19:31 UTC (rev 2294)
+++ ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java 2009-04-03 14:34:40 UTC (rev 2295)
@@ -2,9 +2,8 @@
import org.jboss.jsr299.tck.spi.Beans;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
-import org.jboss.webbeans.resources.spi.NamingContext;
+import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.util.Reflections;
/**
@@ -20,19 +19,17 @@
public boolean isEnterpriseBean(Class<?> clazz)
{
- return CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz);
+ return CurrentManager.rootManager().getNewEnterpriseBeanMap().containsKey(clazz);
}
public boolean isEntityBean(Class<?> clazz)
{
- if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz))
+ if (CurrentManager.rootManager().getNewEnterpriseBeanMap().containsKey(clazz))
{
- for (EjbDescriptor<?> ejbDescriptor : CurrentManager.rootManager().getEjbDescriptorCache().get(clazz))
+ EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getNewEnterpriseBeanMap().get(clazz).getEjbDescriptor();
+ if (!ejbDescriptor.isMessageDriven() && !ejbDescriptor.isSingleton() && !ejbDescriptor.isStateful() && !ejbDescriptor.isStateless())
{
- if (!ejbDescriptor.isMessageDriven() && !ejbDescriptor.isSingleton() && !ejbDescriptor.isStateful() && !ejbDescriptor.isStateless())
- {
- return true;
- }
+ return true;
}
}
return false;
@@ -40,14 +37,12 @@
public boolean isStatefulBean(Class<?> clazz)
{
- if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz))
+ if (CurrentManager.rootManager().getNewEnterpriseBeanMap().containsKey(clazz))
{
- for (EjbDescriptor<?> ejbDescriptor : CurrentManager.rootManager().getEjbDescriptorCache().get(clazz))
+ EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getNewEnterpriseBeanMap().get(clazz).getEjbDescriptor();
+ if (ejbDescriptor.isStateful())
{
- if (ejbDescriptor.isStateful())
- {
- return true;
- }
+ return true;
}
}
return false;
@@ -55,14 +50,12 @@
public boolean isStatelessBean(Class<?> clazz)
{
- if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz))
+ if (CurrentManager.rootManager().getNewEnterpriseBeanMap().containsKey(clazz))
{
- for (EjbDescriptor<?> ejbDescriptor : CurrentManager.rootManager().getEjbDescriptorCache().get(clazz))
+ EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getNewEnterpriseBeanMap().get(clazz).getEjbDescriptor();
+ if (ejbDescriptor.isStateless())
{
- if (ejbDescriptor.isStateless())
- {
- return true;
- }
+ return true;
}
}
return false;
@@ -75,23 +68,13 @@
public <T> T getEnterpriseBean(Class<? extends T> beanType, Class<T> localInterface)
{
- T enterpriseBean = null;
- if (CurrentManager.rootManager().getEjbDescriptorCache().containsKey(beanType))
- {
- EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getEjbDescriptorCache().get(beanType).iterator().next();
- String jndiName = null;
- for (BusinessInterfaceDescriptor<?> businessInterface : ejbDescriptor.getLocalBusinessInterfaces())
- {
- if (businessInterface.getInterface().equals(localInterface))
- {
- jndiName = businessInterface.getJndiName();
- }
- }
- if (jndiName == null)
- throw new NullPointerException("No JNDI name found for interface " + localInterface.getName() + " on bean " + beanType.getName());
- enterpriseBean = CurrentManager.rootManager().getServices().get(NamingContext.class).lookup(jndiName, localInterface);
- }
- return enterpriseBean;
+ // Get the EJB Descriptor and resolve it
+ if (CurrentManager.rootManager().getNewEnterpriseBeanMap().containsKey(beanType))
+ {
+ EjbDescriptor<?> ejbDescriptor = CurrentManager.rootManager().getNewEnterpriseBeanMap().get(beanType).getEjbDescriptor();
+ return CurrentManager.rootManager().getServices().get(EjbServices.class).resolveEjb(ejbDescriptor).getBusinessObject(localInterface);
+ }
+ throw new NullPointerException("No EJB found for " + localInterface.getName() + " on bean " + beanType.getName());
}
}
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2294 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bean and 14 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-03 08:19:31 -0400 (Fri, 03 Apr 2009)
New Revision: 2294
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/annotatedItem/ClassAnnotatedItemTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/deploy/BeansXmlParserTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java
Log:
tidy up usage of ejb descriptors, start on moving all creation of annotated items to a single stateful location suitable for exposing via SPI
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -104,6 +104,7 @@
// The enabled deployment types from web-beans.xml
private transient List<Class<? extends Annotation>> enabledDeploymentTypes;
+
// The Web Beans event manager
private transient final EventManager eventManager;
@@ -118,25 +119,20 @@
// The registered contexts
private transient final ContextMap contextMap;
+
// The client proxy pool
private transient final ClientProxyProvider clientProxyProvider;
+
// The registered beans
private transient List<Bean<?>> beans;
+
// The registered beans, mapped by implementation class
private transient final Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeanMap;
private transient final Map<String, RIBean<?>> riBeans;
-
- // The registered decorators
- private transient final Set<Decorator> decorators;
- // The registered interceptors
- private transient final Set<Interceptor> interceptors;
-
- // The EJB resolver provided by the container
+
private transient final ServiceRegistry services;
- private transient final EjbDescriptorCache ejbDescriptorCache;
-
private final transient Map<Bean<?>, Bean<?>> specializedBeans;
private final transient NonContextualInjector nonContextualInjector;
@@ -154,11 +150,8 @@
this.riBeans = new ConcurrentHashMap<String, RIBean<?>>();
this.resolver = new Resolver(this);
this.clientProxyProvider = new ClientProxyProvider();
- this.decorators = new HashSet<Decorator>();
- this.interceptors = new HashSet<Interceptor>();
this.contextMap = new ContextMap();
this.eventManager = new EventManager(this);
- this.ejbDescriptorCache = new EjbDescriptorCache();
this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
{
@Override
@@ -460,8 +453,7 @@
*/
public Manager addDecorator(Decorator decorator)
{
- decorators.add(decorator);
- return this;
+ throw new UnsupportedOperationException("Not yet implemented");
}
/**
@@ -474,8 +466,7 @@
*/
public Manager addInterceptor(Interceptor interceptor)
{
- interceptors.add(interceptor);
- return this;
+ throw new UnsupportedOperationException("Not yet implemented");
}
/**
@@ -874,11 +865,6 @@
return resolver;
}
- public EjbDescriptorCache getEjbDescriptorCache()
- {
- return ejbDescriptorCache;
- }
-
/**
* Gets a string representation
*
@@ -892,8 +878,6 @@
buffer.append("Enabled deployment types: " + getEnabledDeploymentTypes() + "\n");
buffer.append("Registered contexts: " + contextMap.keySet() + "\n");
buffer.append("Registered beans: " + getBeans().size() + "\n");
- buffer.append("Registered decorators: " + decorators.size() + "\n");
- buffer.append("Registered interceptors: " + interceptors.size() + "\n");
buffer.append("Specialized beans: " + specializedBeans.size() + "\n");
return buffer.toString();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -144,7 +144,7 @@
mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager);
if (isSpecializing())
{
- preSpecialize();
+ preSpecialize(environment);
specialize(environment);
postSpecialize();
}
@@ -348,7 +348,7 @@
manager.getSpecializedBeans().put(getSpecializedBean(), this);
}
- protected void preSpecialize()
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -277,9 +277,9 @@
}
@Override
- protected void preSpecialize()
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
- super.preSpecialize();
+ super.preSpecialize(environment);
if (getAnnotatedItem().getSuperclass() == null || getAnnotatedItem().getSuperclass().getRawType().equals(Object.class))
{
throw new DefinitionException("Specializing bean must extend another bean " + toString());
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -17,6 +17,7 @@
package org.jboss.webbeans.bean;
+import java.beans.BeanDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
@@ -41,6 +42,7 @@
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.DependentStorageRequest;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
@@ -77,9 +79,9 @@
* @param manager the current manager
* @return An Enterprise Web Bean
*/
- public static <T> EnterpriseBean<T> of(AnnotatedClass<T> clazz, RootManager manager)
+ public static <T> EnterpriseBean<T> of(AnnotatedClass<T> clazz, RootManager manager, BeanDeployerEnvironment environment)
{
- return new EnterpriseBean<T>(clazz, manager);
+ return new EnterpriseBean<T>(clazz, manager, environment);
}
/**
@@ -88,11 +90,11 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected EnterpriseBean(AnnotatedClass<T> type, RootManager manager)
+ protected EnterpriseBean(AnnotatedClass<T> type, RootManager manager, BeanDeployerEnvironment environment)
{
super(type, manager);
initType();
- Iterable<InternalEjbDescriptor<T>> ejbDescriptors = manager.getEjbDescriptorCache().get(getType());
+ Iterable<InternalEjbDescriptor<T>> ejbDescriptors = environment.getEjbDescriptors().get(getType());
if (ejbDescriptors == null)
{
throw new DefinitionException("Not an EJB " + toString());
@@ -189,10 +191,11 @@
/**
* Validates specialization
*/
- protected void preSpecialize()
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
- super.preSpecialize();
- if (!manager.getEjbDescriptorCache().containsKey(getAnnotatedItem().getSuperclass().getRawType()))
+ super.preSpecialize(environment);
+ if (!environment.getEjbDescriptors().containsKey(getAnnotatedItem().getSuperclass().getRawType()))
{
throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -25,6 +25,7 @@
import javax.inject.Standard;
import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.literal.NewLiteral;
@@ -44,9 +45,9 @@
* @param manager The Web Beans manager
* @return a new NewEnterpriseBean instance
*/
- public static <T> NewEnterpriseBean<T> of(AnnotatedClass<T> clazz, RootManager manager)
+ public static <T> NewEnterpriseBean<T> of(AnnotatedClass<T> clazz, RootManager manager, BeanDeployerEnvironment environment)
{
- return new NewEnterpriseBean<T>(clazz, manager);
+ return new NewEnterpriseBean<T>(clazz, manager, environment);
}
/**
@@ -55,9 +56,9 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewEnterpriseBean(AnnotatedClass<T> type, RootManager manager)
+ protected NewEnterpriseBean(AnnotatedClass<T> type, RootManager manager, BeanDeployerEnvironment environment)
{
- super(type, manager);
+ super(type, manager, environment);
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -248,7 +248,7 @@
}
@Override
- protected void preSpecialize()
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
if (declaringBean.getAnnotatedItem().getSuperclass().getDeclaredMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -355,10 +355,10 @@
}
@Override
- protected void preSpecialize()
+ protected void preSpecialize(BeanDeployerEnvironment environment)
{
- super.preSpecialize();
- if (manager.getEjbDescriptorCache().containsKey(getAnnotatedItem().getSuperclass().getRawType()))
+ super.preSpecialize(environment);
+ if (environment.getEjbDescriptors().containsKey(getAnnotatedItem().getSuperclass().getRawType()))
{
throw new DefinitionException("Simple bean must specialize a simple bean");
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -25,6 +25,7 @@
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.event.ObserverFactory;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.introspector.AnnotatedClass;
@@ -37,6 +38,8 @@
import org.jboss.webbeans.jsf.JSFApiAbstraction;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.resources.ClassTransformer;
+import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.servlet.ServletApiAbstraction;
import org.jboss.webbeans.util.Reflections;
@@ -45,20 +48,23 @@
private static final LogProvider log = Logging.getLogProvider(BeanDeployer.class);
- private final BeanDeployerEnvironment beanDeployerEnvironment;
+ private final BeanDeployerEnvironment environment;
private final Set<AnnotatedClass<?>> classes;
private final RootManager manager;
+ private final ClassTransformer classTransformer;
- public BeanDeployer(RootManager manager)
+
+ public BeanDeployer(RootManager manager, EjbDescriptorCache ejbDescriptors)
{
this.manager = manager;
- this.beanDeployerEnvironment = new BeanDeployerEnvironment();
+ this.environment = new BeanDeployerEnvironment(ejbDescriptors);
this.classes = new HashSet<AnnotatedClass<?>>();
+ this.classTransformer = new ClassTransformer();
}
public <T> BeanDeployer addBean(RIBean<T> bean)
{
- this.beanDeployerEnvironment.addBean(bean);
+ this.environment.addBean(bean);
return this;
}
@@ -66,7 +72,7 @@
{
if (!clazz.isAnnotation() && !clazz.isEnum())
{
- classes.add(AnnotatedClassImpl.of(clazz));
+ classes.add(classTransformer.classForName(clazz));
}
return this;
}
@@ -90,7 +96,7 @@
{
for (AnnotatedClass<?> clazz : classes)
{
- if (manager.getEjbDescriptorCache().containsKey(clazz.getRawType()))
+ if (environment.getEjbDescriptors().containsKey(clazz.getRawType()))
{
createEnterpriseBean(clazz);
}
@@ -104,14 +110,14 @@
public BeanDeployer deploy()
{
- Set<RIBean<?>> beans = beanDeployerEnvironment.getBeans();
+ Set<RIBean<?>> beans = environment.getBeans();
for (RIBean<?> bean : beans)
{
- bean.initialize(beanDeployerEnvironment);
+ bean.initialize(environment);
log.info("Bean: " + bean);
}
manager.setBeans(beans);
- for (ObserverImpl<?> observer : beanDeployerEnvironment.getObservers())
+ for (ObserverImpl<?> observer : environment.getObservers())
{
observer.initialize();
log.info("Observer : " + observer);
@@ -126,8 +132,8 @@
private void checkDisposalMethods() {
- Set<DisposalMethodBean<?>> all = new HashSet<DisposalMethodBean<?>>(beanDeployerEnvironment.getAllDisposalBeans());
- Set<DisposalMethodBean<?>> resolved = new HashSet<DisposalMethodBean<?>>(beanDeployerEnvironment.getResolvedDisposalBeans());
+ Set<DisposalMethodBean<?>> all = new HashSet<DisposalMethodBean<?>>(environment.getAllDisposalBeans());
+ Set<DisposalMethodBean<?>> resolved = new HashSet<DisposalMethodBean<?>>(environment.getResolvedDisposalBeans());
if(all.size()>0 && !resolved.containsAll(all)) {
StringBuffer buff = new StringBuffer();
buff.append("The following Disposal methods where not resolved\n");
@@ -141,7 +147,7 @@
public BeanDeployerEnvironment getBeanDeployerEnvironment()
{
- return beanDeployerEnvironment;
+ return environment;
}
/**
@@ -186,7 +192,7 @@
for (AnnotatedMethod<?> method : annotatedClass.getDeclaredMethodsWithAnnotatedParameters(Disposes.class))
{
DisposalMethodBean<?> disposalBean = DisposalMethodBean.of(manager, method, declaringBean);
- beanDeployerEnvironment.addAllDisposalBean(disposalBean);
+ environment.addAllDisposalBean(disposalBean);
manager.getResolver().addInjectionPoints(disposalBean.getInjectionPoints());
manager.addBean(disposalBean);
}
@@ -247,7 +253,7 @@
private void createObserverMethod(AbstractClassBean<?> declaringBean, AnnotatedMethod<?> method)
{
ObserverImpl<?> observer = ObserverFactory.create(method, declaringBean, manager);
- beanDeployerEnvironment.getObservers().add(observer);
+ environment.getObservers().add(observer);
}
private <T> void createSimpleBean(AnnotatedClass<T> annotatedClass)
@@ -260,9 +266,9 @@
private <T> void createEnterpriseBean(AnnotatedClass<T> annotatedClass)
{
// TODO Don't create enterprise bean if it has no local interfaces!
- EnterpriseBean<T> bean = EnterpriseBean.of(annotatedClass, manager);
+ EnterpriseBean<T> bean = EnterpriseBean.of(annotatedClass, manager, environment);
createBean(bean, annotatedClass);
- addBean(NewEnterpriseBean.of(annotatedClass, manager));
+ addBean(NewEnterpriseBean.of(annotatedClass, manager, environment));
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -12,6 +12,7 @@
import org.jboss.webbeans.bean.NewBean;
import org.jboss.webbeans.bean.ProducerMethodBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injection.resolution.ResolvableAnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedClass;
@@ -29,8 +30,9 @@
private final Set<ObserverImpl<?>> observers;
private final Set<DisposalMethodBean<?>> allDisposalBeans;
private final Set<DisposalMethodBean<?>> resolvedDisposalBeans;
+ private final EjbDescriptorCache ejbDescriptors;
- public BeanDeployerEnvironment()
+ public BeanDeployerEnvironment(EjbDescriptorCache ejbDescriptors)
{
this.classBeanMap = new HashMap<AnnotatedClass<?>, AbstractClassBean<?>>();
this.methodBeanMap = new HashMap<AnnotatedMethod<?>, ProducerMethodBean<?>>();
@@ -38,6 +40,7 @@
this.resolvedDisposalBeans = new HashSet<DisposalMethodBean<?>>();
this.beans = new HashSet<RIBean<?>>();
this.observers = new HashSet<ObserverImpl<?>>();
+ this.ejbDescriptors = ejbDescriptors;
}
public ProducerMethodBean<?> getProducerMethod(AnnotatedMethod<?> method)
@@ -113,5 +116,10 @@
{
return resolvedDisposalBeans;
}
+
+ public EjbDescriptorCache getEjbDescriptors()
+ {
+ return ejbDescriptors;
+ }
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -47,6 +47,7 @@
import org.jboss.webbeans.conversation.NumericConversationIdGenerator;
import org.jboss.webbeans.conversation.ServletConversationManager;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.jsf.JSFApiAbstraction;
@@ -55,6 +56,7 @@
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.MetaDataCache;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.DefaultNamingContext;
import org.jboss.webbeans.resources.DefaultResourceLoader;
import org.jboss.webbeans.resources.spi.NamingContext;
@@ -120,7 +122,12 @@
getServices().add(EJBApiAbstraction.class, new EJBApiAbstraction(resourceLoader));
getServices().add(JSFApiAbstraction.class, new JSFApiAbstraction(resourceLoader));
getServices().add(ServletApiAbstraction.class, new ServletApiAbstraction(resourceLoader));
- getServices().add(MetaDataCache.class, new MetaDataCache());
+ // Temporary workaround to provide context for building annotated class
+ // TODO expose AnnotatedClass on SPI and allow container to provide impl of this via ResourceLoader
+ getServices().add(ClassTransformer.class, new ClassTransformer());
+ getServices().add(MetaDataCache.class, new MetaDataCache(getServices().get(ClassTransformer.class)));
+
+
}
public RootManager getManager()
@@ -134,9 +141,9 @@
*
* @param classes The classes to register as Web Beans
*/
- protected void registerBeans(Iterable<Class<?>> classes, Collection<AnnotatedClass<?>> xmlClasses)
+ protected void registerBeans(Iterable<Class<?>> classes, Collection<AnnotatedClass<?>> xmlClasses, EjbDescriptorCache ejbDescriptors)
{
- BeanDeployer beanDeployer = new BeanDeployer(manager);
+ BeanDeployer beanDeployer = new BeanDeployer(manager, ejbDescriptors);
beanDeployer.addClasses(classes);
beanDeployer.addClasses(xmlClasses);
beanDeployer.addBean(ManagerBean.of(manager));
@@ -170,22 +177,25 @@
beginApplication(getApplicationContext());
BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
beginDeploy(requestBeanStore);
+ EjbDescriptorCache ejbDescriptors = new EjbDescriptorCache();
if (getServices().contains(EjbServices.class))
{
// Must populate EJB cache first, as we need it to detect whether a
// bean is an EJB!
- manager.getEjbDescriptorCache().addAll(getServices().get(EjbServices.class).discoverEjbs());
+ ejbDescriptors.addAll(getServices().get(EjbServices.class).discoverEjbs());
}
- XmlEnvironment xmlEnvironmentImpl = new XmlEnvironment(getServices());
+
+ XmlEnvironment xmlEnvironmentImpl = new XmlEnvironment(getServices(), ejbDescriptors);
XmlParser parser = new XmlParser(xmlEnvironmentImpl);
parser.parse();
+
List<Class<? extends Annotation>> enabledDeploymentTypes = xmlEnvironmentImpl.getEnabledDeploymentTypes();
if (enabledDeploymentTypes.size() > 0)
{
manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
}
log.info("Deployment types: " + manager.getEnabledDeploymentTypes());
- registerBeans(getServices().get(WebBeanDiscovery.class).discoverWebBeanClasses(), xmlEnvironmentImpl.getClasses());
+ registerBeans(getServices().get(WebBeanDiscovery.class).discoverWebBeanClasses(), xmlEnvironmentImpl.getClasses(), ejbDescriptors);
manager.fireEvent(manager, new InitializedLiteral());
log.info("Web Beans initialized. Validating beans.");
manager.getResolver().resolveInjectionPoints();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -17,10 +17,9 @@
package org.jboss.webbeans.ejb;
-import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
@@ -31,22 +30,21 @@
* @author Pete Muir
*
*/
-public class EjbDescriptorCache implements Serializable
+public class EjbDescriptorCache
{
- private static final long serialVersionUID = 1L;
// EJB name -> EJB descriptor map
- private ConcurrentMap<String, InternalEjbDescriptor<?>> ejbsByName;
+ private Map<String, InternalEjbDescriptor<?>> ejbsByName;
// EJB implementation class -> EJB descriptors map
- private ConcurrentMap<Class<?>, Set<InternalEjbDescriptor<?>>> ejbsByBeanClass;
+ private Map<Class<?>, Set<InternalEjbDescriptor<?>>> ejbsByBeanClass;
/**
* Constructor
*/
public EjbDescriptorCache()
{
- this.ejbsByName = new ConcurrentHashMap<String, InternalEjbDescriptor<?>>();
- this.ejbsByBeanClass = new ConcurrentHashMap<Class<?>, Set<InternalEjbDescriptor<?>>>();
+ this.ejbsByName = new HashMap<String, InternalEjbDescriptor<?>>();
+ this.ejbsByBeanClass = new HashMap<Class<?>, Set<InternalEjbDescriptor<?>>>();
}
/**
@@ -81,7 +79,10 @@
{
InternalEjbDescriptor<T> internalEjbDescriptor = new InternalEjbDescriptor<T>(ejbDescriptor);
ejbsByName.put(ejbDescriptor.getEjbName(), internalEjbDescriptor);
- ejbsByBeanClass.putIfAbsent(ejbDescriptor.getType(), new CopyOnWriteArraySet<InternalEjbDescriptor<?>>());
+ if (!ejbsByBeanClass.containsKey(ejbDescriptor.getType()))
+ {
+ ejbsByBeanClass.put(ejbDescriptor.getType(), new CopyOnWriteArraySet<InternalEjbDescriptor<?>>());
+ }
ejbsByBeanClass.get(ejbDescriptor.getType()).add(internalEjbDescriptor);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -5,6 +5,7 @@
import org.jboss.webbeans.RootManager;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.collections.ConcurrentCache;
@@ -27,7 +28,7 @@
public Set<FieldInjectionPoint<?>> call() throws Exception
{
- return Beans.getFieldInjectionPoints(AnnotatedClassImpl.of(instance.getClass()), null);
+ return Beans.getFieldInjectionPoints(manager.getServices().get(ClassTransformer.class).classForName(instance.getClass()), null);
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -23,6 +23,7 @@
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedType;
import org.jboss.webbeans.introspector.AnnotationStore;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Reflections;
/**
@@ -53,14 +54,14 @@
*
* @param annotationMap The annotation map
*/
- public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T> rawType, Type type)
+ public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T> rawType, Type type, ClassTransformer classTransformer)
{
super(annotatedItemHelper, rawType, type);
this.name = rawType.getName();
this._simpleName = rawType.getSimpleName();
if (rawType.getSuperclass() != null)
{
- this.superclass = AnnotatedClassImpl.of(rawType.getSuperclass());
+ this.superclass = classTransformer.classForName(rawType.getSuperclass());
}
else
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -29,6 +29,7 @@
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotationStore;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Strings;
import org.jboss.webbeans.util.collections.ForwardingMap;
@@ -99,9 +100,9 @@
// Cached string representation
private String toString;
- public static <A extends Annotation> AnnotatedAnnotation<A> of(Class<A> annotationType)
+ public static <A extends Annotation> AnnotatedAnnotation<A> of(Class<A> annotationType, ClassTransformer classTransformer)
{
- return new AnnotatedAnnotationImpl<A>(annotationType);
+ return new AnnotatedAnnotationImpl<A>(annotationType, classTransformer);
}
/**
@@ -111,9 +112,9 @@
*
* @param annotationType The annotation type
*/
- public AnnotatedAnnotationImpl(Class<T> annotationType)
+ protected AnnotatedAnnotationImpl(Class<T> annotationType, ClassTransformer classTransformer)
{
- super(AnnotationStore.of(annotationType), annotationType, annotationType);
+ super(AnnotationStore.of(annotationType), annotationType, annotationType, classTransformer);
this.clazz = annotationType;
members = new HashSet<AnnotatedMethod<?>>();
annotatedMembers = new AnnotatedMemberMap();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -37,6 +37,7 @@
import org.jboss.webbeans.introspector.AnnotationStore;
import org.jboss.webbeans.introspector.ConstructorSignature;
import org.jboss.webbeans.introspector.MethodSignature;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;
@@ -262,14 +263,14 @@
private final boolean _enum;
- public static <T> AnnotatedClass<T> of(Class<T> clazz)
+ public static <T> AnnotatedClass<T> of(Class<T> clazz, ClassTransformer classTransformer)
{
- return new AnnotatedClassImpl<T>(clazz, clazz, clazz.getAnnotations(), clazz.getDeclaredAnnotations());
+ return new AnnotatedClassImpl<T>(clazz, clazz, clazz.getAnnotations(), clazz.getDeclaredAnnotations(), classTransformer);
}
- private AnnotatedClassImpl(Class<T> rawType, Type type, Annotation[] annotations, Annotation[] declaredAnnotations)
+ private AnnotatedClassImpl(Class<T> rawType, Type type, Annotation[] annotations, Annotation[] declaredAnnotations, ClassTransformer classTransformer)
{
- super(AnnotationStore.of(annotations, declaredAnnotations), rawType, type);
+ super(AnnotationStore.of(annotations, declaredAnnotations), rawType, type, classTransformer);
this.fields = new HashSet<AnnotatedField<?>>();
this.annotatedFields = new AnnotatedFieldMap();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/AnnotationModel.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -23,6 +23,7 @@
import org.jboss.webbeans.introspector.AnnotatedAnnotation;
import org.jboss.webbeans.introspector.jlr.AnnotatedAnnotationImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
/**
* Abstract representation of an annotation model
@@ -41,9 +42,9 @@
*
* @param type The annotation type
*/
- public AnnotationModel(Class<T> type)
+ public AnnotationModel(Class<T> type, ClassTransformer transformer)
{
- this.annotatedAnnotation = new AnnotatedAnnotationImpl<T>(type);
+ this.annotatedAnnotation = transformer.classForName(type);
init();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/BindingTypeModel.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -27,6 +27,7 @@
import javax.inject.ExecutionException;
import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Reflections;
/**
@@ -46,9 +47,9 @@
*
* @param type The type
*/
- public BindingTypeModel(Class<T> type)
+ public BindingTypeModel(Class<T> type, ClassTransformer transformer)
{
- super(type);
+ super(type, transformer);
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MetaDataCache.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -21,6 +21,7 @@
import java.util.concurrent.Callable;
import org.jboss.webbeans.bootstrap.api.Service;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.collections.ConcurrentCache;
/**
@@ -38,7 +39,14 @@
private ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>> scopes = new ConcurrentCache<Class<? extends Annotation>, ScopeModel<?>>();
// The binding type models
private ConcurrentCache<Class<? extends Annotation>, BindingTypeModel<?>> bindingTypes = new ConcurrentCache<Class<? extends Annotation>, BindingTypeModel<?>>();
+
+ private final ClassTransformer classTransformer;
+ public MetaDataCache(ClassTransformer classTransformer)
+ {
+ this.classTransformer = classTransformer;
+ }
+
/**
* Gets a stereotype model
*
@@ -55,7 +63,7 @@
public StereotypeModel<T> call() throws Exception
{
- return new StereotypeModel<T>(stereotype);
+ return new StereotypeModel<T>(stereotype, classTransformer);
}
});
}
@@ -76,7 +84,7 @@
public ScopeModel<T> call() throws Exception
{
- return new ScopeModel<T>(scopeType);
+ return new ScopeModel<T>(scopeType, classTransformer);
}
});
@@ -98,7 +106,7 @@
public BindingTypeModel<T> call() throws Exception
{
- return new BindingTypeModel<T>(bindingType);
+ return new BindingTypeModel<T>(bindingType, classTransformer);
}
});
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/ScopeModel.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -21,6 +21,8 @@
import javax.context.ScopeType;
+import org.jboss.webbeans.resources.ClassTransformer;
+
/**
*
* Model of a scope
@@ -35,9 +37,9 @@
*
* @param scope The scope type
*/
- public ScopeModel(Class<T> scope)
+ public ScopeModel(Class<T> scope, ClassTransformer classTransformer)
{
- super(scope);
+ super(scope, classTransformer);
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/StereotypeModel.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -30,6 +30,8 @@
import javax.inject.DeploymentType;
import javax.interceptor.InterceptorBindingType;
+import org.jboss.webbeans.resources.ClassTransformer;
+
/**
* A meta model for a stereotype, allows us to cache a stereotype and to
* validate it
@@ -57,9 +59,9 @@
*
* @param sterotype The stereotype
*/
- public StereotypeModel(Class<T> sterotype)
+ public StereotypeModel(Class<T> sterotype, ClassTransformer transformer)
{
- super(sterotype);
+ super(sterotype, transformer);
initDefaultDeploymentType();
initDefaultScopeType();
initBeanNameDefaulted();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -4,6 +4,8 @@
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.DefaultResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.xml.XmlEnvironment;
@@ -17,11 +19,12 @@
{
services = new SimpleServiceRegistry();
services.add(ResourceLoader.class, new DefaultResourceLoader());
+ services.add(ClassTransformer.class, new ClassTransformer());
}
- public MockXmlEnvironment(Iterable<URL> beansXmlUrls)
+ public MockXmlEnvironment(Iterable<URL> beansXmlUrls, EjbDescriptorCache ejbDescriptors)
{
- super(services, beansXmlUrls);
+ super(services, beansXmlUrls, ejbDescriptors);
}
}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.resources;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.webbeans.bootstrap.api.Service;
+import org.jboss.webbeans.introspector.AnnotatedAnnotation;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.jlr.AnnotatedAnnotationImpl;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+
+public class ClassTransformer implements Service
+{
+
+ public <T> AnnotatedClass<T> classForName(Class<T> clazz)
+ {
+ return AnnotatedClassImpl.of(clazz, this);
+ }
+
+ public <T extends Annotation> AnnotatedAnnotation<T> classForName(Class<T> clazz)
+ {
+ return AnnotatedAnnotationImpl.of(clazz, this);
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/ClassTransformer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/resources/DefaultResourceLoader.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -19,6 +19,8 @@
import java.io.IOException;
import java.net.URL;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceLoadingException;
import org.jboss.webbeans.util.EnumerationIterable;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -7,9 +7,11 @@
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedAnnotation;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.spi.ResourceLoader;
public class XmlEnvironment
@@ -20,19 +22,21 @@
private final ServiceRegistry serviceRegistry;
private final List<Class<? extends Annotation>> enabledDeploymentTypes;
private final Iterable<URL> beansXmlUrls;
+ private final EjbDescriptorCache ejbDescriptors;
- public XmlEnvironment(ServiceRegistry serviceRegistry)
+ public XmlEnvironment(ServiceRegistry serviceRegistry, EjbDescriptorCache ejbDescriptors)
{
- this(serviceRegistry, serviceRegistry.get(WebBeanDiscovery.class).discoverWebBeansXml());
+ this(serviceRegistry, serviceRegistry.get(WebBeanDiscovery.class).discoverWebBeansXml(), ejbDescriptors);
}
- protected XmlEnvironment(ServiceRegistry serviceRegistry, Iterable<URL> beanXmlUrls)
+ protected XmlEnvironment(ServiceRegistry serviceRegistry, Iterable<URL> beanXmlUrls, EjbDescriptorCache ejbDescriptors)
{
this.classes = new ArrayList<AnnotatedClass<?>>();
this.annotations = new ArrayList<AnnotatedAnnotation<?>>();
this.enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
this.serviceRegistry = serviceRegistry;
this.beansXmlUrls = beanXmlUrls;
+ this.ejbDescriptors = ejbDescriptors;
}
public List<AnnotatedClass<?>> getClasses()
@@ -52,7 +56,7 @@
public <T> AnnotatedClass<? extends T> loadClass(String className, Class<T> expectedType)
{
- return AnnotatedClassImpl.of(serviceRegistry.get(ResourceLoader.class).classForName(className).asSubclass(expectedType));
+ return serviceRegistry.get(ClassTransformer.class).classForName((serviceRegistry.get(ResourceLoader.class).classForName(className).asSubclass(expectedType)));
}
public <T extends Annotation> Class<? extends T> loadAnnotation(String className, Class<T> expectedType)
@@ -65,6 +69,11 @@
return enabledDeploymentTypes;
}
+ public EjbDescriptorCache getEjbDescriptors()
+ {
+ return ejbDescriptors;
+ }
+
public URL loadFileByUrn(String urn, String fileName)
{
char separator = '/';
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -206,8 +206,8 @@
{
beanElementCheckers.add(new JmsResourceElementChecker(new NotSimpleBeanChildrenChecker(environment, packagesMap)));
beanElementCheckers.add(new ResourceElementChecker(new NotSimpleBeanChildrenChecker(environment, packagesMap)));
- beanElementCheckers.add(new SessionBeanElementChecker(new NotSimpleBeanChildrenChecker(environment, packagesMap)));
- beanElementCheckers.add(new SimpleBeanElementChecker(new SimpleBeanChildrenChecker(environment, packagesMap)));
+ beanElementCheckers.add(new SessionBeanElementChecker(new NotSimpleBeanChildrenChecker(environment, packagesMap), environment.getEjbDescriptors()));
+ beanElementCheckers.add(new SimpleBeanElementChecker(new SimpleBeanChildrenChecker(environment, packagesMap), environment.getEjbDescriptors()));
boolean isValidType = false;
for(BeanElementChecker beanElementChecker : beanElementCheckers)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -3,23 +3,29 @@
import org.dom4j.Element;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.xml.XmlConstants;
import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
public class SessionBeanElementChecker extends NotSimpleBeanElementChecker
{
- public SessionBeanElementChecker(BeanChildrenChecker childrenChecker)
+
+ private final EjbDescriptorCache ejbDescriptors;
+
+ public SessionBeanElementChecker(BeanChildrenChecker childrenChecker, EjbDescriptorCache ejbDescriptors)
{
super(childrenChecker);
+ this.ejbDescriptors = ejbDescriptors;
}
public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
{
- RootManager manager = CurrentManager.rootManager();
- if (manager.getEjbDescriptorCache().containsKey(beanElement.getName()) ||
+ if (ejbDescriptors.containsKey(beanElement.getName()) ||
beanElement.attribute(XmlConstants.EJB_NAME) != null)
+ {
return true;
+ }
return false;
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -7,6 +7,7 @@
import org.dom4j.Element;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.xml.ParseXmlHelper;
import org.jboss.webbeans.xml.XmlConstants;
@@ -15,19 +16,24 @@
public class SimpleBeanElementChecker extends BeanElementCheckerImpl
{
- public SimpleBeanElementChecker(BeanChildrenChecker childrenChecker)
+
+ private final EjbDescriptorCache ejbDescriptors;
+
+ public SimpleBeanElementChecker(BeanChildrenChecker childrenChecker, EjbDescriptorCache ejbDescriptors)
{
super(childrenChecker);
+ this.ejbDescriptors = ejbDescriptors;
}
public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
{
- RootManager manager = CurrentManager.rootManager();
- boolean isSessionBean = manager.getEjbDescriptorCache().containsKey(beanElement.getName()) ||
+ boolean isSessionBean = ejbDescriptors.containsKey(beanElement.getName()) ||
beanElement.attribute(XmlConstants.EJB_NAME) != null;
if (!beanClass.isAbstract() && !isSessionBean && !beanClass.isParameterizedType())
+ {
return true;
+ }
return false;
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/StereotypesTest.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -6,6 +6,7 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.metadata.StereotypeModel;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
import org.testng.annotations.Test;
@@ -13,10 +14,12 @@
public class StereotypesTest extends AbstractWebBeansTest
{
+ private final ClassTransformer transformer = new ClassTransformer();
+
@Test
public void testAnimalStereotype()
{
- StereotypeModel<AnimalStereotype> animalStereotype = new StereotypeModel<AnimalStereotype>(AnimalStereotype.class);
+ StereotypeModel<AnimalStereotype> animalStereotype = new StereotypeModel<AnimalStereotype>(AnimalStereotype.class, transformer);
assert animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
@@ -29,7 +32,7 @@
@Test
public void testAnimalOrderStereotype()
{
- StereotypeModel<AnimalOrderStereotype> animalStereotype = new StereotypeModel<AnimalOrderStereotype>(AnimalOrderStereotype.class);
+ StereotypeModel<AnimalOrderStereotype> animalStereotype = new StereotypeModel<AnimalOrderStereotype>(AnimalOrderStereotype.class, transformer);
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 2;
@@ -43,7 +46,7 @@
@Test
public void testRequestScopedAnimalStereotype()
{
- StereotypeModel<RequestScopedAnimalStereotype> animalStereotype = new StereotypeModel<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class);
+ StereotypeModel<RequestScopedAnimalStereotype> animalStereotype = new StereotypeModel<RequestScopedAnimalStereotype>(RequestScopedAnimalStereotype.class, transformer);
assert animalStereotype.getDefaultScopeType() == null;
assert animalStereotype.getInterceptorBindings().size() == 0;
assert animalStereotype.getRequiredTypes().size() == 1;
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -46,14 +46,6 @@
}
@Test(groups = { "new" })
- public void testNewBeanIsEnterpriseWebBeanIfParameterTypeIsEnterpriseWebBean()
- {
- initNewBean();
- assert wrappedEnterpriseBean.getType().equals(newEnterpriseBean.getType());
- assert manager.getEjbDescriptorCache().containsKey(newEnterpriseBean.getType());
- }
-
- @Test(groups = { "new" })
public void testNewBeanHasSameInitializerMethodsAsWrappedBean()
{
initNewBean();
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/annotatedItem/ClassAnnotatedItemTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/annotatedItem/ClassAnnotatedItemTest.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/annotatedItem/ClassAnnotatedItemTest.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -11,17 +11,20 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
import org.testng.annotations.Test;
@Artifact
public class ClassAnnotatedItemTest extends AbstractWebBeansTest
{
+
+ private final ClassTransformer transformer = new ClassTransformer();
@Test
public void testDeclaredAnnotations()
{
- AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class);
+ AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class, transformer);
assert annotatedElement.getAnnotationsAsSet().size() == 1;
assert annotatedElement.getAnnotation(Production.class) != null;
assert annotatedElement.getRawType().equals(Order.class);
@@ -30,7 +33,7 @@
@Test
public void testMetaAnnotations()
{
- AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class);
+ AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class, transformer);
Set<Annotation> annotations = annotatedElement.getMetaAnnotations(DeploymentType.class);
assert annotations.size() == 1;
Iterator<Annotation> it = annotations.iterator();
@@ -41,10 +44,10 @@
@Test
public void testEmpty()
{
- AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class);
+ AnnotatedClass<Order> annotatedElement = AnnotatedClassImpl.of(Order.class, transformer);
assert annotatedElement.getAnnotation(Stereotype.class) == null;
assert annotatedElement.getMetaAnnotations(Stereotype.class).size() == 0;
- AnnotatedClass<Antelope> classWithNoAnnotations = AnnotatedClassImpl.of(Antelope.class);
+ AnnotatedClass<Antelope> classWithNoAnnotations = AnnotatedClassImpl.of(Antelope.class, transformer);
assert classWithNoAnnotations.getAnnotationsAsSet().size() == 0;
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/deploy/BeansXmlParserTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/deploy/BeansXmlParserTest.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/deploy/BeansXmlParserTest.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -10,6 +10,7 @@
import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.mock.MockResourceLoader;
import org.jboss.webbeans.mock.MockXmlEnvironment;
import org.jboss.webbeans.resources.spi.ResourceLoader;
@@ -28,8 +29,6 @@
public class BeansXmlParserTest extends AbstractWebBeansTest
{
- private static final ResourceLoader RESOURCE_LOADER = new MockResourceLoader();
-
// Quick unit tests for the parser
@Test
public void testDefaultDeploymentTypes()
@@ -43,7 +42,7 @@
it.next();
}
assert i == 1;
- XmlEnvironment environment = new MockXmlEnvironment(urls);
+ XmlEnvironment environment = new MockXmlEnvironment(urls, new EjbDescriptorCache());
XmlParser parser = new XmlParser(environment);
parser.parse();
@@ -56,7 +55,7 @@
public void testUserDefinedDeploymentType()
{
Iterable<URL> urls = getResources("user-defined-beans.xml");
- XmlEnvironment environment = new MockXmlEnvironment(urls);
+ XmlEnvironment environment = new MockXmlEnvironment(urls, new EjbDescriptorCache());
XmlParser parser = new XmlParser(environment);
parser.parse();
assert environment.getEnabledDeploymentTypes().size() == 3;
@@ -72,7 +71,7 @@
public void testDuplicateDeployElement()
{
Iterable<URL> urls = getResources("duplicate-deployments-beans.xml");
- XmlEnvironment environment = new MockXmlEnvironment(urls);
+ XmlEnvironment environment = new MockXmlEnvironment(urls, new EjbDescriptorCache());
XmlParser parser = new XmlParser(environment);
parser.parse();
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java 2009-04-02 21:29:06 UTC (rev 2293)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java 2009-04-03 12:19:31 UTC (rev 2294)
@@ -21,6 +21,7 @@
import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.mock.MockXmlEnvironment;
@@ -44,7 +45,7 @@
//@Test
public void testParse()
{
- XmlEnvironment parserEnv = new MockXmlEnvironment(getResources("beans.xml"));
+ XmlEnvironment parserEnv = new MockXmlEnvironment(getResources("beans.xml"), new EjbDescriptorCache());
AnnotatedClass<?> aClass = parserEnv.loadClass("org.jboss.webbeans.test.unit.xml.beans.Order", Order.class);
Set<URL> xmls = new HashSet<URL>();
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2293 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-04-02 17:29:06 -0400 (Thu, 02 Apr 2009)
New Revision: 2293
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Egg.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/EggProducer.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Goose.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjb.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjbImpl.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleBeanEEInjectionsTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithEjb.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithResources.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Farm.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/beans.xml
Log:
Few more bean lifecycle tests.
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Egg.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Egg.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Egg.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,24 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+
+import javax.annotation.PreDestroy;
+
+public class Egg
+{
+ private static boolean eggDestroyed = false;
+
+ public Egg()
+ {
+ eggDestroyed = false;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ eggDestroyed = true;
+ }
+
+ public static boolean isEggDestroyed()
+ {
+ return eggDestroyed;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Egg.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/EggProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/EggProducer.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/EggProducer.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,26 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+
+import javax.inject.Disposes;
+import javax.inject.Produces;
+
+public class EggProducer
+{
+ private static boolean eggDisposed = false;
+
+ @Produces @Synchronous
+ public Egg nextEgg()
+ {
+ eggDisposed = false;
+ return new Egg();
+ }
+
+ public void disposeEgg(@Disposes @Synchronous Egg egg)
+ {
+ eggDisposed = true;
+ }
+
+ public static boolean isEggDisposed()
+ {
+ return eggDisposed;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/EggProducer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Farm.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Farm.java 2009-04-01 15:04:36 UTC (rev 2292)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Farm.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -12,19 +12,20 @@
public Date founded;
public Date closed;
public int initialStaff;
+ public String location;
@Current
FarmOffice farmOffice;
@PostConstruct
- private void postConstruct()
+ protected void postConstruct()
{
founded = new Date();
initialStaff = farmOffice.noOfStaff;
}
@PreDestroy
- private void preDestroy()
+ protected void preDestroy()
{
closed = new Date();
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Goose.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Goose.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Goose.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+
+
+public class Goose
+{
+ @Synchronous
+ private Egg currentEgg;
+
+ public Egg getCurrentEgg()
+ {
+ return currentEgg;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Goose.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java (from rev 2292, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/MyCreationalContext.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,36 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle;
+
+import javax.context.CreationalContext;
+
+class MyCreationalContext<T> implements CreationalContext<T>
+{
+ private static Object lastBeanPushed = null;
+ private static boolean pushCalled = false;
+
+ public void push(T incompleteInstance)
+ {
+ pushCalled = true;
+ lastBeanPushed = incompleteInstance;
+ }
+
+ public static Object getLastBeanPushed()
+ {
+ return lastBeanPushed;
+ }
+
+ public static void setLastBeanPushed(Object lastBeanPushed)
+ {
+ MyCreationalContext.lastBeanPushed = lastBeanPushed;
+ }
+
+ public static boolean isPushCalled()
+ {
+ return pushCalled;
+ }
+
+ public static void setPushCalled(boolean pushCalled)
+ {
+ MyCreationalContext.pushCalled = pushCalled;
+ }
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-04-01 15:04:36 UTC (rev 2292)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -3,6 +3,9 @@
import java.lang.annotation.Annotation;
import javax.context.Context;
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.context.Dependent;
import javax.context.RequestScoped;
import javax.inject.AnnotationLiteral;
import javax.inject.CreationException;
@@ -73,6 +76,54 @@
@Test(groups = "beanLifecycle")
@SpecAssertions({
+ @SpecAssertion(section = "6.1", id = "b"),
+ @SpecAssertion(section = "6.2", id = "d")
+ })
+ public void testCreateReturnsSameBeanPushed() throws Exception
+ {
+ final CreationalContext<Farm> farmCreationalContext = new MyCreationalContext<Farm>();
+ final Contextual<Farm> farmBean = getCurrentManager().resolveByType(Farm.class).iterator().next();
+ MyCreationalContext.setLastBeanPushed(null);
+ MyCreationalContext.setPushCalled(false);
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ Farm farmInstance = getCurrentManager().getContext(Dependent.class).get(farmBean, farmCreationalContext);
+ if (MyCreationalContext.isPushCalled())
+ {
+ assert farmInstance.equals(MyCreationalContext.getLastBeanPushed());
+ }
+ assert farmInstance.farmOffice != null : "FarmOffice should be injected by Contextual.create()";
+ }
+
+ }.run();
+ }
+
+ @Test(groups = { "ri-broken", "beanLifecycle" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.2", id = "e")
+ })
+ public void testCreateSetsInitialValuesFromXml() throws Exception
+ {
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ Farm farmInstance = getCurrentManager().getInstanceByType(Farm.class);
+ assert farmInstance.location != null;
+ assert farmInstance.location.equals("Indiana");
+ }
+
+ }.run();
+ }
+
+ @Test(groups = "beanLifecycle")
+ @SpecAssertions({
@SpecAssertion(section = "6.2", id = "a"),
@SpecAssertion(section="2", id="g"),
@SpecAssertion(section="2.2", id="f"),
@@ -99,27 +150,6 @@
assert false;
}
- @Test(groups = { "stub", "beanLifecycle", "commonAnnotations", "integration" })
- @SpecAssertion(section = "6.4", id = "b")
- public void testCreateInjectsEjb()
- {
- assert false;
- }
-
- @Test(groups = { "stub", "beanLifecycle", "commonAnnotations", "integration" })
- @SpecAssertion(section = "6.4", id = "c")
- public void testCreateInjectsPersistenceContext()
- {
- assert false;
- }
-
- @Test(groups = { "stub", "beanLifecycle", "commonAnnotations", "integration" })
- @SpecAssertion(section = "6.4", id = "d")
- public void testCreateInjectsResource()
- {
- assert false;
- }
-
@Test(groups = "injection")
@SpecAssertions({
@SpecAssertion(section = "6.4", id = "e"),
@@ -164,6 +194,24 @@
assert farm.closed != null;
}
+ @Test(groups = { "ri-broken", "beanLifecycle", "lifecycleCallbacks" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.3", id = "a"),
+ @SpecAssertion(section = "6.3", id = "c")
+ })
+ public void testContextualDestroyDisposesWhenNecessary() throws Exception
+ {
+ final Contextual<Goose> gooseBean = getCurrentManager().resolveByType(Goose.class).iterator().next();
+ final Goose goose = getCurrentManager().getInstanceByType(Goose.class);
+
+ assert !EggProducer.isEggDisposed();
+ assert !Egg.isEggDestroyed();
+ gooseBean.destroy(goose);
+ assert EggProducer.isEggDisposed();
+ //TODO Apparently Dependent scoped injected objects do not have their PreDestroy method called
+ assert Egg.isEggDestroyed();
+ }
+
@Test
@SpecAssertion(section = "4.2", id = "baa")
public void testSubClassInheritsPostConstructOnSuperclass() throws Exception
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjb.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjb.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjb.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle.ic;
+
+import javax.ejb.Local;
+
+@Local
+public interface MyEjb
+{
+ public void hello();
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjb.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjbImpl.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjbImpl.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjbImpl.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle.ic;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class MyEjbImpl implements MyEjb
+{
+
+ public void hello()
+ {
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/MyEjbImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleBeanEEInjectionsTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleBeanEEInjectionsTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleBeanEEInjectionsTest.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,40 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle.ic;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+@Artifact
+(a)Packaging(PackagingType.EAR)
+@IntegrationTest
+public class SimpleBeanEEInjectionsTest extends AbstractJSR299Test
+{
+ @Test(groups = { "stub", "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertion(section = "6.4", id = "b")
+ public void testCreateInjectsEjb()
+ {
+ SimpleWithEjb bean = getCurrentManager().getInstanceByType(SimpleWithEjb.class);
+ assert bean.isEjbInjected();
+ }
+
+ @Test(groups = { "stub", "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertion(section = "6.4", id = "c")
+ public void testCreateInjectsPersistenceContext()
+ {
+ assert false;
+ }
+
+ @Test(groups = { "broken", "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertion(section = "6.4", id = "d")
+ public void testCreateInjectsResource()
+ {
+ //TODO Spec defines resources for EJBs, not simple beans
+ SimpleWithResources bean = getCurrentManager().getInstanceByType(SimpleWithResources.class);
+ assert bean.getMyResourceId() == 42;
+ assert "SimpleResource".equals(bean.getMyResourceName());
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleBeanEEInjectionsTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithEjb.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithEjb.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithEjb.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle.ic;
+
+import javax.ejb.EJB;
+
+public class SimpleWithEjb
+{
+ @EJB
+ private MyEjb myEjb;
+
+ public boolean isEjbInjected()
+ {
+ return myEjb != null;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithEjb.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithResources.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithResources.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithResources.java 2009-04-02 21:29:06 UTC (rev 2293)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.lifecycle.ic;
+
+import javax.annotation.Resource;
+
+public class SimpleWithResources
+{
+ @Resource
+ private int myResourceId;
+
+ @Resource
+ private String myResourceName;
+
+ public int getMyResourceId()
+ {
+ return myResourceId;
+ }
+
+ public String getMyResourceName()
+ {
+ return myResourceName;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/SimpleWithResources.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/beans.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/beans.xml 2009-04-01 15:04:36 UTC (rev 2292)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/beans.xml 2009-04-02 21:29:06 UTC (rev 2293)
@@ -5,4 +5,7 @@
<Production />
<test:AnotherDeploymentType />
</Deploy>
+ <test:Farm>
+ <test:location>Indiana</test:location>
+ </test:Farm>
</Beans>
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2292 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-04-01 11:04:36 -0400 (Wed, 01 Apr 2009)
New Revision: 2292
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java
Log:
A couple producer method tests now working.
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-04-01 14:07:15 UTC (rev 2291)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java 2009-04-01 15:04:36 UTC (rev 2292)
@@ -19,7 +19,7 @@
public class ProducerMethodLifecycleTest extends AbstractJSR299Test
{
- @Test(groups = { "producerMethod", "disposalMethod", "ri-broken" })
+ @Test(groups = { "producerMethod", "disposalMethod" })
@SpecAssertions({
@SpecAssertion(section = "6", id = "f")
})
@@ -41,5 +41,23 @@
}.run();
}
+ @Test(groups = { "producerMethod" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6", id = "b")
+ })
+ public void testProducerMethodBeanCreate() throws Exception
+ {
+ new RunInDependentContext()
+ {
+ @Override
+ protected void execute() throws Exception
+ {
+ getCurrentManager().getInstanceByType(Tarantula.class);
+ assert SpiderProducer.isTarantulaCreated();
+ }
+
+ }.run();
+ }
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java 2009-04-01 14:07:15 UTC (rev 2291)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java 2009-04-01 15:04:36 UTC (rev 2292)
@@ -6,10 +6,12 @@
@AnotherDeploymentType
class SpiderProducer
{
+ private static boolean tarantulaCreated;
private static boolean tarantulaDestroyed;
@Produces public Tarantula produceTarantula()
{
+ tarantulaCreated = true;
return new Tarantula("Pete");
}
@@ -23,11 +25,21 @@
tarantulaDestroyed = true;
}
+ public static boolean isTarantulaCreated()
+ {
+ return tarantulaCreated;
+ }
+
public static boolean isTarantulaDestroyed()
{
return tarantulaDestroyed;
}
+ public static void setTarantulaCreated(boolean tarantulaCreated)
+ {
+ SpiderProducer.tarantulaCreated = tarantulaCreated;
+ }
+
public static void setTarantulaDestroyed(boolean tarantulaDestroyed)
{
SpiderProducer.tarantulaDestroyed = tarantulaDestroyed;
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2291 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request: ejb and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-04-01 10:07:15 -0400 (Wed, 01 Apr 2009)
New Revision: 2291
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java
Log:
A couple more contexts tests to push the total over 75%.
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java 2009-04-01 11:57:18 UTC (rev 2290)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java 2009-04-01 14:07:15 UTC (rev 2291)
@@ -114,18 +114,6 @@
* to any EJB message driven bean.
*/
@Test(groups = { "stub", "contexts", "ejb3", "integration" })
- @SpecAssertion(section = "8.5.1", id = "i")
- public void testRequestScopeActiveDuringCallToEjbTimeoutMethod()
- {
- assert false;
- }
-
- /**
- * The request scope is active during any remote method invocation of any EJB
- * bean, during any call to an EJB timeout method and during message delivery
- * to any EJB message driven bean.
- */
- @Test(groups = { "stub", "contexts", "ejb3", "integration" })
@SpecAssertion(section = "8.5.1", id = "j")
public void testRequestScopeActiveDuringEjbMessageDelivery()
{
@@ -148,17 +136,6 @@
* timeout or message delivery completes.
*/
@Test(groups = { "stub", "contexts", "ejb3", "integration" })
- @SpecAssertion(section = "8.5.1", id = "l")
- public void testRequestScopeDestroyedAfterCallToEjbTimeoutMethod()
- {
- assert false;
- }
-
- /**
- * The request context is destroyed after the remote method invocation,
- * timeout or message delivery completes.
- */
- @Test(groups = { "stub", "contexts", "ejb3", "integration" })
@SpecAssertion(section = "8.5.1", id = "m")
public void testRequestScopeDestroyedAfterEjbMessageDelivery()
{
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java 2009-04-01 14:07:15 UTC (rev 2291)
@@ -0,0 +1,54 @@
+package org.jboss.jsr299.tck.tests.context.request.ejb;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+/**
+ * EJB and related tests with the built-in request context.
+ *
+ * @author David Allen
+ *
+ * Spec version: PRD2
+ */
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.EAR)
+public class EJBRequestContextTest extends AbstractJSR299Test
+{
+ /**
+ * The request scope is active during any remote method invocation of any EJB
+ * bean, during any call to an EJB timeout method and during message delivery
+ * to any EJB message driven bean.
+ */
+ @Test(groups = { "ri-broken", "contexts", "ejb3", "integration" })
+ @SpecAssertion(section = "8.5.1", id = "i")
+ public void testRequestScopeActiveDuringCallToEjbTimeoutMethod() throws Exception
+ {
+ FMS flightManagementSystem = getCurrentManager().getInstanceByType(FMS.class);
+ flightManagementSystem.climb();
+ Thread.sleep(250);
+ assert flightManagementSystem.isRequestScopeActive();
+ }
+
+ /**
+ * The request context is destroyed after the remote method invocation,
+ * timeout or message delivery completes.
+ */
+ @Test(groups = { "ri-broken", "contexts", "ejb3", "integration" })
+ @SpecAssertion(section = "8.5.1", id = "l")
+ public void testRequestScopeDestroyedAfterCallToEjbTimeoutMethod() throws Exception
+ {
+ FMS flightManagementSystem = getCurrentManager().getInstanceByType(FMS.class);
+ flightManagementSystem.climb();
+ flightManagementSystem.descend();
+ Thread.sleep(250);
+ assert !flightManagementSystem.isSameBean();
+ assert SimpleRequestBean.isBeanDestroyed();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMS.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java 2009-04-01 14:07:15 UTC (rev 2291)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.context.request.ejb;
+
+import javax.ejb.Local;
+
+@Local
+public interface FMS
+{
+ public void turnLeft();
+
+ public void turnRight();
+
+ public void climb();
+
+ public void descend();
+
+ public boolean isRequestScopeActive();
+
+ public void setRequestScopeActive(boolean requestScopeActive);
+
+ public boolean isSameBean();
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java 2009-04-01 14:07:15 UTC (rev 2291)
@@ -0,0 +1,82 @@
+package org.jboss.jsr299.tck.tests.context.request.ejb;
+
+import javax.annotation.Resource;
+import javax.context.RequestScoped;
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+
+@Stateless
+public class FMSModelIII implements FMS
+{
+ private static final long serialVersionUID = 1L;
+
+ @Resource
+ private TimerService timerService;
+
+ @Current
+ private Manager manager;
+
+ private static boolean requestScopeActive = false;
+ private static double beanId = 0.0d;
+ private static boolean sameBean = false;
+
+ public void climb()
+ {
+ timerService.createTimer(200, "Climb command timeout");
+ }
+
+ public void descend()
+ {
+ timerService.createTimer(100, "Descend command timeout");
+ beanId = 0.0d;
+ sameBean = false;
+ }
+
+ public void turnLeft()
+ {
+ }
+
+ public void turnRight()
+ {
+ }
+
+ @Timeout
+ public void timeout(Timer timer)
+ {
+ if (manager.getContext(RequestScoped.class).isActive())
+ {
+ requestScopeActive = true;
+ if (beanId > 0.0)
+ {
+ if (beanId == manager.getInstanceByType(SimpleRequestBean.class).getId())
+ {
+ sameBean = true;
+ }
+ }
+ else
+ {
+ beanId = manager.getInstanceByType(SimpleRequestBean.class).getId();
+ }
+ }
+ }
+
+ public boolean isRequestScopeActive()
+ {
+ return requestScopeActive;
+ }
+
+ public void setRequestScopeActive(boolean requestScopeActive)
+ {
+ FMSModelIII.requestScopeActive = requestScopeActive;
+ }
+
+ public boolean isSameBean()
+ {
+ return sameBean;
+ }
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/SimpleApplicationBean.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java 2009-04-01 14:07:15 UTC (rev 2291)
@@ -0,0 +1,32 @@
+package org.jboss.jsr299.tck.tests.context.request.ejb;
+
+import javax.annotation.PreDestroy;
+import javax.context.RequestScoped;
+
+@RequestScoped
+class SimpleRequestBean
+{
+ private double id = Math.random();
+ private static boolean beanDestroyed = false;
+
+ public double getId()
+ {
+ return id;
+ }
+
+ @PreDestroy
+ public void destroy()
+ {
+ beanDestroyed = true;
+ }
+
+ public static boolean isBeanDestroyed()
+ {
+ return beanDestroyed;
+ }
+
+ public static void setBeanDestroyed(boolean beanDestroyed)
+ {
+ SimpleRequestBean.beanDestroyed = beanDestroyed;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/SimpleRequestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2290 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/context/application/standalone and 4 other directories.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-04-01 07:57:18 -0400 (Wed, 01 Apr 2009)
New Revision: 2290
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/FilterTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ServiceMethodServlet.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/NearMiss.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TargetEvent.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TcasDisplay.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/SimplePage.html
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/web.xml
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java
Log:
A few more context tests for request scope
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java 2009-03-31 23:29:11 UTC (rev 2289)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -66,11 +66,11 @@
{
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
- TextPage firstRequestResult = webClient.getPage(getContextPath() + "IntrospectApplication");
+ TextPage firstRequestResult = webClient.getPage(getContextPath() + "IntrospectRequestScope");
assert firstRequestResult.getContent() != null;
assert Double.parseDouble(firstRequestResult.getContent()) != 0;
// Make a second request and make sure the same context is used
- TextPage secondRequestResult = webClient.getPage(getContextPath() + "IntrospectApplication");
+ TextPage secondRequestResult = webClient.getPage(getContextPath() + "IntrospectRequestScope");
assert secondRequestResult.getContent() != null;
assert Double.parseDouble(secondRequestResult.getContent()) == Double.parseDouble(firstRequestResult.getContent());
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java 2009-03-31 23:29:11 UTC (rev 2289)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -3,30 +3,33 @@
class NearMiss
{
private SimpleApplicationBean bean;
- private boolean sameBean = false;
+ private boolean sameBean = false;
public SimpleApplicationBean getBean()
{
return bean;
}
+
public void setBean(SimpleApplicationBean bean)
{
if (this.bean == null)
{
- this.bean = bean;
+ this.bean = bean;
}
else
{
sameBean = this.bean.getId() == bean.getId();
}
}
+
public boolean isSameBean()
{
return sameBean;
}
+
public void setSameBean(boolean sameBean)
{
this.sameBean = sameBean;
}
-
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java 2009-03-31 23:29:11 UTC (rev 2289)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -19,6 +19,10 @@
{
applicationScopeActive = true;
}
+ else
+ {
+ applicationScopeActive = false;
+ }
}
public void drawNearMiss(@Observes @Asynchronously NearMiss event)
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/FilterTest.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/FilterTest.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/FilterTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/FilterTest.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,55 @@
+package org.jboss.jsr299.tck.tests.context.request;
+
+import java.io.IOException;
+
+import javax.context.ApplicationScoped;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class FilterTest implements Filter
+{
+ @Current
+ private Manager jsr299Manager;
+
+ public void destroy()
+ {
+ jsr299Manager = null;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+ if (!jsr299Manager.getContext(ApplicationScoped.class).isActive())
+ {
+ throw new ServletException("Application context is not active");
+ }
+ else
+ {
+ chain.doFilter(request, response);
+ }
+ }
+
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ //TODO Remove init code once injection works in servlet container
+ try
+ {
+ if (jsr299Manager == null)
+ {
+ InitialContext ic = new InitialContext();
+ jsr299Manager = (Manager) ic.lookup("java:app/Manager");
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Error looking up manager", e);
+ }
+ }
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/IntrospectApplication.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,50 @@
+package org.jboss.jsr299.tck.tests.context.request;
+
+import java.io.IOException;
+
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class IntrospectRequestScope extends HttpServlet
+{
+ private static final long serialVersionUID = 1L;
+
+ @Current
+ private Manager jsr299Manager;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ resp.setContentType("text/text");
+ SimpleRequestBean aBean = jsr299Manager.getInstanceByType(SimpleRequestBean.class);
+ resp.getWriter().print(aBean.getId());
+ }
+
+ @Override
+ public void init() throws ServletException
+ {
+ //TODO Remove init code once injection works in servlet container
+ try
+ {
+ InitialContext ic = new InitialContext();
+ jsr299Manager = (Manager) ic.lookup("java:app/Manager");
+ }
+ catch (NamingException e)
+ {
+ throw new ServletException("Error looking up manager", e);
+ }
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ init();
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/IntrospectRequestScope.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java 2009-03-31 23:29:11 UTC (rev 2289)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/RequestContextTest.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -4,14 +4,24 @@
import org.jboss.jsr299.tck.AbstractJSR299Test;
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;
+import com.gargoylesoftware.htmlunit.TextPage;
+import com.gargoylesoftware.htmlunit.WebClient;
+
/**
*
* Spec version: PRD2
*/
@Artifact
-@IntegrationTest
+@IntegrationTest(runLocally=true)
+@Resources({
+ @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION, source="web.xml"),
+ @Resource(destination="SimplePage.html", source="SimplePage.html")
+})
public class RequestContextTest extends AbstractJSR299Test
{
@@ -19,34 +29,50 @@
* The request scope is active during the service() method of any Servlet in
* the web application.
*/
- @Test(groups = { "stub", "contexts", "servlet", "integration" })
+ @Test(groups = { "contexts", "servlet", "integration" })
@SpecAssertion(section = "8.5.1", id = "a")
- public void testRequestScopeActiveDuringServiceMethod()
+ public void testRequestScopeActiveDuringServiceMethod() throws Exception
{
- assert false;
+ WebClient webClient = new WebClient();
+ webClient.setThrowExceptionOnFailingStatusCode(true);
+ webClient.getPage(getContextPath() + "serviceMethodTest");
}
-
/**
* The request scope is active during the doFilter() method of any Servlet in
* the web application.
*/
- @Test(groups = { "stub", "contexts", "servlet", "integration" })
+ @Test(groups = { "contexts", "servlet", "integration" })
@SpecAssertion(section = "8.5.1", id = "b")
- public void testRequestScopeActiveDuringServletFilter()
+ public void testRequestScopeActiveDuringServletFilter() throws Exception
{
- assert false;
+ WebClient webClient = new WebClient();
+ webClient.setThrowExceptionOnFailingStatusCode(true);
+ webClient.getPage(getContextPath() + "SimplePage.html");
}
/**
* The request context is destroyed at the end of the servlet request, after
* the Servlet service() method returns.
*/
- @Test(groups = { "stub", "contexts", "servlet", "integration" })
+ @Test(groups = { "contexts", "servlet", "integration" })
@SpecAssertion(section = "8.5.1", id = "c")
- public void testRequestScopeIsDestroyedAfterServiceMethod()
+ public void testRequestScopeIsDestroyedAfterServletRequest() throws Exception
{
- assert false;
+ WebClient webClient = new WebClient();
+ webClient.setThrowExceptionOnFailingStatusCode(true);
+ TextPage firstRequestResult = webClient.getPage(getContextPath() + "IntrospectRequest");
+ assert firstRequestResult.getContent() != null;
+ assert Double.parseDouble(firstRequestResult.getContent()) != 0;
+ // Make a second request and make sure the same context is not there
+ TextPage secondRequestResult = webClient.getPage(getContextPath() + "IntrospectRequest");
+ assert secondRequestResult.getContent() != null;
+ assert Double.parseDouble(secondRequestResult.getContent()) != Double.parseDouble(firstRequestResult.getContent());
+
+ // As final confirmation that the context was destroyed, check that its beans
+ // were also destroyed.
+// TextPage beanDestructionResult = webClient.getPage(getContextPath() + "InvalidateSession?isBeanDestroyed");
+// assert Boolean.parseBoolean(beanDestructionResult.getContent());
}
/**
@@ -71,27 +97,6 @@
}
/**
- * The request scope is active during any asynchronous observer method notification
- */
- @Test(groups = { "stub", "contexts", "integration" })
- @SpecAssertion(section = "8.5.1", id = "f")
- public void testRequestScopeIsActiveDuringAsynchronousObserverMethodInvocation()
- {
- assert false;
- }
-
- /**
- * The request context is destroyed after the web service invocation
- * completes
- */
- @Test(groups = { "stub", "contexts", "integration" })
- @SpecAssertion(section = "8.5.1", id = "g")
- public void testRequestScopeIsDestroyedAfterAsynchronousObserverMethodInvocation()
- {
- assert false;
- }
-
- /**
* The request scope is active during any remote method invocation of any EJB
* bean, during any call to an EJB timeout method and during message delivery
* to any EJB message driven bean.
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ServiceMethodServlet.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ServiceMethodServlet.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ServiceMethodServlet.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ServiceMethodServlet.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,87 @@
+/*
+ * 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.context.request;
+
+import java.io.IOException;
+
+import javax.context.ApplicationScoped;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Servlet used just to test context during service method.
+ *
+ * @author David Allen
+ *
+ */
+public class ServiceMethodServlet extends HttpServlet
+{
+
+ private static final long serialVersionUID = 1L;
+
+ @Current
+ private Manager jsr299Manager;
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ if (!jsr299Manager.getContext(ApplicationScoped.class).isActive())
+ {
+ throw new ServletException("Application context is not active");
+ }
+ else
+ {
+ super.service(req, resp);
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ resp.setContentType("text/text");
+ resp.getWriter().println("It worked!");
+ }
+
+ @Override
+ public void init() throws ServletException
+ {
+ //TODO Remove init code once injection works in servlet container
+ try
+ {
+ InitialContext ic = new InitialContext();
+ jsr299Manager = (Manager) ic.lookup("java:app/Manager");
+ }
+ catch (NamingException e)
+ {
+ throw new ServletException("Error looking up manager", e);
+ }
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ init();
+ }
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.context.request;
+
+import javax.context.RequestScoped;
+
+@RequestScoped
+public class SimpleRequestBean
+{
+ private double id = Math.random();
+
+ public double getId()
+ {
+ return id;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/SimpleRequestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/NearMiss.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/NearMiss.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/NearMiss.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/NearMiss.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,35 @@
+package org.jboss.jsr299.tck.tests.context.request.standalone;
+
+class NearMiss
+{
+ private SimpleRequestBean bean;
+ private boolean sameBean = false;
+
+ public SimpleRequestBean getBean()
+ {
+ return bean;
+ }
+
+ public void setBean(SimpleRequestBean bean)
+ {
+ if (this.bean == null)
+ {
+ this.bean = bean;
+ }
+ else
+ {
+ sameBean = this.bean.getId() == bean.getId();
+ }
+ }
+
+ public boolean isSameBean()
+ {
+ return sameBean;
+ }
+
+ public void setSameBean(boolean sameBean)
+ {
+ this.sameBean = sameBean;
+ }
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/ApplicationContextTest.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,62 @@
+/*
+ * 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.context.request.standalone;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+/**
+ * @author David Allen
+ *
+ * Spec version: PRD2
+ *
+ */
+@Artifact
+public class RequestContextTest extends AbstractJSR299Test
+{
+ /**
+ * The request scope is active during any asynchronous observer method notification
+ */
+ @Test(groups = { "ri-broken", "contexts", "integration" })
+ @SpecAssertion(section = "8.5.1", id = "f")
+ public void testRequestScopeIsActiveDuringAsynchronousObserverMethodInvocation() throws Exception
+ {
+ getCurrentManager().fireEvent(new TargetEvent());
+ Thread.sleep(200);
+ assert TcasDisplay.isRequestScopeActive();
+ }
+
+ /**
+ * The request context is destroyed after the asynchronous observer method notification
+ * completes
+ */
+ @Test(groups = { "contexts", "integration" })
+ @SpecAssertion(section = "8.5.1", id = "g")
+ public void testRequestScopeIsDestroyedAfterAsynchronousObserverMethodInvocation() throws Exception
+ {
+ NearMiss event = new NearMiss();
+ getCurrentManager().fireEvent(event);
+ Thread.sleep(200);
+ getCurrentManager().fireEvent(event);
+ Thread.sleep(200);
+ assert !event.isSameBean();
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/RequestContextTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/SimpleApplicationBean.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.context.request.standalone;
+
+import javax.context.RequestScoped;
+
+@RequestScoped
+class SimpleRequestBean
+{
+ private double id = Math.random();
+
+ public double getId()
+ {
+ return id;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/SimpleRequestBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TargetEvent.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TargetEvent.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TargetEvent.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TargetEvent.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.context.request.standalone;
+
+class TargetEvent
+{
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TcasDisplay.java (from rev 2289, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/standalone/TcasDisplay.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TcasDisplay.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/standalone/TcasDisplay.java 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,42 @@
+package org.jboss.jsr299.tck.tests.context.request.standalone;
+
+import javax.context.RequestScoped;
+import javax.event.Asynchronously;
+import javax.event.Observes;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
+
+class TcasDisplay
+{
+ @Current
+ private Manager manager;
+
+ private static boolean requestScopeActive = false;
+
+ public void drawTarget(@Observes @Asynchronously TargetEvent targetEvent)
+ {
+ if (manager.getContext(RequestScoped.class).isActive())
+ {
+ requestScopeActive = true;
+ }
+ else
+ {
+ requestScopeActive = false;
+ }
+ }
+
+ public void drawNearMiss(@Observes @Asynchronously NearMiss event)
+ {
+ event.setBean(manager.getInstanceByType(SimpleRequestBean.class));
+ }
+
+ public static boolean isRequestScopeActive()
+ {
+ return requestScopeActive;
+ }
+
+ public static void setRequestScopeActive(boolean requestScopeActive)
+ {
+ TcasDisplay.requestScopeActive = requestScopeActive;
+ }
+}
Copied: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/SimplePage.html (from rev 2289, tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/session/SimplePage.html)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/SimplePage.html (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/SimplePage.html 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,11 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
+<head>
+</head>
+
+<body>
+</body>
+
+</html>
Copied: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/web.xml (from rev 2289, tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/session/web.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/web.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/request/web.xml 2009-04-01 11:57:18 UTC (rev 2290)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <description>Test servlets used to test session contexts.</description>
+ <display-name>Session Context Tests</display-name>
+ <filter>
+ <display-name>Test Filter for Sessions</display-name>
+ <filter-name>filterTest</filter-name>
+ <filter-class>org.jboss.jsr299.tck.tests.context.request.FilterTest</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>filterTest</filter-name>
+ <url-pattern>/SimplePage.html</url-pattern>
+ </filter-mapping>
+ <listener>
+ <listener-class>org.jboss.testharness.impl.runner.servlet.HarnessServletListener</listener-class>
+ </listener>
+ <servlet>
+ <display-name>serviceMethod</display-name>
+ <servlet-name>service</servlet-name>
+ <servlet-class>org.jboss.jsr299.tck.tests.context.request.ServiceMethodServlet</servlet-class>
+ </servlet>
+ <servlet>
+ <display-name>Introspection Service for Request Context</display-name>
+ <servlet-name>requestIntrospector</servlet-name>
+ <servlet-class>org.jboss.jsr299.tck.tests.context.request.IntrospectRequestScope</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>service</servlet-name>
+ <url-pattern>/serviceMethodTest</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>requestIntrospector</servlet-name>
+ <url-pattern>/IntrospectRequest</url-pattern>
+ </servlet-mapping>
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
15 years, 7 months