Author: pete.muir(a)jboss.org
Date: 2009-03-05 11:51:38 -0500 (Thu, 05 Mar 2009)
New Revision: 1773
Added:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/manager/
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/manager/api/
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ServletInjector.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Barn.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Farm.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/FarmLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Hamlet.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/HamletLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Village.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/VillageLocal.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/nonContextual/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/nonContextual/beans.xml
Modified:
ri/trunk/webbeans-ri-spi/pom.xml
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/packaging/ear/EarArtifactDescriptor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/NonContextualInjectionTest.java
Log:
WBRI-119, WBRI-55
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-05
13:56:44 UTC (rev 1772)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -56,6 +56,7 @@
import javax.inject.manager.InterceptionType;
import javax.inject.manager.Interceptor;
import javax.inject.manager.Manager;
+import javax.servlet.Servlet;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.NewEnterpriseBean;
@@ -69,10 +70,13 @@
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injection.ResolvableAnnotatedClass;
import org.jboss.webbeans.injection.Resolver;
+import org.jboss.webbeans.injection.ServletInjector;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.literal.NewLiteral;
+import org.jboss.webbeans.manager.api.WebBeansManager;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
@@ -89,8 +93,10 @@
* @author Pete Muir
*
*/
-public class ManagerImpl implements Manager, Serializable
+public class ManagerImpl implements WebBeansManager, Serializable
{
+
+ private static final Annotation[] NEW_BINDING_ARRAY = {new NewLiteral()};
private static final long serialVersionUID = 3021562879133838561L;
@@ -139,6 +145,8 @@
private transient final NamingContext namingContext;
private final transient Map<Bean<?>, Bean<?>> specializedBeans;
+
+ private final transient ServletInjector servletInjector;
/**
* Create a new manager
@@ -163,6 +171,7 @@
this.ejbDescriptorCache = new EjbDescriptorCache();
this.currentInjectionPoint = new ThreadLocal<InjectionPoint>();
this.specializedBeans = new HashMap<Bean<?>, Bean<?>>();
+ this.servletInjector = new ServletInjector(this);
List<Class<? extends Annotation>> defaultEnabledDeploymentTypes = new
ArrayList<Class<? extends Annotation>>();
defaultEnabledDeploymentTypes.add(0, Standard.class);
defaultEnabledDeploymentTypes.add(1, Production.class);
@@ -624,6 +633,11 @@
return this.<T>getInstanceToInject(injectionPoint, null);
}
+ public void injectIntoServlet(Servlet servlet)
+ {
+ servletInjector.inject(servlet);
+ }
+
@SuppressWarnings("unchecked")
public <T> T getInstanceToInject(InjectionPoint injectionPoint,
CreationalContext<?> creationalContext)
{
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-03-05
13:56:44 UTC (rev 1772)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -25,7 +25,6 @@
import javax.context.Dependent;
import javax.context.ScopeType;
import javax.event.Observes;
-import javax.inject.BindingType;
import javax.inject.CreationException;
import javax.inject.DefinitionException;
import javax.inject.DeploymentType;
@@ -39,11 +38,11 @@
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.AnnotatedClass;
-import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;
@@ -130,24 +129,8 @@
*/
protected void initInjectionPoints()
{
- injectableFields = new HashSet<FieldInjectionPoint<?>>();
- for (AnnotatedField<?> annotatedField :
annotatedItem.getMetaAnnotatedFields(BindingType.class))
- {
- if (!annotatedField.isAnnotationPresent(Produces.class))
- {
- if (annotatedField.isStatic())
- {
- throw new DefinitionException("Don't place binding annotations on
static fields " + annotatedField);
- }
- if (annotatedField.isFinal())
- {
- throw new DefinitionException("Don't place binding annotations on
final fields " + annotatedField);
- }
- FieldInjectionPoint<?> fieldInjectionPoint =
FieldInjectionPoint.of(this, annotatedField);
- injectableFields.add(fieldInjectionPoint);
- super.injectionPoints.add(fieldInjectionPoint);
- }
- }
+ injectableFields = new
HashSet<FieldInjectionPoint<?>>(Beans.getFieldInjectionPoints(annotatedItem,
this));
+ super.injectionPoints.addAll(injectableFields);
for (AnnotatedMethod<?> initializer : getInitializerMethods())
{
for (AnnotatedParameter<?> parameter : initializer.getParameters())
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java 2009-03-05
13:56:44 UTC (rev 1772)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -1,6 +1,9 @@
package org.jboss.webbeans.injection;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
@@ -35,6 +38,22 @@
return new ResolvableAnnotatedClass<T>(clazz, clazz, annotations);
}
+ public static <T> ResolvableAnnotatedClass<T> of(Member member,
Annotation[] annotations)
+ {
+ if (member instanceof Field)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>) ((Field)
member).getType(), ((Field) member).getGenericType(), annotations);
+ }
+ else if (member instanceof Method)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>) ((Method)
member).getReturnType(), ((Method) member).getGenericReturnType(), annotations);
+ }
+ else
+ {
+ throw new IllegalStateException();
+ }
+ }
+
private ResolvableAnnotatedClass(Class<T> rawType, Type type, Annotation[]
annotations)
{
super(AnnotationStore.of(annotations, EMPTY_ANNOTATION_ARRAY));
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ServletInjector.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ServletInjector.java
(rev 0)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ServletInjector.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,43 @@
+package org.jboss.webbeans.injection;
+
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import javax.servlet.Servlet;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.ConcurrentCache;
+
+public class ServletInjector
+{
+
+ private final ConcurrentCache<Class<?>,
Set<FieldInjectionPoint<?>>> servlets;
+ private final ManagerImpl manager;
+
+ public ServletInjector(ManagerImpl manager)
+ {
+ this.manager = manager;
+ this.servlets = new ConcurrentCache<Class<?>,
Set<FieldInjectionPoint<?>>>();
+ }
+
+ public void inject(final Servlet instance)
+ {
+ Set<FieldInjectionPoint<?>> injectionPoints =
servlets.putIfAbsent(instance.getClass(), new
Callable<Set<FieldInjectionPoint<?>>>()
+ {
+
+ public Set<FieldInjectionPoint<?>> call() throws Exception
+ {
+ return
Beans.getFieldInjectionPoints(AnnotatedClassImpl.of(instance.getClass()), null);
+ }
+
+ }
+ );
+ for (FieldInjectionPoint<?> injectionPoint : injectionPoints)
+ {
+ injectionPoint.inject(instance, manager, null);
+ }
+ }
+
+}
Property changes on:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/ServletInjector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-03-05
13:56:44 UTC (rev 1772)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/Beans.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -17,12 +17,19 @@
package org.jboss.webbeans.util;
import java.lang.reflect.Type;
+import java.util.HashSet;
import java.util.Set;
+import javax.inject.BindingType;
+import javax.inject.DefinitionException;
+import javax.inject.Produces;
import javax.inject.manager.Bean;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.injection.FieldInjectionPoint;
+import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.metadata.MetaDataCache;
/**
@@ -92,4 +99,26 @@
return true;
}
+ public static Set<FieldInjectionPoint<?>>
getFieldInjectionPoints(AnnotatedClass<?> annotatedItem, Bean<?>
declaringBean)
+ {
+ Set<FieldInjectionPoint<?>> injectableFields = new
HashSet<FieldInjectionPoint<?>>();
+ for (AnnotatedField<?> annotatedField :
annotatedItem.getMetaAnnotatedFields(BindingType.class))
+ {
+ if (!annotatedField.isAnnotationPresent(Produces.class))
+ {
+ if (annotatedField.isStatic())
+ {
+ throw new DefinitionException("Don't place binding annotations on
static fields " + annotatedField);
+ }
+ if (annotatedField.isFinal())
+ {
+ throw new DefinitionException("Don't place binding annotations on
final fields " + annotatedField);
+ }
+ FieldInjectionPoint<?> fieldInjectionPoint =
FieldInjectionPoint.of(declaringBean, annotatedField);
+ injectableFields.add(fieldInjectionPoint);
+ }
+ }
+ return injectableFields;
+ }
+
}
Modified: ri/trunk/webbeans-ri-spi/pom.xml
===================================================================
--- ri/trunk/webbeans-ri-spi/pom.xml 2009-03-05 13:56:44 UTC (rev 1772)
+++ ri/trunk/webbeans-ri-spi/pom.xml 2009-03-05 16:51:38 UTC (rev 1773)
@@ -38,6 +38,12 @@
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <optional>true</optional>
+ </dependency>
</dependencies>
Modified:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java
===================================================================
---
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java 2009-03-05
13:56:44 UTC (rev 1772)
+++
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/api/Bootstrap.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -1,11 +1,10 @@
package org.jboss.webbeans.bootstrap.api;
-import javax.inject.manager.Manager;
-
import org.jboss.webbeans.bootstrap.spi.EjbDiscovery;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.ejb.spi.EjbResolver;
+import org.jboss.webbeans.manager.api.WebBeansManager;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -76,12 +75,12 @@
public void initialize();
/**
- * Get the manager being used for bootstrap.
+ * Get the manager used for this application.
*
* @return the manager. Unless {@link #initialize()} has been called, this
* method will return null.
*/
- public Manager getManager();
+ public WebBeansManager getManager();
/**
* Starts the boot process.
Modified:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java
===================================================================
---
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java 2009-03-05
13:56:44 UTC (rev 1772)
+++
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/api/helpers/ForwardingBootstrap.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -1,12 +1,11 @@
package org.jboss.webbeans.bootstrap.api.helpers;
-import javax.inject.manager.Manager;
-
import org.jboss.webbeans.bootstrap.api.Bootstrap;
import org.jboss.webbeans.bootstrap.spi.EjbDiscovery;
import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.ejb.spi.EjbResolver;
+import org.jboss.webbeans.manager.api.WebBeansManager;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
@@ -20,7 +19,7 @@
delegate().boot();
}
- public Manager getManager()
+ public WebBeansManager getManager()
{
return delegate().getManager();
}
Added:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java
===================================================================
---
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java
(rev 0)
+++
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.manager.api;
+
+import javax.inject.manager.Manager;
+import javax.servlet.Servlet;
+
+public interface WebBeansManager extends Manager
+{
+
+ public void injectIntoServlet(Servlet servlet);
+
+}
Property changes on:
ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/manager/api/WebBeansManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/packaging/ear/EarArtifactDescriptor.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/packaging/ear/EarArtifactDescriptor.java 2009-03-05
13:56:44 UTC (rev 1772)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/impl/packaging/ear/EarArtifactDescriptor.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -5,6 +5,7 @@
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Writer;
+import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger;
@@ -117,6 +118,14 @@
@Override
public void create() throws IOException
{
+ for (ResourceDescriptor resource : new
HashSet<ResourceDescriptor>(getResources()))
+ {
+ if (resource.getName().startsWith("war"))
+ {
+ getResources().remove(resource);
+ war.getResources().add(new
ResourceDescriptor(resource.getName().substring(3), resource.getSource()));
+ }
+ }
getResources().add(new ResourceDescriptor(war.getDefaultName(), war.getJar()));
getResources().add(new ResourceDescriptor(ejbJar.getDefaultName(),
ejbJar.getJar()));
super.create();
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Barn.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Barn.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Barn.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.lookup.nonContextual;
+
+import java.io.Serializable;
+
+public class Barn implements Serializable
+{
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Barn.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Farm.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Farm.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Farm.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,26 @@
+package org.jboss.jsr299.tck.tests.lookup.nonContextual;
+
+import java.io.Serializable;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Current;
+
+@Stateful
+public class Farm implements FarmLocal, Serializable
+{
+
+ @Current Barn barn;
+
+ @Remove
+ public void remove()
+ {
+
+ }
+
+ public Barn getBarn()
+ {
+ return barn;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Farm.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/FarmLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/FarmLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/FarmLocal.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.lookup.nonContextual;
+
+import javax.ejb.Local;
+
+@Local
+public interface FarmLocal
+{
+
+ public Barn getBarn();
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/FarmLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Hamlet.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Hamlet.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Hamlet.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.lookup.nonContextual;
+
+import javax.annotation.Resource;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+@Stateful
+public class Hamlet implements HamletLocal
+{
+
+ @Resource(mappedName="java:comp/env/servlet-test-runner/Farm/local")
FarmLocal farm;
+
+ @Remove
+ public void remove() {}
+
+ public FarmLocal getFarm()
+ {
+ return farm;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Hamlet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/HamletLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/HamletLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/HamletLocal.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.lookup.nonContextual;
+
+import javax.ejb.Local;
+
+@Local
+public interface HamletLocal
+{
+
+ public FarmLocal getFarm();
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/HamletLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/NonContextualInjectionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/NonContextualInjectionTest.java 2009-03-05
13:56:44 UTC (rev 1772)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/NonContextualInjectionTest.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -2,6 +2,10 @@
import org.hibernate.tck.annotations.SpecAssertion;
import org.jboss.jsr299.tck.AbstractDeclarativeTest;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.jboss.jsr299.tck.impl.packaging.IntegrationTest;
+import org.jboss.jsr299.tck.impl.packaging.Packaging;
+import org.jboss.jsr299.tck.impl.packaging.PackagingType;
import org.testng.annotations.Test;
/**
@@ -9,60 +13,37 @@
* Spec version: PRD2
*
*/
+@Artifact
+@IntegrationTest
+(a)Packaging(PackagingType.EAR)
public class NonContextualInjectionTest extends AbstractDeclarativeTest
{
- /**
- * For the purposes of dependency injection and interceptor/decorator stack
- * creation, the container must treat non-contextual instances of session
- * beans as instances of the most specialized bean that specializes the bean
- * with binding @New and de- ployment type @Standard defined in Section
- * 3.3.6, "Session beans with the @New binding".
- */
- @Test(groups = { "stub", "integration" })
- @SpecAssertion(section = "5.12.1", id = "p")
- public void testNonContextualSessionBeanSpecializesNewBeanForInjection()
+ @Test(groups = { "integration", "stub" })
+ @SpecAssertion(section = "5.12.1", id = "a")
+ public void testInjectionIntoSessionBeanLookedUpInJndi() throws Exception
{
+ // Quite tough as no universal names. Need to allow these to be specified or
something...
assert false;
}
-
- /**
- * Session bean instances obtained directly from JNDI, injected using @EJB or
- * @Resource, or created by the container to re- ceive remote method calls or
- * timeouts are not contextual instances. However, the container is still
- * required to perform de- pendency injection and create interceptor and
- * decorator stacks for these instances.
- */
- @Test(groups = { "stub", "integration" })
- @SpecAssertion(section = "5.12.1", id = "q")
- public void testNonContextualSessionBeanSpecializesNewBeanForInterceptorStack()
+
+ @Test(groups = { "integration" })
+ @SpecAssertion(section = "5.12.1", id = "a")
+ public void testInjectionIntoSessionBeanInjectedViaEjb() throws Exception
{
- assert false;
+ assert getCurrentManager().resolveByType(VillageLocal.class).size() == 1;
+ assert
getCurrentManager().getInstanceByType(VillageLocal.class).getFarm().getBarn() != null;
}
-
- /**
- * Session bean instances obtained directly from JNDI, injected using @EJB or
- * @Resource, or created by the container to re- ceive remote method calls or
- * timeouts are not contextual instances. However, the container is still
- * required to perform de- pendency injection and create interceptor and
- * decorator stacks for these instances.
- */
- @Test(groups = { "stub", "integration" })
- @SpecAssertion(section = "5.12.1", id = "r")
- public void testNonContextualSessionBeanSpecializesNewBeanForDecoratorStack()
+
+ @Test(groups = { "integration", "broken" })
+ @SpecAssertion(section = "5.12.1", id = "a")
+ public void testInjectionIntoSessionBeanInjectedViaResource() throws Exception
{
- assert false;
+ // Quite tough as no universal names. Need to allow these to be specified or
something...
+ assert getCurrentManager().resolveByType(HamletLocal.class).size() == 1;
+ assert getCurrentManager().getInstanceByType(HamletLocal.class).getFarm().getBarn()
!= null;
}
-
- /**
- * Message-driven beans do not have contextual instances. However, the
- * container is still required to perform dependency in- jection and create
- * interceptor and decorator stacks.
- *
- * The container performs dependency injection and creates interceptor and
- * decorator stacks for message-driven bean in- stances according to the bean
- * class annotations.
- */
+
@Test(groups = { "stub", "integration" })
@SpecAssertion(section = "5.12.2", id = "a")
public void testInjectionIntoMessageDrivenBean()
@@ -70,12 +51,6 @@
assert false;
}
- /**
- * Servlets do not have contextual instances. However, the container is still
- * required to perform dependency injection. The container performs
- * dependency injection for servlets according to the servlet class
- * annotations.
- */
@Test(groups = { "stub", "integration" })
@SpecAssertion(section = "5.12.3", id = "a")
public void testInjectionIntoServlet()
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Village.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Village.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Village.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.lookup.nonContextual;
+
+import javax.ejb.EJB;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+
+@Stateful
+public class Village implements VillageLocal
+{
+
+ @EJB FarmLocal farm;
+
+ @Remove
+ public void remove() {}
+
+ public FarmLocal getFarm()
+ {
+ return farm;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/Village.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/VillageLocal.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/VillageLocal.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/VillageLocal.java 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.lookup.nonContextual;
+
+import javax.ejb.Local;
+
+@Local
+public interface VillageLocal
+{
+
+ public FarmLocal getFarm();
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/nonContextual/VillageLocal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/nonContextual/beans.xml
===================================================================
---
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/nonContextual/beans.xml
(rev 0)
+++
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/nonContextual/beans.xml 2009-03-05
16:51:38 UTC (rev 1773)
@@ -0,0 +1,7 @@
+<Beans xmlns="urn:java:ee"
+
xmlns:test="urn:java:org.jboss.jsr299.tck.tests.lookup.nonContextual">
+ <Deploy>
+ <Standard />
+ <Production />
+ </Deploy>
+</Beans>
Property changes on:
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/lookup/nonContextual/beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain