svn commit: r1363656 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/container/ContainerLoader.java webapp/src/org/ofbiz/webapp/control/ContextFilter.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1363656 - in /ofbiz/trunk/framework: base/src/org/ofbiz/base/container/ContainerLoader.java webapp/src/org/ofbiz/webapp/control/ContextFilter.java

jacopoc
Author: jacopoc
Date: Fri Jul 20 05:41:27 2012
New Revision: 1363656

URL: http://svn.apache.org/viewvc?rev=1363656&view=rev
Log:
Removed some Geronimo/RMI specific code that was causing issues during system shutdown (several attempts to shutdown the RMIContainer); the code had also some tweaks that made the classes less readable; the static containerMap in ContainerLoader was breaking thread safety because the put operations were not atomic with the related add operations of the loadedContainers list.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java?rev=1363656&r1=1363655&r2=1363656&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java Fri Jul 20 05:41:27 2012
@@ -48,22 +48,6 @@ import org.ofbiz.base.util.UtilXml;
 public class ContainerLoader implements StartupLoader {
 
     public static final String module = ContainerLoader.class.getName();
-    private static Map<String, Container> containerMap = new ConcurrentHashMap<String, Container>();
-
-    /**
-     * Returns a <code>Container</code> that has the specified name. Returns
-     * <code>null</code> if the specified container was not loaded. If more than one
-     * instance of the container was loaded, then the last instance that was loaded is
-     * returned. The returned <code>Container</code> will be initialized, but there is no
-     * guarantee that it will be in the running state.
-     *
-     * @param containerName
-     *            The name of the container.
-     * @return A <code>Container</code> that has the specified name.
-     */
-    public static Container getContainer(String containerName) {
-        return containerMap.get(containerName);
-    }
 
     private String configFile = null;
     private final List<Container> loadedContainers = new LinkedList<Container>();
@@ -114,28 +98,7 @@ public class ContainerLoader implements
                 Debug.logInfo("Loading container: " + containerCfg.name, module);
                 Container tmpContainer = loadContainer(containerCfg, args);
                 this.loadedContainers.add(tmpContainer);
-                containerMap.put(containerCfg.name, tmpContainer);
                 Debug.logInfo("Loaded container: " + containerCfg.name, module);
-
-                // TODO: Put container-specific code in the container.
-                // This is only used in case of OFBiz running in Geronimo or WASCE. It allows to use the RMIDispatcher
-                if (containerCfg.name.equals("rmi-dispatcher") && configFile.equals("limited-containers.xml")) {
-                    try {
-                        ContainerConfig.Container.Property initialCtxProp = containerCfg.getProperty("use-initial-context");
-                        String useCtx = initialCtxProp == null || initialCtxProp.value == null ? "false" : initialCtxProp.value;
-                        if (!useCtx.equalsIgnoreCase("true")) {
-                            //system.setProperty("java.security.policy", "client.policy"); maybe used if needed...
-                            if (System.getSecurityManager() == null) { // needed by WASCE with a client.policy file.
-                                System.setSecurityManager(new java.rmi.RMISecurityManager());
-                            }
-                            tmpContainer.start();
-                        }
-                    } catch (ContainerException e) {
-                        throw new StartupException("Cannot start() " + tmpContainer.getClass().getName(), e);
-                    } catch (java.lang.AbstractMethodError e) {
-                        throw new StartupException("Cannot start() " + tmpContainer.getClass().getName(), e);
-                    }
-                }
             }
         }
         if (this.unloading) {
@@ -159,7 +122,6 @@ public class ContainerLoader implements
                 Debug.logInfo("Loading component's container: " + containerCfg.name, module);
                 Container tmpContainer = loadContainer(containerCfg, args);
                 this.loadedContainers.add(tmpContainer);
-                containerMap.put(containerCfg.name, tmpContainer);
                 Debug.logInfo("Loaded component's container: " + containerCfg.name, module);
             }
         }
@@ -178,7 +140,6 @@ public class ContainerLoader implements
                     }
                     Container tmpContainer = loadContainer(containerCfg, args);
                     this.loadedContainers.add(tmpContainer);
-                    containerMap.put(containerCfg.name, tmpContainer);
                 }
             }
         } catch (Exception e) {

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1363656&r1=1363655&r2=1363656&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java Fri Jul 20 05:41:27 2012
@@ -40,9 +40,6 @@ import javax.servlet.http.HttpServletRes
 
 import javolution.util.FastList;
 
-import org.ofbiz.base.container.Container;
-import org.ofbiz.base.container.ContainerException;
-import org.ofbiz.base.container.ContainerLoader;
 import org.ofbiz.base.util.CachedClassLoader;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
@@ -70,14 +67,11 @@ import org.ofbiz.service.LocalDispatcher
 public class ContextFilter implements Filter {
 
     public static final String module = ContextFilter.class.getName();
-    public static final String CONTAINER_CONFIG = "limited-containers.xml";
     public static final String FORWARDED_FROM_SERVLET = "_FORWARDED_FROM_SERVLET_";
 
     protected ClassLoader localCachedClassLoader = null;
     protected FilterConfig config = null;
     protected boolean debug = false;
-    protected Container rmiLoadedContainer = null; // used in Geronimo/WASCE to allow to deregister
-
 
     /**
      * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
@@ -98,11 +92,6 @@ public class ContextFilter implements Fi
             debug = Debug.verboseOn();
         }
 
-        // load the containers
-        Container container = getContainers();
-        if (container != null) {
-            rmiLoadedContainer = container; // used in Geronimo/WASCE to allow to deregister
-        }
         // check the serverId
         getServerId();
         // initialize the delegator
@@ -334,11 +323,6 @@ public class ContextFilter implements Fi
      */
     public void destroy() {
         getDispatcher(config.getServletContext()).deregister();
-        try {
-            destroyRmiContainer(); // used in Geronimo/WASCE to allow to deregister
-        } catch (ServletException e) {
-            Debug.logError("Error when stopping containers, this exception should not arise...", module);
-        }
         config = null;
     }
 
@@ -455,20 +439,4 @@ public class ContextFilter implements Fi
         }
         return serverId;
     }
-
-    protected Container getContainers() throws ServletException {
-        return ContainerLoader.getContainer("rmi-dispatcher");
-    }
-
-    // used in Geronimo/WASCE to allow to deregister
-    protected void destroyRmiContainer() throws ServletException {
-        if (rmiLoadedContainer != null) {
-            try {
-                rmiLoadedContainer.stop();
-            } catch (ContainerException e) {
-                Debug.logError(e, module);
-                throw new ServletException("Error when stopping the RMI loaded container");
-            }
-        }
-    }
 }