Author: nickarls
Date: 2010-03-10 04:36:55 -0500 (Wed, 10 Mar 2010)
New Revision: 6032
Added:
core/trunk/impl/src/main/java/org/jboss/weld/manager/MessageDrivenInjectionTarget.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/manager/SimpleInjectionTarget.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java
Log:
WELD-463
Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-03-09
23:07:09 UTC (rev 6031)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-03-10
09:36:55 UTC (rev 6032)
@@ -1025,11 +1025,16 @@
return new
SimpleInjectionTarget<T>(getServices().get(ClassTransformer.class).loadClass(type),
this);
}
+ private <T> InjectionTarget<T>
createMessageDrivenInjectionTarget(AnnotatedType<T> type)
+ {
+ return new
MessageDrivenInjectionTarget<T>(getServices().get(ClassTransformer.class).loadClass(type),
this);
+ }
+
public <T> InjectionTarget<T> createInjectionTarget(EjbDescriptor<T>
descriptor)
{
if (descriptor.isMessageDriven())
{
- return createInjectionTarget(createAnnotatedType(descriptor.getBeanClass()));
+ return
createMessageDrivenInjectionTarget(createAnnotatedType(descriptor.getBeanClass()));
}
else
{
Added:
core/trunk/impl/src/main/java/org/jboss/weld/manager/MessageDrivenInjectionTarget.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/manager/MessageDrivenInjectionTarget.java
(rev 0)
+++
core/trunk/impl/src/main/java/org/jboss/weld/manager/MessageDrivenInjectionTarget.java 2010-03-10
09:36:55 UTC (rev 6032)
@@ -0,0 +1,29 @@
+package org.jboss.weld.manager;
+
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.weld.injection.InjectionContextImpl;
+import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.util.Beans;
+
+public class MessageDrivenInjectionTarget<T> extends
SimpleInjectionTarget<T>
+{
+
+ public MessageDrivenInjectionTarget(WeldClass<T> type, BeanManagerImpl
beanManager)
+ {
+ super(type, beanManager);
+ }
+
+ public void inject(final T instance, final CreationalContext<T> ctx)
+ {
+ new InjectionContextImpl<T>(beanManager, this, instance)
+ {
+ public void proceed()
+ {
+ Beans.injectFieldsAndInitializers(instance, ctx, beanManager,
injectableFields, initializerMethods);
+ }
+ }.run();
+
+ }
+
+}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/SimpleInjectionTarget.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/manager/SimpleInjectionTarget.java 2010-03-09
23:07:09 UTC (rev 6031)
+++
core/trunk/impl/src/main/java/org/jboss/weld/manager/SimpleInjectionTarget.java 2010-03-10
09:36:55 UTC (rev 6032)
@@ -47,18 +47,18 @@
public class SimpleInjectionTarget<T> implements InjectionTarget<T>
{
- private final BeanManagerImpl beanManager;
+ protected final BeanManagerImpl beanManager;
private final WeldClass<T> type;
private final ConstructorInjectionPoint<T> constructor;
- private final List<Set<FieldInjectionPoint<?, ?>>>
injectableFields;
- private final List<Set<MethodInjectionPoint<?, ?>>>
initializerMethods;
+ protected final List<Set<FieldInjectionPoint<?, ?>>>
injectableFields;
+ protected final List<Set<MethodInjectionPoint<?, ?>>>
initializerMethods;
private final List<WeldMethod<?, ? super T>> postConstructMethods;
private final List<WeldMethod<?, ? super T>> preDestroyMethods;
private final Set<InjectionPoint> injectionPoints;
- private final Set<WeldInjectionPoint<?, ?>> ejbInjectionPoints;
- private final Set<WeldInjectionPoint<?, ?>>
persistenceContextInjectionPoints;
- private final Set<WeldInjectionPoint<?, ?>>
persistenceUnitInjectionPoints;
- private final Set<WeldInjectionPoint<?, ?>> resourceInjectionPoints;
+ protected final Set<WeldInjectionPoint<?, ?>> ejbInjectionPoints;
+ protected final Set<WeldInjectionPoint<?, ?>>
persistenceContextInjectionPoints;
+ protected final Set<WeldInjectionPoint<?, ?>>
persistenceUnitInjectionPoints;
+ protected final Set<WeldInjectionPoint<?, ?>> resourceInjectionPoints;
public SimpleInjectionTarget(WeldClass<T> type, BeanManagerImpl beanManager)
{
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java 2010-03-09
23:07:09 UTC (rev 6031)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/Control.java 2010-03-10
09:36:55 UTC (rev 6032)
@@ -1,12 +1,13 @@
package org.jboss.weld.tests.ejb.mdb;
+import javax.ejb.MessageDrivenContext;
import javax.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class Control
{
-
private volatile boolean messageDelivered;
+ private volatile boolean contextSet;
public boolean isMessageDelivered()
{
@@ -18,4 +19,17 @@
this.messageDelivered = messageDelivered;
}
+ public void setContext(MessageDrivenContext context)
+ {
+ if (context != null)
+ {
+ contextSet = true;
+ }
+ }
+
+ public boolean isContextSet()
+ {
+ return contextSet;
+ }
+
}
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java 2010-03-09
23:07:09 UTC (rev 6031)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/EJBTest.java 2010-03-10
09:36:55 UTC (rev 6032)
@@ -52,6 +52,7 @@
sender.send(session.createTextMessage(MESSAGE));
Thread.sleep(1000);
assert getReference(Control.class).isMessageDelivered();
+ assert getReference(Control.class).isContextSet();
}
}
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java 2010-03-09
23:07:09 UTC (rev 6031)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/ejb/mdb/MilkMan.java 2010-03-10
09:36:55 UTC (rev 6032)
@@ -16,8 +16,10 @@
*/
package org.jboss.weld.tests.ejb.mdb;
+import javax.annotation.Resource;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
+import javax.ejb.MessageDrivenContext;
import javax.inject.Inject;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -32,11 +34,15 @@
{
@Inject Control control;
+
+ @Resource
+ private MessageDrivenContext context;
public void onMessage(Message message)
{
try
{
+ control.setContext(context);
control.setMessageDelivered(((TextMessage)
message).getText().equals(EJBTest.MESSAGE));
}
catch (JMSException e)
Show replies by date