You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2014/12/24 19:10:08 UTC
tomee git commit: new ejb plugin method for owb
Repository: tomee
Updated Branches:
refs/heads/develop 437bf7b2c -> 8e305cc42
new ejb plugin method for owb
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/8e305cc4
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/8e305cc4
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/8e305cc4
Branch: refs/heads/develop
Commit: 8e305cc42ffd313a72c9208663eaca36fe54a2e8
Parents: 437bf7b
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Wed Dec 24 19:09:45 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Wed Dec 24 19:09:45 2014 +0100
----------------------------------------------------------------------
.../java/org/apache/openejb/cdi/CdiEjbBean.java | 29 +++++++++++++-------
.../java/org/apache/openejb/cdi/CdiPlugin.java | 8 ++++++
tck/cdi-embedded/src/test/resources/failing.xml | 4 +--
3 files changed, 29 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/8e305cc4/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
index d99d5e4..14c9e56 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java
@@ -91,7 +91,7 @@ public class CdiEjbBean<T> extends BaseEjbBean<T> implements InterceptedMarker,
public CdiEjbBean(final BeanContext beanContext, final WebBeansContext webBeansContext, final Class beanClass, final AnnotatedType<T> at,
final InjectionTargetFactoryImpl<T> factory, final BeanAttributes<T> attributes) {
super(webBeansContext, toSessionType(beanContext.getComponentType()), at, new EJBBeanAttributesImpl<T>(beanContext,
- attributes), beanClass, factory);
+ attributes, true), beanClass, factory);
this.beanContext = beanContext;
beanContext.set(Bean.class, this);
passivatingId = beanContext.getDeploymentID() + getReturnType().getName();
@@ -313,15 +313,20 @@ public class CdiEjbBean<T> extends BaseEjbBean<T> implements InterceptedMarker,
}
}
- private static class EJBBeanAttributesImpl<T> extends BeanAttributesImpl<T> {
+ public static class EJBBeanAttributesImpl<T> extends BeanAttributesImpl<T> { // TODO: move it in its own class
private final BeanContext beanContext;
private final Set<Type> ejbTypes;
- public EJBBeanAttributesImpl(final BeanContext bc, final BeanAttributes<T> beanAttributes) {
+ public EJBBeanAttributesImpl(final BeanContext bc, final BeanAttributes<T> beanAttributes, final boolean withSerializable) {
super(beanAttributes, false);
this.beanContext = bc;
this.ejbTypes = new HashSet<Type>();
initTypes();
+ if (withSerializable) {
+ if (!ejbTypes.contains(Serializable.class)) {
+ ejbTypes.add(Serializable.class);
+ }
+ }
}
@Override
@@ -341,25 +346,29 @@ public class CdiEjbBean<T> extends BaseEjbBean<T> implements InterceptedMarker,
final List<Class> cl = beanContext.getBusinessLocalInterfaces();
if (cl != null && !cl.isEmpty()) {
for (final Class<?> c : cl) {
- ejbTypes.add(c);
- ejbTypes.addAll(asList(c.getInterfaces()));
+ ejbTypes.addAll(parentInterfaces(c));
}
}
final List<Class> clRemote = beanContext.getBusinessRemoteInterfaces();
if (clRemote != null && !clRemote.isEmpty()) {
for (final Class<?> c : clRemote) {
- ejbTypes.add(c);
+ ejbTypes.add(c); // parentInterfaces(c), but is it useful in practise?
}
}
- if (!ejbTypes.contains(Serializable.class)) {
- ejbTypes.add(Serializable.class);
- }
-
ejbTypes.add(Object.class);
}
+ private static Collection<Class<?>> parentInterfaces(final Class<?> c) {
+ final Collection<Class<?>> set = new HashSet<>();
+ set.add(c);
+ for (final Class<?> parent : c.getInterfaces()) {
+ set.addAll(parentInterfaces(parent));
+ }
+ return set;
+ }
+
private static void addApiTypes(final Collection<Type> clazzes, final Class<?> beanClass) {
final Typed typed = beanClass.getAnnotation(Typed.class);
if (typed == null || typed.value().length == 0) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/8e305cc4/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
index 02c2642..a879981 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiPlugin.java
@@ -29,6 +29,7 @@ import org.apache.webbeans.component.OwbBean;
import org.apache.webbeans.component.ProducerFieldBean;
import org.apache.webbeans.component.ProducerMethodBean;
import org.apache.webbeans.component.WebBeansType;
+import org.apache.webbeans.component.creation.BeanAttributesBuilder;
import org.apache.webbeans.component.creation.ObserverMethodsBuilder;
import org.apache.webbeans.component.creation.ProducerFieldBeansBuilder;
import org.apache.webbeans.component.creation.ProducerMethodBeansBuilder;
@@ -118,6 +119,13 @@ public class CdiPlugin extends AbstractOwbPlugin implements OpenWebBeansJavaEEPl
}
}
+ public <T> BeanAttributes<T> createBeanAttributes(final AnnotatedType<T> type) {
+ return new CdiEjbBean.EJBBeanAttributesImpl(
+ findBeanContext(webBeansContext, type.getJavaClass()),
+ BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(type).build(),
+ false);
+ }
+
public void configureDeployments(final List<BeanContext> ejbDeployments) {
beans = new WeakHashMap<Class<?>, BeanContext>();
for (final BeanContext deployment : ejbDeployments) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/8e305cc4/tck/cdi-embedded/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/failing.xml b/tck/cdi-embedded/src/test/resources/failing.xml
index 384c1b8..95b92ed 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -20,9 +20,9 @@
<!-- runner helping properties
-Dopenejb.cdi.filter.classloader=false -Dorg.apache.openejb.assembler.classic.WebAppBuilder=org.apache.openejb.web.LightweightWebAppBuilder -Dopenejb.cdi.debug=true -Dopenejb.http.mock-request=true
-->
- <classes><!-- org.jboss.cdi.tck.tests.context.application.ApplicationContextTest, org.jboss.cdi.tck.tests.extensions.beanManager.beanAttributes.CreateBeanAttributesTest, org.jboss.cdi.tck.tests.event.fires.FireEventTest, org.jboss.cdi.tck.tests.extensions.lifecycle.processInjectionPoint.ProcessInjectionPointFiredTest -->
+ <classes><!-- org.jboss.cdi.tck.tests.event.fires.FireEventTest, org.jboss.cdi.tck.tests.extensions.lifecycle.processInjectionPoint.ProcessInjectionPointFiredTest -->
<!--<class name="org.jboss.cdi.tck.tests.context.application.async.ApplicationContextAsyncListenerTest" />-->
- <class name="org.jboss.cdi.tck.tests.context.conversation.ClientConversationContextTest" />
+ <class name="org.jboss.cdi.tck.tests.extensions.beanManager.beanAttributes.CreateBeanAttributesTest" />
</classes>
</test>
</suite>