tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1058856 - in /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config: ConfigurationFactory.java DeploymentLoader.java DeploymentsResolver.java
Date Fri, 14 Jan 2011 05:50:15 GMT
Author: xuhaihong
Date: Fri Jan 14 05:50:15 2011
New Revision: 1058856

URL: http://svn.apache.org/viewvc?rev=1058856&view=rev
Log:
OPENEJB-1231 Webapp context.xml setting allows app to be ignored entirely by OpenEJB (Patch
from Shawn Jiang)

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1058856&r1=1058855&r2=1058856&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
Fri Jan 14 05:50:15 2011
@@ -404,7 +404,7 @@ public class ConfigurationFactory implem
             declaredApps = getDeclaredApps();
         }
         List<URL> classpathAppsUrls = new ArrayList<URL>();
-        DeploymentsResolver.loadFromClasspath(base, classpathAppsUrls, classLoader);
+        DeploymentsResolver.loadFromClasspath(base, classpathAppsUrls, classLoader, null);
 
         ArrayList<File> jarFiles = new ArrayList<File>();
         for (URL path : classpathAppsUrls) {

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1058856&r1=1058855&r2=1058856&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
Fri Jan 14 05:50:15 2011
@@ -513,7 +513,7 @@ public class DeploymentLoader implements
                 p.put(appModule.getModuleId(), appModule.getJarLocation());
                 FileUtils base = new FileUtils(appModule.getModuleId(), appModule.getModuleId(),
p);
                 List<URL> filteredUrls = new ArrayList<URL>();
-                DeploymentsResolver.loadFromClasspath(base, filteredUrls, appModule.getClassLoader());
+                DeploymentsResolver.loadFromClasspath(base, filteredUrls, appModule.getClassLoader(),null);
                 addPersistenceUnits(appModule, filteredUrls.toArray(new URL[filteredUrls.size()]));
             }
 
@@ -622,7 +622,7 @@ public class DeploymentLoader implements
 
         contextParams.getProperties().put(webModule.getModuleId(), warPath);
         FileUtils base = new FileUtils(webModule.getModuleId(), webModule.getModuleId(),
contextParams.getProperties());
-        DeploymentsResolver.loadFromClasspath(base, urls, webClassLoader, include, exclude,
requireDescriptors, filterDescriptors, filterSystemApps);
+        DeploymentsResolver.loadFromClasspath(base, urls, webClassLoader, include, exclude,
requireDescriptors, filterDescriptors, filterSystemApps, ddDir);
 
         // we need to exclude previously deployed modules
         // using a Set instead of a list would be easier ...
@@ -1315,7 +1315,18 @@ public class DeploymentLoader implements
         final boolean scanPotentialEjbModules = !requireDescriptor.contains(RequireDescriptors.EJB);
         final boolean scanPotentialClientModules = !requireDescriptor.contains(RequireDescriptors.CLIENT);
 
-        ResourceFinder finder = new ResourceFinder("", classLoader, baseUrl);
+        
+        URL pathToScanDescriptors=baseUrl;
+        String baseURLString=baseUrl.toString();
+        
+        if (baseUrl.getProtocol().equals("file") && baseURLString.endsWith("WEB-INF/classes/"))
{
+            //EJB found in WAR/WEB-INF/classes, scan WAR for ejb-jar.xml
+            
+            pathToScanDescriptors=new URL(baseURLString.substring(0,baseURLString.lastIndexOf("WEB-INF/classes/")));
+
+        }
+        ResourceFinder finder = new ResourceFinder("", classLoader, pathToScanDescriptors);
+        
         Map<String, URL> descriptors = altDDSources(finder.getResourcesMap(ddDir),
false);
 
         String path = baseUrl.getPath();

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java?rev=1058856&r1=1058855&r2=1058856&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
Fri Jan 14 05:50:15 2011
@@ -169,7 +169,7 @@ public class DeploymentsResolver impleme
      * 2- Loading the resource is the default behaviour in case of not defining a value for
