tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1652 cdiStereotypes() in @Classes
Date Tue, 03 Nov 2015 17:39:51 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 4baf8a60e -> ca0436e8f


TOMEE-1652 cdiStereotypes() in @Classes


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/ca0436e8
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/ca0436e8
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/ca0436e8

Branch: refs/heads/master
Commit: ca0436e8f34c08de809c18bce6732f3675ac01ee
Parents: 4baf8a6
Author: Romain Manni-Bucau <rmannibu@gmail.com>
Authored: Tue Nov 3 09:39:41 2015 -0800
Committer: Romain Manni-Bucau <rmannibu@gmail.com>
Committed: Tue Nov 3 09:39:41 2015 -0800

----------------------------------------------------------------------
 .../openejb/testing/ApplicationComposers.java   | 57 ++++++++++++--------
 .../org/apache/openejb/testing/Classes.java     |  2 +
 2 files changed, 38 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ca0436e8/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
index 8c6f1a0..d1b1507 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/ApplicationComposers.java
@@ -99,6 +99,15 @@ import org.apache.xbean.finder.filter.Filter;
 import org.apache.xbean.finder.filter.Filters;
 import org.xml.sax.InputSource;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -120,15 +129,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.inject.spi.Extension;
-import javax.inject.Inject;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 
 import static java.util.Arrays.asList;
 import static org.apache.openejb.config.DeploymentFilterable.DEPLOYMENTS_CLASSPATH_PROPERTY;
@@ -431,6 +431,7 @@ public class ApplicationComposers {
                 String[] excludes = null;
                 Class<?>[] cdiInterceptors = null;
                 Class<?>[] cdiAlternatives = null;
+                Class<?>[] cdiStereotypes = null;
                 Class<?>[] cdiDecorators = null;
                 boolean cdi = false;
                 boolean innerClassesAsBean = false;
@@ -441,8 +442,8 @@ public class ApplicationComposers {
                     cdiInterceptors = classesAnnotation.cdiInterceptors();
                     cdiDecorators = classesAnnotation.cdiDecorators();
                     cdiAlternatives = classesAnnotation.cdiAlternatives();
-                    cdi = classesAnnotation.cdi() || cdiAlternatives.length > 0
-                        || cdiDecorators.length > 0 || cdiInterceptors.length > 0;
+                    cdiStereotypes = classesAnnotation.cdiStereotypes();
+                    cdi = isCdi(classesAnnotation.cdi(), cdiInterceptors, cdiAlternatives,
cdiStereotypes, cdiDecorators);
                 } else if (classesAnnotationOld != null) {
                     classes = classesAnnotationOld.value();
                 }
@@ -458,7 +459,7 @@ public class ApplicationComposers {
                         method.getAnnotation(Descriptors.class), method.getAnnotation(JaxrsProviders.class),
                         webApp,
                         globalJarsAnnotation, jarsAnnotation,
-                        classes, excludes, cdiInterceptors, cdiAlternatives, cdiDecorators,
cdi, innerClassesAsBean,
+                        classes, excludes, cdiInterceptors, cdiAlternatives, cdiDecorators,
cdiStereotypes, cdi, innerClassesAsBean,
                         defaultConfig);
                 } else if (obj instanceof WebModule) { // will add the ejbmodule too
                     webModulesNb++;
@@ -471,7 +472,7 @@ public class ApplicationComposers {
                     final EjbModule ejbModule = DeploymentLoader.addWebModule(webModule,
appModule);
                     ejbModule.getProperties().put(CdiScanner.OPENEJB_CDI_FILTER_CLASSLOADER,
"false");
                     if (cdi) {
-                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors,
cdiAlternatives));
+                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors,
cdiAlternatives, cdiStereotypes));
                     }
 
                     Collection<File> files = findFiles(jarsAnnotation);
@@ -489,7 +490,7 @@ public class ApplicationComposers {
                     ejbModule.initAppModule(appModule);
                     appModule.getEjbModules().add(ejbModule);
                     if (cdi) {
-                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors,
cdiAlternatives));
+                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors,
cdiAlternatives, cdiStereotypes));
                     }
 
                     Collection<File> files = findFiles(jarsAnnotation);
@@ -509,7 +510,7 @@ public class ApplicationComposers {
 
                     appModule.getEjbModules().add(ejbModule);
                     if (cdi) {
-                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors,
cdiAlternatives));
+                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors,
cdiAlternatives, cdiStereotypes));
                     }
 
                     Collection<File> files = findFiles(jarsAnnotation);
