You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/01/13 23:50:27 UTC

svn commit: r495991 - in /incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config: ConfigurationFactory.java DeploymentLoader.java DeploymentsResolver.java

Author: dblevins
Date: Sat Jan 13 14:50:26 2007
New Revision: 495991

URL: http://svn.apache.org/viewvc?view=rev&rev=495991
Log:
Reformatted

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

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java?view=diff&rev=495991&r1=495990&r2=495991
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/ConfigurationFactory.java Sat Jan 13 14:50:26 2007
@@ -44,10 +44,10 @@
 import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
 import org.apache.openejb.assembler.classic.OpenEjbConfigurationFactory;
 import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.ServiceInfo;
 import org.apache.openejb.assembler.classic.StatefulSessionContainerInfo;
 import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
 import org.apache.openejb.assembler.classic.TransactionServiceInfo;
-import org.apache.openejb.assembler.classic.ServiceInfo;
 import org.apache.openejb.jee.ApplicationClient;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.Logger;
@@ -57,11 +57,11 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Collections;
 
 public class ConfigurationFactory implements OpenEjbConfigurationFactory, ProviderDefaults {
 
@@ -74,8 +74,8 @@
 
     public static OpenEjbConfiguration sys;
 
-    private final List<ContainerInfo> containers  = new ArrayList<ContainerInfo>();
-    private Map<String,ContainerInfo> containerTable = new HashMap<String,ContainerInfo>();
+    private final List<ContainerInfo> containers = new ArrayList<ContainerInfo>();
+    private Map<String, ContainerInfo> containerTable = new HashMap<String, ContainerInfo>();
 
     private Properties props = new Properties();
     public EjbJarInfoBuilder ejbJarInfoBuilder = new EjbJarInfoBuilder();
@@ -98,7 +98,7 @@
         }
 
         configLocation = ConfigUtils.searchForConfiguration(configLocation, props);
-        if (configLocation != null){
+        if (configLocation != null) {
             this.props.setProperty("openejb.configuration", configLocation);
         }
     }