any class-path pattern
      * This appears in step 3 of the above algorithm.
      */
-    public static void loadFromClasspath(FileUtils base, List<URL> jarList, ClassLoader
classLoader) {
+    public static void loadFromClasspath(FileUtils base, List<URL> jarList, ClassLoader
classLoader, String ddDir) {
         Options options = SystemInstance.get().getOptions();
         String include = options.get(CLASSPATH_INCLUDE, "");
         String exclude = options.get(CLASSPATH_EXCLUDE, ".*");
@@ -178,12 +178,12 @@ public class DeploymentsResolver impleme
         boolean filterSystemApps = options.get(CLASSPATH_FILTER_SYSTEMAPPS, true);
 
         loadFromClasspath(base, jarList, classLoader,
-                include, exclude, requireDescriptors, filterDescriptors, filterSystemApps);
+                include, exclude, requireDescriptors, filterDescriptors, filterSystemApps,
ddDir);
     }
 
     public static void loadFromClasspath(FileUtils base, List<URL> jarList, ClassLoader
classLoader,
                                          String include, String exclude, Set<RequireDescriptors>
requireDescriptors,
-                                         boolean filterDescriptors, boolean filterSystemApps)
{
+                                         boolean filterDescriptors, boolean filterSystemApps,
String ddDir) {
 
         try {
             UrlSet urlSet = new UrlSet(classLoader);
@@ -234,7 +234,7 @@ public class DeploymentsResolver impleme
             }
 
             long begin = System.currentTimeMillis();
-            processUrls(urls, classLoader, requireDescriptors, base, jarList);
+            processUrls(urls, classLoader, requireDescriptors, base, jarList,ddDir);
             long end = System.currentTimeMillis();
             long time = end - begin;
 
@@ -244,7 +244,7 @@ public class DeploymentsResolver impleme
                 if (filterSystemApps){
                     unchecked = unchecked.exclude(".*/openejb-[^/]+(.(jar|ear|war)(./)?|/target/classes/?)");
                 }
-                processUrls(unchecked.getUrls(), classLoader, EnumSet.allOf(RequireDescriptors.class),
base, jarList);
+                processUrls(unchecked.getUrls(), classLoader, EnumSet.allOf(RequireDescriptors.class),
base, jarList, ddDir);
             }
 
             if (logger.isDebugEnabled()) {
@@ -378,7 +378,7 @@ public class DeploymentsResolver impleme
         return urlSet;
     }
 
-    private static void processUrls(List<URL> urls, ClassLoader classLoader, Set<RequireDescriptors>
requireDescriptors, FileUtils base, List<URL> jarList) {
+    private static void processUrls(List<URL> urls, ClassLoader classLoader, Set<RequireDescriptors>
requireDescriptors, FileUtils base, List<URL> jarList, String ddDir) {
         for (URL url : urls) {
 
             String urlProtocol = url.getProtocol();
@@ -392,7 +392,10 @@ public class DeploymentsResolver impleme
             Deployments deployment;
             String path = "";
             try {
-                Class<? extends DeploymentModule> moduleType = new DeploymentLoader().discoverModuleType(url,
classLoader, requireDescriptors);
+                
+                DeploymentLoader deploymentLoader = (ddDir == null) ? new DeploymentLoader(ddDir)
: new DeploymentLoader(ddDir);
+                
+                Class<? extends DeploymentModule> moduleType = deploymentLoader.discoverModuleType(url,
classLoader, requireDescriptors);
                 if (AppModule.class.isAssignableFrom(moduleType) || EjbModule.class.isAssignableFrom(moduleType)
|| PersistenceModule.class.isAssignableFrom(moduleType) || ConnectorModule.class.isAssignableFrom(moduleType)
|| ClientModule.class.isAssignableFrom(moduleType)) {
                     deployment = JaxbOpenejb.createDeployments();
                     if (urlProtocol.equals("jar")) {



Mime
View raw message