tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1296910 - in /openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config: ConfigurableClasspathArchive.java FinderFactory.java Module.java WebappAggregatedArchive.java
Date Mon, 05 Mar 2012 00:19:51 GMT
Author: rmannibucau
Date: Mon Mar  5 00:19:50 2012
New Revision: 1296910

URL: http://svn.apache.org/viewvc?rev=1296910&view=rev
Log:
scan.xml was badly managed for webapps and altdd was not used

Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/WebappAggregatedArchive.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java?rev=1296910&r1=1296909&r2=1296910&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurableClasspathArchive.java
Mon Mar  5 00:19:50 2012
@@ -1,7 +1,6 @@
 package org.apache.openejb.config;
 
 import org.apache.openejb.loader.SystemInstance;
-import org.apache.xbean.finder.ResourceFinder;
 import org.apache.xbean.finder.archive.Archive;
 import org.apache.xbean.finder.archive.ClassesArchive;
 import org.apache.xbean.finder.archive.ClasspathArchive;
@@ -20,23 +19,31 @@ import java.util.List;
 import java.util.Set;
 
 public class ConfigurableClasspathArchive extends CompositeArchive implements ScanConstants
{
-    public ConfigurableClasspathArchive(final ClassLoader loader, final URL... urls) {
-        this(loader, Arrays.asList(urls));
+    public ConfigurableClasspathArchive(final Module module, final URL... urls) {
+        this(module, Arrays.asList(urls));
+    }
+
+    public ConfigurableClasspathArchive(final Module module, final Iterable<URL> urls)
{
+        this(module, false, urls);
     }
 
     public ConfigurableClasspathArchive(final ClassLoader loader, final Iterable<URL>
urls) {
-        this(loader, false, urls);
+        this(new FakeModule(loader), urls);
+    }
+
+    public ConfigurableClasspathArchive(final ClassLoader loader, final URL url) {
+        this(new FakeModule(loader), Arrays.asList(url));
     }
 
-    public ConfigurableClasspathArchive(final ClassLoader loader, boolean forceDescriptor,
final Iterable<URL> urls) {
-        super(archive(loader, urls, forceDescriptor));
+    public ConfigurableClasspathArchive(final Module module, boolean forceDescriptor, final
Iterable<URL> urls) {
+        super(archive(module, urls, forceDescriptor));
     }
 
-    public static List<Archive> archive(final ClassLoader loader, final Iterable<URL>
urls, boolean forceDescriptor) {
+    public static List<Archive> archive(final Module module, final Iterable<URL>
urls, boolean forceDescriptor) {
         final List<Archive> archives = new ArrayList<Archive>();
         for (URL location : urls) {
             try {
-                archives.add(archive(loader, location, forceDescriptor));
+                archives.add(archive(module, location, forceDescriptor));
             } catch (Exception e) {
                 // ignored
             }
@@ -44,10 +51,10 @@ public class ConfigurableClasspathArchiv
         return archives;
     }
 
-    public static Archive archive(final ClassLoader loader, final URL location, boolean forceDescriptor)
{
-        final ResourceFinder scanFinder = new ResourceFinder("", location);
+    public static Archive archive(final Module module, final URL location, boolean forceDescriptor)
{
+        final ClassLoader loader = module.getClassLoader();
         try {
-            final URL scanXml = scanFinder.find(SystemInstance.get().getProperty(SCAN_XML_PROPERTY,
SCAN_XML));
+            final URL scanXml = (URL) module.getAltDDs().get(SystemInstance.get().getProperty(SCAN_XML_PROPERTY,
SCAN_XML_NAME));
             final ScanUtil.ScanHandler scan = ScanUtil.read(scanXml);
             final Archive packageArchive = packageArchive(scan.getPackages(), loader, location);
             final Archive classesArchive = classesArchive(scan.getPackages(), scan.getClasses(),
loader);
@@ -114,4 +121,16 @@ public class ConfigurableClasspathArchiv
         }
         return false;
     }
+
+    private static class FakeModule extends Module {
+        private FakeModule(final ClassLoader loader) {
+            super(false);
+            setClassLoader(loader);
+
+            final URL scanXml = loader.getResource(SCAN_XML);
+            if (scanXml != null) {
+                getAltDDs().put(SCAN_XML, scanXml);
+            }
+        }
+    }
 }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java?rev=1296910&r1=1296909&r2=1296910&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/FinderFactory.java
Mon Mar  5 00:19:50 2012
@@ -49,11 +49,11 @@ public class FinderFactory {
         if (module instanceof WebModule) {
             WebModule webModule = (WebModule) module;
             final ClassLoader webClassLoader = webModule.getClassLoader();
-            finder = new AnnotationFinder(new WebappAggregatedArchive(webClassLoader, webModule.getScannableUrls())).link();
+            finder = new AnnotationFinder(new WebappAggregatedArchive(webModule, webClassLoader,
webModule.getScannableUrls())).link();
         } else if (module instanceof ConnectorModule) {
         	ConnectorModule connectorModule = (ConnectorModule) module;
         	final ClassLoader connectorClassLoader = connectorModule.getClassLoader();
-        	finder = new AnnotationFinder(new ConfigurableClasspathArchive(connectorClassLoader,
connectorModule.getLibraries())).link();
+        	finder = new AnnotationFinder(new ConfigurableClasspathArchive(connectorModule,
connectorModule.getLibraries())).link();
         } else if (module.getJarLocation() != null) {
             String location = module.getJarLocation();
             File file = new File(location);
@@ -70,7 +70,11 @@ public class FinderFactory {
                 url = new URL(location);
             }
 
-            finder = new AnnotationFinder(new ConfigurableClasspathArchive(module.getClassLoader(),
url)).link();
+            if (module instanceof Module) {
+                finder = new AnnotationFinder(new ConfigurableClasspathArchive((Module) module,
url)).link();
+            } else {
+                finder = new AnnotationFinder(new ConfigurableClasspathArchive(module.getClassLoader(),
url)).link();
+            }
         } else {
             finder = new AnnotationFinder(new ClassesArchive()).link();
         }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java?rev=1296910&r1=1296909&r2=1296910&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Module.java
Mon Mar  5 00:19:50 2012
@@ -29,14 +29,20 @@ public class Module {
 
     private ClassLoader classLoader;
 
-    private ValidationConfigType validationConfig;
+    private ValidationConfigType validationConfig = null;
     private final Map<String, Object> altDDs = new HashMap<String, Object>();
-    private String uniqueId;
+    private String uniqueId = null;
     private AppModule appModule = null;
-    private Resources resources;
+    private Resources resources = null;
+
+    public Module(boolean needId) {
+        if (needId) {
+            uniqueId = Integer.toString(currentId++);
+        }
+    }
 
     public Module() {
-        uniqueId = Integer.toString(currentId++);
+        this(true);
     }
 
     public ValidationConfigType getValidationConfig() {

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/WebappAggregatedArchive.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/WebappAggregatedArchive.java?rev=1296910&r1=1296909&r2=1296910&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/WebappAggregatedArchive.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/WebappAggregatedArchive.java
Mon Mar  5 00:19:50 2012
@@ -16,17 +16,15 @@ import java.util.List;
 import java.util.Map;
 
 public class WebappAggregatedArchive implements Archive, ScanConstants {
-    private static final String WEBAPP_GLOBAL_SCAN_LOCATION = "WEB-INF/" + SCAN_XML_NAME;
-
     private final Map<URL, List<String>> map = new HashMap<URL, List<String>>();
     private ScanUtil.ScanHandler handler = null;
     private boolean scanXmlExists = false; // faster than using an empty handler
     private Archive archive;
 
-    public WebappAggregatedArchive(final ClassLoader loader, final Iterable<URL> urls)
{
+    public WebappAggregatedArchive(final WebModule module, final ClassLoader loader, final
Iterable<URL> urls) {
         final List<Archive> archives = new ArrayList<Archive>();
 
-        final URL scanXml = loader.getResource(WEBAPP_GLOBAL_SCAN_LOCATION);
+        final URL scanXml = (URL) module.getAltDDs().get(ScanConstants.SCAN_XML_NAME);
         if (scanXml != null) {
             try {
                 handler = ScanUtil.read(scanXml);



Mime
View raw message