svn commit: r1863019 - in /ofbiz/ofbiz-framework/trunk/framework: base/config/ base/dtd/ base/src/main/java/org/apache/ofbiz/base/container/ start/src/main/java/org/apache/ofbiz/base/start/

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

svn commit: r1863019 - in /ofbiz/ofbiz-framework/trunk/framework: base/config/ base/dtd/ base/src/main/java/org/apache/ofbiz/base/container/ start/src/main/java/org/apache/ofbiz/base/start/

mthl
Author: mthl
Date: Sat Jul 13 21:37:40 2019
New Revision: 1863019

URL: http://svn.apache.org/viewvc?rev=1863019&view=rev
Log:
Improved: Remove support for “ofbiz-containers.xml”
(OFBIZ-11100)

To extend the containers loaded on startup, it was possible too both
edit the “ofbiz-containers.xml” file or alternatively to define a
container in a component.

This redundancy adds extra complexity in the startup process for no
good extensibility reason. The component container loader is more
flexible since it allows developper to add new containers without
touching the framework so it is better to only rely on this option.

The component loader is now hard-coded directly in code.

Removed:
    ofbiz/ofbiz-framework/trunk/framework/base/config/ofbiz-containers.xml
    ofbiz/ofbiz-framework/trunk/framework/base/dtd/ofbiz-containers.xsd
Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/Container.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java
    ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/Container.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/Container.java?rev=1863019&r1=1863018&r2=1863019&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/Container.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/Container.java Sat Jul 13 21:37:40 2019
@@ -45,12 +45,14 @@ public interface Container {
      *
      * @param ofbizCommands Command-line arguments.
      * @param name Unique name of the container's instance.
-     * @param configFile Location of the configuration file used to load this container.
+     * @param configFile  always {@code null} but used to be the location of the global
+     *                    container configuration file which does not exist anymore
      * @throws ContainerException If an error was encountered. Throwing this exception
      * will halt container loading, so it should be thrown only when other containers
      * might depend on this one.
      */
-    public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException;
+    void init(List<StartupCommand> ofbizCommands, String name, String configFile)
+            throws ContainerException;
 
     /**
      * Start the container process. This method must not block - implementations

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java?rev=1863019&r1=1863018&r2=1863019&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java Sat Jul 13 21:37:40 2019
@@ -66,14 +66,17 @@ public class ContainerLoader {
         // loaders defined in startup (e.g. main, test, load-data, etc ...)
         List<String> loaders = config.loaders;
 
-        // load containers defined in ofbiz-containers.xml
-        Debug.logInfo("[Startup] Loading containers...", module);
-        List<ContainerConfig.Configuration> ofbizContainerConfigs = filterContainersHavingMatchingLoaders(
-                loaders, retrieveOfbizContainers(config.containerConfig));
-        loadedContainers.addAll(loadContainersFromConfigurations(ofbizContainerConfigs, config, ofbizCommands));
+        // Load mandatory container providing access to containers from components.
+        try {
+            ComponentContainer cc = new ComponentContainer();
+            cc.init(ofbizCommands, "component-container", null);
+            loadedContainers.add(cc);
+        } catch (ContainerException e) {
+            throw new StartupException("Cannot init() component-container", e);
+        }
 
-        // load containers defined in components
-        Debug.logInfo("[Startup] Loading component containers...", module);
+        // Load containers defined in components.
+        Debug.logInfo("[Startup] Loading containers...", module);
         List<ContainerConfig.Configuration> componentContainerConfigs = filterContainersHavingMatchingLoaders(
                 loaders, ComponentConfig.getAllConfigurations());
         loadedContainers.addAll(loadContainersFromConfigurations(componentContainerConfigs, config, ofbizCommands));
@@ -82,15 +85,6 @@ public class ContainerLoader {
         startLoadedContainers();
     }
 
-    private static Collection<ContainerConfig.Configuration> retrieveOfbizContainers(String configFile)
-            throws StartupException {
-        try {
-            return ContainerConfig.getConfigurations(configFile);
-        } catch (ContainerException e) {
-            throw new StartupException(e);
-        }
-    }
-
     private static List<ContainerConfig.Configuration> filterContainersHavingMatchingLoaders(List<String> loaders,
             Collection<ContainerConfig.Configuration> containerConfigs) {
         return containerConfigs.stream()
@@ -116,15 +110,16 @@ public class ContainerLoader {
         List<Container> loadContainers = new ArrayList<>();
         for (ContainerConfig.Configuration containerCfg : containerConfigs) {
             Debug.logInfo("Loading container: " + containerCfg.name, module);
-            Container tmpContainer = loadContainer(config.containerConfig, containerCfg, ofbizCommands);
+            Container tmpContainer = loadContainer(containerCfg, ofbizCommands);
             loadContainers.add(tmpContainer);
             Debug.logInfo("Loaded container: " + containerCfg.name, module);
         }
         return loadContainers;
     }
 
-    private static Container loadContainer(String configFile, ContainerConfig.Configuration containerCfg,
-            List<StartupCommand> ofbizCommands) throws StartupException {
+
+    private static Container loadContainer(ContainerConfig.Configuration containerCfg, List<StartupCommand> ofbizCommands)
+            throws StartupException {
         // load the container class
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         Class<?> containerClass;
@@ -150,7 +145,7 @@ public class ContainerLoader {
 
         // initialize the container object
         try {
-            containerObj.init(ofbizCommands, containerCfg.name, configFile);
+            containerObj.init(ofbizCommands, containerCfg.name, null);
         } catch (ContainerException e) {
             throw new StartupException("Cannot init() " + containerCfg.name, e);
         }

Modified: ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java?rev=1863019&r1=1863018&r2=1863019&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Config.java Sat Jul 13 21:37:40 2019
@@ -40,7 +40,6 @@ public final class Config {
     public final String adminKey;
     public final int portOffset;
     public final int adminPort;
-    public final String containerConfig;
     public final List<String> loaders;
     public final String logDir;
     public final boolean shutdownAfterLoad;
@@ -57,8 +56,6 @@ public final class Config {
         adminKey = getProperty(props, "ofbiz.admin.key", "NA");
         portOffset = getPortOffsetValue(ofbizCommands, "0");
         adminPort = getAdminPort(props, 0, portOffset);
-        containerConfig = getAbsolutePath(props, "ofbiz.container.config",
-                "framework/base/config/ofbiz-containers.xml", ofbizHome);
         loaders = Arrays.asList(getProperty(props, "ofbiz.start.loaders", "").split(","));
         logDir = getAbsolutePath(props, "ofbiz.log.dir", "runtime/logs", ofbizHome);
         shutdownAfterLoad = getProperty(props, "ofbiz.auto.shutdown", "false").equalsIgnoreCase("true");