tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1415222 - in /openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb: assembler/classic/ cdi/ config/
Date Thu, 29 Nov 2012 15:57:35 GMT
Author: rmannibucau
Date: Thu Nov 29 15:57:33 2012
New Revision: 1415222

URL: http://svn.apache.org/viewvc?rev=1415222&view=rev
Log:
TOMEE-615 better support of alternative + specialization in webapp for ear

Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/StartupObject.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java?rev=1415222&r1=1415221&r2=1415222&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java
Thu Nov 29 15:57:33 2012
@@ -38,4 +38,5 @@ public class BeansInfo extends InfoObjec
     public final List<String> duplicatedDecorators = new ArrayList<String>();
     public final List<String> duplicatedAlternativeClasses = new ArrayList<String>();
     public final List<String> duplicatedAlternativeStereotypes = new ArrayList<String>();
+    public boolean webapp = false;
 }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java?rev=1415222&r1=1415221&r2=1415222&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
Thu Nov 29 15:57:33 2012
@@ -74,7 +74,7 @@ public class CdiScanner implements Scann
             comparator = new DefaultClassLoaderComparator(classLoader);
         }
 
-        WebBeansContext webBeansContext = startupObject.getAppContext().getWebBeansContext();
+        final WebBeansContext webBeansContext = startupObject.getWebBeansContext();
         final AlternativesManager alternativesManager = webBeansContext.getAlternativesManager();
         final DecoratorsManager decoratorsManager = webBeansContext.getDecoratorsManager();
         final InterceptorsManager interceptorsManager = webBeansContext.getInterceptorsManager();
@@ -124,7 +124,7 @@ public class CdiScanner implements Scann
                     } /* else { don't do it, check is done when we know the beans.xml path
--> org.apache.openejb.config.DeploymentLoader.addBeansXmls
                         throw new WebBeansConfigurationException("Interceptor class : " +
clazz.getName() + " is already defined");
                     }*/
-                } else {
+                } else if (beans.webapp && startupObject.isFromWebApp()) {
                     throw new WebBeansConfigurationException("Could not load interceptor
class: " + className);
                 }
             }
@@ -137,7 +137,7 @@ public class CdiScanner implements Scann
                         decoratorsManager.addNewDecorator(clazz);
                         classes.add(clazz);
                     } // same than interceptors regarding throw new WebBeansConfigurationException("Decorator
class : " + clazz.getName() + " is already defined");
-                } else {
+                } else if (beans.webapp && startupObject.isFromWebApp()) {
                     throw new WebBeansConfigurationException("Could not load decorator class:
" + className);
                 }
             }
@@ -148,7 +148,7 @@ public class CdiScanner implements Scann
                 if (clazz != null) {
                     alternativesManager.addStereoTypeAlternative(clazz, null, null);
                     classes.add(clazz);
-                } else {
+                } else if (beans.webapp && startupObject.isFromWebApp()) {
                     throw new WebBeansConfigurationException("Could not load alternativeStereotype
class: " + className);
                 }
             }
@@ -158,7 +158,7 @@ public class CdiScanner implements Scann
                 if (clazz != null) {
                     alternativesManager.addClazzAlternative(clazz, null, null);
                     classes.add(clazz);
-                } else {
+                } else if (beans.webapp && startupObject.isFromWebApp()) {
                     throw new WebBeansConfigurationException("Could not load alternative
class: " + className);
                 }
             }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/StartupObject.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/StartupObject.java?rev=1415222&r1=1415221&r2=1415222&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/StartupObject.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/StartupObject.java
Thu Nov 29 15:57:33 2012
@@ -66,10 +66,21 @@ public class StartupObject {
         return webContext;
     }
 
+    public WebBeansContext getWebBeansContext() {
+        if (isFromWebApp()) {
+            return webContext.getWebbeansContext();
+        }
+        return appContext.getWebBeansContext();
+    }
+
     public ClassLoader getClassLoader() {
-        if (webContext != null) {
+        if (isFromWebApp()) {
             return webContext.getClassLoader();
         }
         return appContext.getClassLoader();
     }
+
+    public boolean isFromWebApp() {
+        return webContext != null;
+    }
 }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java?rev=1415222&r1=1415221&r2=1415222&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
Thu Nov 29 15:57:33 2012
@@ -372,6 +372,12 @@ public class WebappBeanManager extends B
 
     @Override
     public Set<Bean<?>> getComponents() {
+        if (deploymentBeans.isEmpty()) {
+            // probably not yet merged (afterStart())
+            // so reuse parent beans
+            // this can happen for validations
+            return super.getBeans();
+        }
         return deploymentBeans;
     }
 

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1415222&r1=1415221&r2=1415222&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Thu Nov 29 15:57:33 2012
@@ -95,6 +95,8 @@ import static org.apache.openejb.util.UR
 public class DeploymentLoader implements DeploymentFilterable {
     public static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP_CONFIG,
"org.apache.openejb.util.resources");
     public static final String OPENEJB_ALTDD_PREFIX = "openejb.altdd.prefix";
+    public static final String OPENEJB_ORIGIN_WEBAPP = "openejb.webapp.origin";
+
     private static final String ddDir = "META-INF/";
     private boolean scanManagedBeans = true;
     private static final Collection<String> KNOWN_DESCRIPTORS = Arrays.asList("app-ctx.xml",
"module.properties", "application.properties", "web.xml", "ejb-jar.xml", "openejb-jar.xml",
"env-entries.properties", "beans.xml", "ra.xml", "application.xml", "application-client.xml",
"persistence-fragment.xml", "persistence.xml", "validation.xml", NewLoaderLogic.EXCLUSION_FILE);
@@ -668,6 +670,7 @@ public class DeploymentLoader implements
         // than an ear file, so the ear-style code we were previously
         // using doesn't exactly work anymore.
         final EjbModule webEjbModule = new EjbModule(webModule.getClassLoader(), webModule.getModuleId(),
webModule.getJarLocation(), null, null);
+        webEjbModule.getProperties().put(OPENEJB_ORIGIN_WEBAPP, "true");
         webEjbModule.getAltDDs().putAll(webModule.getAltDDs());
         appModule.getEjbModules().add(webEjbModule);
 

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java?rev=1415222&r1=1415221&r2=1415222&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
Thu Nov 29 15:57:33 2012
@@ -206,6 +206,7 @@ public class EjbJarInfoBuilder {
 
         if (jar.getBeans() != null) {
             ejbJar.beans = new BeansInfo();
+            ejbJar.beans.webapp = Boolean.TRUE.toString().equals(jar.getProperties().getProperty(DeploymentLoader.OPENEJB_ORIGIN_WEBAPP,
Boolean.FALSE.toString()));
 
             ejbJar.beans.interceptors.addAll(jar.getBeans().getInterceptors());
             ejbJar.beans.decorators.addAll(jar.getBeans().getDecorators());



Mime
View raw message