@@ -183,7 +183,7 @@
     private DynamicDeployer getDeployer(Openejb openejb) {
         DynamicDeployer deployer;
         // TODO: Create some way to enable one versus the other
-        if (false){
+        if (false) {
             deployer = new AutoDeployer(openejb);
 
         } else {
@@ -245,8 +245,8 @@
         String jarLocation = clientModule.getJarLocation();
         File file = new File(jarLocation);
         String name = file.getName();
-        if (name.endsWith(".jar") || name.endsWith(".zip")){
-            name = name.replaceFirst("....$","");
+        if (name.endsWith(".jar") || name.endsWith(".zip")) {
+            name = name.replaceFirst("....$", "");
         }
         return name;
     }

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java?view=diff&rev=495991&r1=495990&r2=495991
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentLoader.java Sat Jan 13 14:50:26 2007
@@ -19,18 +19,18 @@
 
 import org.apache.openejb.OpenEJB;
 import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.core.TemporaryClassLoader;
 import org.apache.openejb.alt.config.ejb.OpenejbJar;
+import org.apache.openejb.core.TemporaryClassLoader;
 import org.apache.openejb.jee.Application;
 import org.apache.openejb.jee.ApplicationClient;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.Module;
 import org.apache.openejb.util.Logger;
-import org.apache.xbean.finder.ResourceFinder;
 import org.apache.xbean.finder.ClassFinder;
+import org.apache.xbean.finder.ResourceFinder;
 
-import javax.ejb.Stateless;
 import javax.ejb.Stateful;
+import javax.ejb.Stateless;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -41,8 +41,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.jar.Manifest;
 import java.util.jar.Attributes;
+import java.util.jar.Manifest;
 
 /**
  * @version $Revision$ $Date$
@@ -112,8 +112,8 @@
                     logger.warning("Cannot load libs from 'META-INF/lib/' : " + e.getMessage(), e);
                 }
 
-                Map<String,URL> ejbModules = new HashMap();
-                Map<String,URL> clientModules = new HashMap();
+                Map<String, URL> ejbModules = new HashMap();
+                Map<String, URL> clientModules = new HashMap();
 
                 URL applicationXmlUrl = descriptors.get("application.xml");
 
@@ -135,7 +135,7 @@
                     }
                 } else {
                     application = new Application();
-                    HashMap<String,URL> files = new HashMap();
+                    HashMap<String, URL> files = new HashMap();
                     scanDir(appDir, files, "");
                     files.remove("META-INF/MANIFEST.MF");
                     for (Map.Entry<String, URL> entry : files.entrySet()) {
@@ -144,15 +144,15 @@
 
                         try {
                             Class moduleType = discoverModuleType(entry.getValue(), tmpClassLoader);
-                            if (EjbModule.class.equals(moduleType)){
+                            if (EjbModule.class.equals(moduleType)) {
                                 ejbModules.put(entry.getKey(), entry.getValue());
-                            } else if (ClientModule.class.equals(moduleType)){
+                            } else if (ClientModule.class.equals(moduleType)) {
                                 clientModules.put(entry.getKey(), entry.getValue());
                             }
                         } catch (UnsupportedOperationException e) {
                             // Ignore it as per the javaee spec EE.8.4.2 section 1.d.iiilogger.info("Ignoring unknown module type: "+entry.getKey());
                         } catch (Exception e) {
-                            throw new OpenEJBException("Unable to determine the module type of "+ entry.getKey()+": Exception: "+ e.getMessage(), e);
+                            throw new OpenEJBException("Unable to determine the module type of " + entry.getKey() + ": Exception: " + e.getMessage(), e);
                         }
                     }
                 }
@@ -256,7 +256,7 @@
         }
     }
 
-    public static void scanDir(File dir, Map<String,URL> files, String path) {
+    public static void scanDir(File dir, Map<String, URL> files, String path) {
         for (File file : dir.listFiles()) {
             if (file.isDirectory()) {
                 scanDir(file, files, path + file.getName() + "/");
@@ -265,7 +265,7 @@
                 try {
                     files.put(path + name, file.toURL());
                 } catch (MalformedURLException e) {
-                    logger.warning("EAR path bad: "+path + name, e);
+                    logger.warning("EAR path bad: " + path + name, e);
                 }
             }
         }
@@ -294,21 +294,21 @@
         }
 
         URL manifestUrl = descriptors.get("MANIFEST.MF");
-        if (manifestUrl != null){
+        if (manifestUrl != null) {
             InputStream is = manifestUrl.openStream();
             Manifest manifest = new Manifest(is);
             String mainClass = manifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
-            if (mainClass != null){
+            if (mainClass != null) {
                 return ClientModule.class;
             }
         }
 
-        ClassFinder classFinder = new ClassFinder(new TemporaryClassLoader(new URL[]{baseUrl},classLoader), baseUrl);
+        ClassFinder classFinder = new ClassFinder(new TemporaryClassLoader(new URL[]{baseUrl}, classLoader), baseUrl);
         List<Class> beans = classFinder.findAnnotatedClasses(Stateless.class);
         beans.addAll(classFinder.findAnnotatedClasses(Stateful.class));
         beans.addAll(classFinder.findAnnotatedClasses(javax.ejb.MessageDriven.class));
 
-        if (beans.size() > 0){
+        if (beans.size() > 0) {
             return EjbModule.class;
         }
 
@@ -325,7 +325,7 @@
     }
 
     private File unpack(File jarFile) throws OpenEJBException {
-        if (jarFile.isDirectory()){
+        if (jarFile.isDirectory()) {
             return jarFile;
         }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentsResolver.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentsResolver.java?view=diff&rev=495991&r1=495990&r2=495991
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentsResolver.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/alt/config/DeploymentsResolver.java Sat Jan 13 14:50:26 2007
@@ -21,14 +21,14 @@
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.xbean.finder.UrlSet;
 
-import java.util.List;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
 
 /**
  * @version $Rev$ $Date$
@@ -86,9 +86,9 @@
         }
 
         HashMap<String, URL> files = new HashMap<String, URL>();
-        DeploymentLoader.scanDir(dir, files,"");
+        DeploymentLoader.scanDir(dir, files, "");
         for (String fileName : files.keySet()) {
-            if (fileName.endsWith(".class")){
+            if (fileName.endsWith(".class")) {
                 if (!jarList.contains(dir.getAbsolutePath())) {
                     jarList.add(dir.getAbsolutePath());
                 }
@@ -102,7 +102,7 @@
         //
         ////////////////////////////////
         for (String fileName : files.keySet()) {
-            if (fileName.endsWith(".jar") || fileName.endsWith(".ear")){
+            if (fileName.endsWith(".jar") || fileName.endsWith(".ear")) {
                 File jar = new File(dir, fileName);
 
                 if (jarList.contains(jar.getAbsolutePath())) continue;
@@ -143,22 +143,22 @@
         return jarList;
     }
 
-    /*
-        * The algorithm of OpenEJB deployments class-path inclusion and exclusion is implemented as follows:
-        * 	1- If the string value of the resource URL matches the include class-path pattern
-        *     Then load this resource
-        *  2- If the string value of the resource URL matches the exclude class-path pattern
-        *     Then ignore this resource
-        *  3- If the include and exclude class-path patterns are not defined
-        *     Then load this resource
-        *
-        * The previous steps are based on the following points:
-        *  1- Include class-path pattern has the highst priority
-        *     This helps in case both patterns are defined using the same values.
-        *     This appears in step 1 and 2 of the above algorithm.
-        *	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.
-        */
+    /**
+     * The algorithm of OpenEJB deployments class-path inclusion and exclusion is implemented as follows:
+     * 1- If the string value of the resource URL matches the include class-path pattern
+     * Then load this resource
+     * 2- If the string value of the resource URL matches the exclude class-path pattern
+     * Then ignore this resource
+     * 3- If the include and exclude class-path patterns are not defined
+     * Then load this resource
+     * <p/>
+     * The previous steps are based on the following points:
+     * 1- Include class-path pattern has the highst priority
+     * This helps in case both patterns are defined using the same values.
+     * This appears in step 1 and 2 of the above algorithm.
+     * 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.
+     */
     private static void loadFromClasspath(FileUtils base, List<String> jarList, ClassLoader classLoader) {
 
         Deployments deployment = null;
@@ -175,32 +175,32 @@
             urlSet = urlSet.excludeJavaExtDirs();
             urlSet = urlSet.excludeJavaEndorsedDirs();
             urlSet = urlSet.excludeJavaHome();
-            urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path",""));
+            urlSet = urlSet.excludePaths(System.getProperty("sun.boot.class.path", ""));
             urlSet = urlSet.exclude(".*/JavaVM.framework/.*");
             urlSet = urlSet.exclude(exclude);
             urlSet = urlSet.include(includes);
 
             List<URL> urls = urlSet.getUrls();
             int size = urls.size();
-            if (size == 0 && include.length() > 0){
-                DeploymentLoader.logger.warning("No classpath URLs matched.  Current settings: "+CLASSPATH_EXCLUDE +"='"+exclude+"', "+CLASSPATH_INCLUDE+"='"+include+"'");
+            if (size == 0 && include.length() > 0) {
+                DeploymentLoader.logger.warning("No classpath URLs matched.  Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
                 return;
             } else if (size == 0) {
                 return;
             } else if (size < 10) {
-                DeploymentLoader.logger.debug("Inspecting classpath for applications: "+urls.size()+" urls.");
+                DeploymentLoader.logger.debug("Inspecting classpath for applications: " + urls.size() + " urls.");
             } else if (size < 50) {
-                DeploymentLoader.logger.info("Inspecting classpath for applications: "+urls.size()+" urls. Consider adjusting your exclude/include.  Current settings: "+CLASSPATH_EXCLUDE +"='"+exclude+"', "+CLASSPATH_INCLUDE+"='"+include+"'");
+                DeploymentLoader.logger.info("Inspecting classpath for applications: " + urls.size() + " urls. Consider adjusting your exclude/include.  Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
             } else {
-                DeploymentLoader.logger.warning("Inspecting classpath for applications: "+urls.size()+" urls.");
-                DeploymentLoader.logger.warning("ADJUST THE EXCLUDE/INCLUDE!!!.  Current settings: "+CLASSPATH_EXCLUDE +"='"+exclude+"', "+CLASSPATH_INCLUDE+"='"+include+"'");
+                DeploymentLoader.logger.warning("Inspecting classpath for applications: " + urls.size() + " urls.");
+                DeploymentLoader.logger.warning("ADJUST THE EXCLUDE/INCLUDE!!!.  Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
             }
 
             long begin = System.currentTimeMillis();
             for (URL url : urls) {
                 try {
                     Class moduleType = DeploymentLoader.discoverModuleType(url, classLoader);
-                    if (AppModule.class.isAssignableFrom(moduleType) || EjbModule.class.isAssignableFrom(moduleType)){
+                    if (AppModule.class.isAssignableFrom(moduleType) || EjbModule.class.isAssignableFrom(moduleType)) {
                         deployment = new Deployments();
                         if (url.getProtocol().equals("jar")) {
                             url = new URL(url.getFile().replaceFirst("!.*$", ""));
@@ -219,7 +219,7 @@
                         loadFrom(deployment, base, jarList);
                     }
                 } catch (IOException e) {
-                    DeploymentLoader.logger.warning("Unable to determine the module type of "+ url.toExternalForm()+": Exception: "+ e.getMessage(), e);
+                    DeploymentLoader.logger.warning("Unable to determine the module type of " + url.toExternalForm() + ": Exception: " + e.getMessage(), e);
                 } catch (UnsupportedOperationException ignore) {
                 }
             }
@@ -227,22 +227,22 @@
             long time = end - begin;
 
             if (time < 1000) {
-                DeploymentLoader.logger.debug("Searched "+urls.size()+" classpath urls in "+time+" milliseconds.  Average "+(time/urls.size())+" milliseconds per url.");
+                DeploymentLoader.logger.debug("Searched " + urls.size() + " classpath urls in " + time + " milliseconds.  Average " + (time / urls.size()) + " milliseconds per url.");
             } else if (time < 4000 || urls.size() < 3) {
-                DeploymentLoader.logger.info("Searched "+urls.size()+" classpath urls in "+time+" milliseconds.  Average "+(time/urls.size())+" milliseconds per url.");
-            } else if (time < 10000){
-                DeploymentLoader.logger.warning("Searched "+urls.size()+" classpath urls in "+time+" milliseconds.  Average "+(time/urls.size())+" milliseconds per url.");
-                DeploymentLoader.logger.warning("Consider adjusting your "+CLASSPATH_EXCLUDE +" and "+CLASSPATH_INCLUDE +" settings.  Current settings: exclude='"+exclude+"', include='"+include+"'");
+                DeploymentLoader.logger.info("Searched " + urls.size() + " classpath urls in " + time + " milliseconds.  Average " + (time / urls.size()) + " milliseconds per url.");
+            } else if (time < 10000) {
+                DeploymentLoader.logger.warning("Searched " + urls.size() + " classpath urls in " + time + " milliseconds.  Average " + (time / urls.size()) + " milliseconds per url.");
+                DeploymentLoader.logger.warning("Consider adjusting your " + CLASSPATH_EXCLUDE + " and " + CLASSPATH_INCLUDE + " settings.  Current settings: exclude='" + exclude + "', include='" + include + "'");
             } else {
-                DeploymentLoader.logger.fatal("Searched "+urls.size()+" classpath urls in "+time+" milliseconds.  Average "+(time/urls.size())+" milliseconds per url.  TOO LONG!");
-                DeploymentLoader.logger.fatal("ADJUST THE EXCLUDE/INCLUDE!!!.  Current settings: "+CLASSPATH_EXCLUDE +"='"+exclude+"', "+CLASSPATH_INCLUDE+"='"+include+"'");
+                DeploymentLoader.logger.fatal("Searched " + urls.size() + " classpath urls in " + time + " milliseconds.  Average " + (time / urls.size()) + " milliseconds per url.  TOO LONG!");
+                DeploymentLoader.logger.fatal("ADJUST THE EXCLUDE/INCLUDE!!!.  Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
                 List<String> list = new ArrayList<String>();
                 for (URL url : urls) {
                     list.add(url.toExternalForm());
                 }
                 Collections.sort(list);
                 for (String url : list) {
-                    DeploymentLoader.logger.info("Matched: "+url);
+                    DeploymentLoader.logger.info("Matched: " + url);
                 }
             }
         } catch (IOException e1) {