@@ -528,7 +529,7 @@ public class ApplicationComposers {
                     ejbModule.setBeans(beans);
                     appModule.getEjbModules().add(ejbModule);
                     if (cdi) {
-                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors,
cdiAlternatives));
+                        ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors,
cdiAlternatives, cdiStereotypes));
                     }
                     Collection<File> files = findFiles(jarsAnnotation);
                     if (defaultConfig) {
@@ -565,7 +566,7 @@ public class ApplicationComposers {
                     ejbModule.setBeans(beans);
                     appModule.getEjbModules().add(ejbModule);
                     if (cdi) {
-                        ejbModule.setBeans(beans(beans, cdiDecorators, cdiInterceptors, cdiAlternatives));
+                        ejbModule.setBeans(beans(beans, cdiDecorators, cdiInterceptors, cdiAlternatives,
cdiStereotypes));
                     }
                     Collection<File> files = findFiles(jarsAnnotation);
                     if (defaultConfig) {
@@ -639,7 +640,7 @@ public class ApplicationComposers {
                     appModule, testBean, additionalDescriptors,
                     null, null,
                     webapp, globalJarsAnnotation, null, classClasses.value(), classClasses.excludes(),
-                    classClasses.cdiInterceptors(), classClasses.cdiAlternatives(), classClasses.cdiDecorators(),
+                    classClasses.cdiInterceptors(), classClasses.cdiAlternatives(), classClasses.cdiDecorators(),
classClasses.cdiStereotypes(),
                     classClasses.cdi(), classClasses.innerClassesAsBean(), testClass.getAnnotation(Default.class)
!= null);
             webModulesNb++;
             moduleNumber++;
@@ -759,6 +760,14 @@ public class ApplicationComposers {
         testClassFinders.put(this, testClassFinder);
     }
 
+    private boolean isCdi(final boolean cdi, final Class<?>[] cdiInterceptors,
+                          final Class<?>[] cdiAlternatives, final Class<?>[]
cdiStereotypes,
+                          final Class<?>[] cdiDecorators) {
+        return cdi || cdiAlternatives.length > 0
+            || cdiDecorators.length > 0 || cdiInterceptors.length > 0
+            || cdiStereotypes.length > 0;
+    }
+
     protected boolean mockCdiContexts() {
         return "true".equalsIgnoreCase(SystemInstance.get().getProperty("openejb.testing.start-cdi-contexts",
"true"));
     }
@@ -774,6 +783,7 @@ public class ApplicationComposers {
                           final Class<?>[] cdiInterceptors,
                           final Class<?>[] cdiAlternatives,
                           final Class<?>[] cdiDecorators,
+                           final Class<?>[] cdiStereotypes,
                           final boolean cdi,
                           final boolean innerClassesAsBean,
                           final boolean autoConfig) throws OpenEJBException {
@@ -808,8 +818,8 @@ public class ApplicationComposers {
 
         final EjbModule ejbModule = DeploymentLoader.addWebModule(webModule, appModule);
         ejbModule.getProperties().put(CdiScanner.OPENEJB_CDI_FILTER_CLASSLOADER, "false");
-        if (cdi) {
-            ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors, cdiAlternatives));
+        if (isCdi(cdi, cdiInterceptors, cdiAlternatives, cdiStereotypes, cdiDecorators))
{
+            ejbModule.setBeans(beans(new Beans(), cdiDecorators, cdiInterceptors, cdiAlternatives,
cdiStereotypes));
         }
 
         Class<?>[] classes = cdiClasses;
@@ -970,7 +980,7 @@ public class ApplicationComposers {
     }
 
     private Beans beans(final Beans beans, final Class<?>[] cdiDecorators, final Class<?>[]
cdiInterceptors,
-                        final Class<?>[] cdiAlternatives) {
+                        final Class<?>[] cdiAlternatives, final Class<?>[] cdiStereotypes)
{
         if (cdiDecorators != null) {
             for (final Class<?> clazz : cdiDecorators) {
                 beans.addDecorator(clazz);
@@ -986,6 +996,11 @@ public class ApplicationComposers {
                 beans.addAlternativeClass(clazz);
             }
         }
+        if (cdiStereotypes != null) {
+            for (final Class<?> clazz : cdiStereotypes) {
+                beans.addAlternativeStereotype(clazz);
+            }
+        }
         return beans;
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/ca0436e8/container/openejb-core/src/main/java/org/apache/openejb/testing/Classes.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/testing/Classes.java
b/container/openejb-core/src/main/java/org/apache/openejb/testing/Classes.java
index 3806f42..713a588 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/testing/Classes.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/testing/Classes.java
@@ -35,6 +35,8 @@ public @interface Classes {
 
     Class<?>[] cdiAlternatives() default {};
 
+    Class<?>[] cdiStereotypes() default {};
+
     boolean cdi() default false;
 
     // only for WebApp ATM


Mime
View raw message