Author: pete.muir(a)jboss.org
Date: 2009-03-14 13:10:09 -0400 (Sat, 14 Mar 2009)
New Revision: 1995
Added:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/IntInjection.java
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducer.java
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducerTest.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
Log:
WBRI-183, thanks to Takeshi Kondo
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-14 16:46:33
UTC (rev 1994)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-14 17:10:09
UTC (rev 1995)
@@ -31,6 +31,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Stack;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
@@ -112,7 +113,7 @@
private transient final ExecutorService taskExecutor =
Executors.newSingleThreadExecutor();
// An injection point metadata beans factory
- private transient final ThreadLocal<InjectionPoint> currentInjectionPoint;
+ private transient final ThreadLocal<Stack<InjectionPoint>>
currentInjectionPoint;
// The bean resolver
private transient final Resolver resolver;
@@ -167,7 +168,14 @@
this.contextMap = new ContextMap();
this.eventManager = new EventManager();
this.ejbDescriptorCache = new EjbDescriptorCache();
- this.currentInjectionPoint = new ThreadLocal<InjectionPoint>();
+ this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
+ {
+ @Override
+ protected Stack<InjectionPoint> initialValue()
+ {
+ return new Stack<InjectionPoint>();
+ }
+ };
this.specializedBeans = new HashMap<Bean<?>, Bean<?>>();
this.servletInjector = new ServletInjector(this);
List<Class<? extends Annotation>> defaultEnabledDeploymentTypes = new
ArrayList<Class<? extends Annotation>>();
@@ -635,7 +643,7 @@
{
if (registerInjectionPoint)
{
- currentInjectionPoint.set(injectionPoint);
+ currentInjectionPoint.get().push(injectionPoint);
}
AnnotatedItem<T, ?> element = ResolvableAnnotatedClass.of((Class<T>)
injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]));
Bean<T> bean = getBeanByType(element, element.getBindingsAsArray());
@@ -660,7 +668,7 @@
{
if (registerInjectionPoint)
{
- currentInjectionPoint.remove();
+ currentInjectionPoint.get().pop();
}
}
}
@@ -917,7 +925,14 @@
*/
public InjectionPoint getInjectionPoint()
{
- return currentInjectionPoint.get();
+ if (!currentInjectionPoint.get().empty())
+ {
+ return currentInjectionPoint.get().peek();
+ }
+ else
+ {
+ return null;
+ }
}
/**
Added:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/IntInjection.java
===================================================================
---
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/IntInjection.java
(rev 0)
+++
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/IntInjection.java 2009-03-14
17:10:09 UTC (rev 1995)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.test.unit.implementation.producer;
+
+import javax.inject.Initializer;
+
+public class IntInjection
+{
+
+ int value;
+
+ @Initializer public IntInjection(Integer integer)
+ {
+ this.value = integer;
+ }
+
+}
Property changes on:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/IntInjection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducer.java
===================================================================
---
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducer.java
(rev 0)
+++
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducer.java 2009-03-14
17:10:09 UTC (rev 1995)
@@ -0,0 +1,32 @@
+package org.jboss.webbeans.test.unit.implementation.producer;
+
+import javax.inject.Current;
+import javax.inject.Produces;
+import javax.inject.manager.InjectionPoint;
+import javax.inject.manager.Manager;
+
+class ManagerProducer
+{
+
+ @Current Manager manager;
+
+ private static boolean injectionPointInjected;
+
+ public static boolean isInjectionPointInjected()
+ {
+ return injectionPointInjected;
+ }
+
+ public static void setInjectionPointInjected(boolean injectionPointInjected)
+ {
+ ManagerProducer.injectionPointInjected = injectionPointInjected;
+ }
+
+ @Produces
+ Integer create(InjectionPoint point)
+ {
+ injectionPointInjected = point != null;
+ return 10;
+ }
+
+}
Property changes on:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducerTest.java
===================================================================
---
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducerTest.java
(rev 0)
+++
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducerTest.java 2009-03-14
17:10:09 UTC (rev 1995)
@@ -0,0 +1,18 @@
+package org.jboss.webbeans.test.unit.implementation.producer;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+@Artifact
+public class ManagerProducerTest extends AbstractWebBeansTest
+{
+ @Test(description="WBRI-183")
+ public void testInjectManagerProducer()
+ {
+ ManagerProducer.setInjectionPointInjected(false);
+ manager.getInstanceByType(IntInjection.class);
+ assert ManagerProducer.isInjectionPointInjected();
+ }
+
+}
Property changes on:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/ManagerProducerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date