Author: jacopoc Date: Thu Jun 28 09:31:37 2012 New Revision: 1354884 URL: http://svn.apache.org/viewvc?rev=1354884&view=rev Log: It is now possible for a component to define new "containers" that are loaded after the ones defined in base/conf/*-containers.xml
Modified: ofbiz/trunk/framework/base/dtd/ofbiz-component.xsd ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java ofbiz/trunk/framework/base/src/org/ofbiz/base/container/ContainerLoader.java Modified: ofbiz/trunk/framework/base/dtd/ofbiz-component.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/dtd/ofbiz-component.xsd?rev=1354884&r1=1354883&r2=1354884&view=diff ============================================================================== --- ofbiz/trunk/framework/base/dtd/ofbiz-component.xsd (original) +++ ofbiz/trunk/framework/base/dtd/ofbiz-component.xsd Thu Jun 28 09:31:37 2012 @@ -29,6 +29,7 @@ under the License. <xs:element minOccurs="0" maxOccurs="unbounded" ref="test-suite"/> <xs:element minOccurs="0" maxOccurs="unbounded" ref="keystore"/> <xs:element minOccurs="0" maxOccurs="unbounded" ref="webapp"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="container"/> </xs:sequence> <xs:attributeGroup ref="attlist.ofbiz-component"/> </xs:complexType> @@ -242,6 +243,38 @@ under the License. <xs:attribute type="xs:string" name="name" use="required"/> <xs:attribute type="xs:string" name="value" use="required"/> </xs:attributeGroup> + + <xs:element name="container"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="property"/> + </xs:sequence> + <xs:attributeGroup ref="attlist.container"/> + </xs:complexType> + </xs:element> + <xs:attributeGroup name="attlist.container"> + <xs:attribute type="xs:string" name="name" use="required"/> + <xs:attribute type="xs:string" name="class" use="required"/> + </xs:attributeGroup> + <xs:element name="property"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="property"/> + <xs:element minOccurs="0" ref="property-value"/> + </xs:sequence> + <xs:attributeGroup ref="attlist.property"/> + </xs:complexType> + </xs:element> + <xs:attributeGroup name="attlist.property"> + <xs:attribute type="xs:string" name="name" use="required"/> + <xs:attribute type="xs:string" name="value"/> + </xs:attributeGroup> + <xs:element name="property-value" type="any"/> + <xs:complexType name="any" mixed="true"> + <xs:sequence> + <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/> + </xs:sequence> + </xs:complexType> </xs:schema> <!-- <ofbiz-component name="core"> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java?rev=1354884&r1=1354883&r2=1354884&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/component/ComponentConfig.java Thu Jun 28 09:31:37 2012 @@ -33,6 +33,8 @@ import javax.xml.parsers.ParserConfigura import javolution.util.FastList; import javolution.util.FastMap; +import org.ofbiz.base.container.ContainerConfig; +import org.ofbiz.base.container.ContainerException; import org.ofbiz.base.location.FlexibleLocation; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.KeyStoreUtil; @@ -224,6 +226,20 @@ public class ComponentConfig { return webappInfos; } + public static List<ContainerConfig.Container> getAllContainers() { + return getAllContainers(null); + } + + public static List<ContainerConfig.Container> getAllContainers(String componentName) { + List<ContainerConfig.Container> containers = FastList.newInstance(); + for (ComponentConfig cc: getAllComponents()) { + if (componentName == null || componentName.equals(cc.getComponentName())) { + containers.addAll(cc.getContainers()); + } + } + return containers; + } + public static boolean isFileResourceLoader(String componentName, String resourceLoaderName) throws ComponentException { ComponentConfig cc = ComponentConfig.getComponentConfig(componentName); if (cc == null) { @@ -339,6 +355,7 @@ public class ComponentConfig { protected List<TestSuiteInfo> testSuiteInfos = FastList.newInstance(); protected List<KeystoreInfo> keystoreInfos = FastList.newInstance(); protected List<WebappInfo> webappInfos = FastList.newInstance(); + protected List<ContainerConfig.Container> containers = FastList.newInstance(); protected ComponentConfig() {} @@ -423,6 +440,13 @@ public class ComponentConfig { this.webappInfos.add(webappInfo); } + // containers + try { + this.containers.addAll(ContainerConfig.getContainers(xmlUrl)); + } catch(ContainerException ce) { + throw new ComponentException("Error reading containers for component: " + this.globalName, ce); + } + if (Debug.verboseOn()) Debug.logVerbose("Read component config : [" + rootLocation + "]", module); } @@ -552,6 +576,10 @@ public class ComponentConfig { return this.webappInfos; } + public List<ContainerConfig.Container> getContainers() { + return this.containers; + } + public boolean enabled() { return this.enabled; } 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=1354884&r1=1354883&r2=1354884&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 Thu Jun 28 09:31:37 2012 @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.ofbiz.base.component.ComponentConfig; import org.ofbiz.base.start.Config; import org.ofbiz.base.start.StartupException; import org.ofbiz.base.start.StartupLoader; @@ -118,6 +119,12 @@ public class ContainerLoader implements if (this.unloading) { return; } + List<ContainerConfig.Container> containersDefinedInComponents = ComponentConfig.getAllContainers(); + for (ContainerConfig.Container containerCfg: containersDefinedInComponents) { + Container tmpContainer = loadContainer(containerCfg, args); + this.loadedContainers.add(tmpContainer); + containerMap.put(containerCfg.name, tmpContainer); + } // Get hot-deploy container configuration files ClassLoader loader = Thread.currentThread().getContextClassLoader(); Enumeration<URL> resources;