Author: rmannibucau
Date: Sun May 19 21:52:20 2013
New Revision: 1484354
URL: http://svn.apache.org/r1484354
Log:
servlet and web objects shouldnt be passivation capable if we want to inject
depenent beans which is correct
Modified:
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/ConstructorInjectionBean.java
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
Modified:
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/ConstructorInjectionBean.java
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/ConstructorInjectionBean.java?rev=1484354&r1=1484353&r2=1484354&view=diff
==============================================================================
---
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/ConstructorInjectionBean.java
(original)
+++
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/ConstructorInjectionBean.java
Sun May 19 21:52:20 2013
@@ -46,13 +46,29 @@ public class ConstructorInjectionBean<T>
INJECTION_TARGET_FIELD.setAccessible(true);
}
+ private final boolean passivationCapable;
+
public ConstructorInjectionBean(WebBeansContext webBeansContext, Class<T>
returnType, AnnotatedType<T> at) {
+ this(webBeansContext, returnType, at, null);
+ }
+
+ public ConstructorInjectionBean(WebBeansContext webBeansContext, Class<T>
returnType, AnnotatedType<T> at, Boolean passivationCapable) {
super(webBeansContext, WebBeansType.DEPENDENT, at,
BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(at).build(),
returnType);
try {
INJECTION_TARGET_FIELD.set(this, new
ConstructorInjectionTarget<T>(getAnnotatedType(), getInjectionPoints(),
getWebBeansContext()));
} catch (final Exception e) {
throw new OpenEJBRuntimeException(e);
}
+ if (passivationCapable != null) {
+ this.passivationCapable = passivationCapable;
+ } else {
+ this.passivationCapable = isPassivationCapable();
+ }
+ }
+
+ @Override
+ public boolean isPassivationCapable() {
+ return passivationCapable;
}
private static final class ConstructorInjectionTarget<T> extends
InjectionTargetImpl<T> {
Modified:
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java?rev=1484354&r1=1484353&r2=1484354&view=diff
==============================================================================
---
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
(original)
+++
tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
Sun May 19 21:52:20 2013
@@ -22,6 +22,7 @@ import org.apache.openejb.InjectionProce
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.cdi.ConstructorInjectionBean;
import org.apache.webbeans.component.InjectionTargetBean;
+import org.apache.webbeans.component.WebBeansType;
import org.apache.webbeans.config.WebBeansContext;
import javax.enterprise.context.Dependent;
@@ -29,6 +30,9 @@ import javax.enterprise.context.spi.Crea
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContextListener;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
@@ -152,7 +156,12 @@ public class WebContext {
synchronized (this) {
beanDefinition = constructorInjectionBeanCache.get(beanClass);
if (beanDefinition == null) {
- beanDefinition = new
ConstructorInjectionBean<Object>(webBeansContext, beanClass,
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(beanClass));
+ if (Servlet.class.isAssignableFrom(beanClass) ||
Filter.class.isAssignableFrom(beanClass) ||
ServletContextListener.class.isAssignableFrom(beanClass)) {
+ beanDefinition = new
ConstructorInjectionBean<Object>(webBeansContext, beanClass,
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(beanClass),
false);
+ } else {
+ beanDefinition = new
ConstructorInjectionBean<Object>(webBeansContext, beanClass,
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(beanClass));
+ }
+
constructorInjectionBeanCache.put(beanClass,
beanDefinition);
}
}