Ok,

the first step is now completed, see commit revisions:
1354884 - containers can be defined by components
1355460 - added ability to define "loaders" for loading selectively specific 
containers defined in components
1355466 - moved some containers to their component

Now the next step is to move the two catalina containers (the standard one and 
the one, with different ports, for tests) to the catalina component; but before 
I can do this we need the ability to define more than one catalina containers 
with different names; unfortunately the existing container names are hardcoded 
into the container classes (and this is one of the causes of the proliferation 
of specialized *-containers.xml files). However I have a patch that works fine 
that changes the Container interface (and all the implementations) to pass the 
name of the Container; here is a part of the patch with the change to the 
interface and one of the containers:

Index: framework/base/src/org/ofbiz/base/container/Container.java
===================================================================
--- framework/base/src/org/ofbiz/base/container/Container.java  (revision 
1355460)
+++ framework/base/src/org/ofbiz/base/container/Container.java  (working copy)
@@ -40,12 +40,13 @@
      * should initialize internal structures and then return.
      *
      * @param args Command-line arguments.
+     * @param name Unique name of the container's instance.
      * @param configFile Location of the configuration file used to load this 
container.
      * @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(String[] args, String configFile) throws 
ContainerException;
+    public void init(String[] args, String name, String configFile) throws 
ContainerException;
 
     /**
      * Start the container process. This method must not block - 
implementations
Index: 
framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java
===================================================================
--- framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java  
(revision 1355460)
+++ framework/catalina/src/org/ofbiz/catalina/container/CatalinaContainer.java  
(working copy)
@@ -174,9 +174,9 @@
     /**
      * @see org.ofbiz.base.container.Container#init(java.lang.String[], 
java.lang.String)
      */
-    public void init(String[] args, String configFile) throws 
ContainerException {
+    public void init(String[] args, String name, String configFile) throws 
ContainerException {
         // get the container config
-        ContainerConfig.Container cc = 
ContainerConfig.getContainer("catalina-container", configFile);
+        ContainerConfig.Container cc = ContainerConfig.getContainer(name, 
configFile);
         if (cc == null) {
             throw new ContainerException("No catalina-container configuration 
found in container config!");
         }


I am planning to commit this changes over the weekend so please let me know if 
you see something wrong (but I am rather confident this is the way to go).

Thanks,

Jacopo


On Jun 28, 2012, at 3:46 PM, Jacopo Cappellato wrote:

> Yes, thank you I appreciate the advices; I think I have actually considered 
> the most important architectural changes and we should be fine (I have spent 
> a considerable amount of time studying this code): the containers are stared 
> by the same method they used to even if they are defined in different files.
> But I will keep you posted... once completed I think it will be a really nice 
> feature and will be a (small) step ahead in the modularization of the 
> framework.
> 
> Regards,
> 
> Jacopo
> 
> 
> On Jun 28, 2012, at 3:41 PM, Adrian Crum wrote:
> 
>> Thank you for the info. I was commenting on the whole approach, not the 
>> specific problem.
>> 
>> I remember troubleshooting some problems with container loading a while ago. 
>> The startup process can be tricky, and things like premature shutdown 
>> (during container loading) need to be considered.
>> 
>> I don't have any specific advice, just a word of caution that it might not 
>> be as simple as it seems.
>> 
>> -Adrian
>> 
>> On 6/28/2012 2:33 PM, Jacopo Cappellato wrote:
>>> Adding some more details: you can already move birt/catalina/jetty from 
>>> ofbiz-containers.xml to their own ofbiz-component.xml and the system 
>>> willwork fine; the only probalem I am fixing now is that if you start ofbiz 
>>> in limited mode (tests, pos, rmi etc..) and you still want to load the 
>>> components but not their containers then you may get some errors: I am 
>>> working on a solution right now.
>>> 
>>> Jacopo
>>> 
>>> On Jun 28, 2012, at 3:27 PM, Jacopo Cappellato wrote:
>>> 
>>>> Well, actually the problem is less difficult to resolve: I simply need to 
>>>> find a good mechanism to disable the the birt container (or any other 
>>>> component container) based on some startup settings (at the moment we use 
>>>> different *-containers.xml files)... I am working on a better mechanism, 
>>>> it shouldn't be too difficult.
>>>> 
>>>> Jacopo
>>>> 
>>>> On Jun 28, 2012, at 3:13 PM, Adrian Crum wrote:
>>>> 
>>>>> It seems to me there is a chicken and the egg scenario here. You're 
>>>>> trying to load containers via component configuration, but the component 
>>>>> configuration files are loaded by a container.
>>>>> 
>>>>> Do we know why Birt requires a container?
>>>>> 
>>>>> -Adrian
>>>>> 
>>>>> On 6/28/2012 11:35 AM, [email protected] wrote:
>>>>>> Author: jacopoc
>>>>>> Date: Thu Jun 28 10:35:33 2012
>>>>>> New Revision: 1354905
>>>>>> 
>>>>>> URL: http://svn.apache.org/viewvc?rev=1354905&view=rev
>>>>>> Log:
>>>>>> This (temporarily) reverts my last commit 1354885: I still have to 
>>>>>> figure out a few things (how to selectively enable/disable containers at 
>>>>>> startup)
>>>>>> 
>>>>>> Modified:
>>>>>>   ofbiz/trunk/framework/base/config/ofbiz-containers.xml
>>>>>>   ofbiz/trunk/framework/birt/ofbiz-component.xml
>>>>>> 
>>>>>> Modified: ofbiz/trunk/framework/base/config/ofbiz-containers.xml
>>>>>> URL: 
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/config/ofbiz-containers.xml?rev=1354905&r1=1354904&r2=1354905&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/framework/base/config/ofbiz-containers.xml (original)
>>>>>> +++ ofbiz/trunk/framework/base/config/ofbiz-containers.xml Thu Jun 28 
>>>>>> 10:35:33 2012
>>>>>> @@ -235,6 +235,9 @@ under the License.
>>>>>>        </property>
>>>>>>    </container>
>>>>>> +    <!-- load the BIRT container -->
>>>>>> +    <container name="birt-container" 
>>>>>> class="org.ofbiz.birt.container.BirtContainer"/>
>>>>>> +
>>>>>>    <!-- load BeanShell remote telnet server -->
>>>>>>    <!-- Commented out by default for security reasons -->
>>>>>>    <!-- the port below and port-1 will be opened by Beanshell -->
>>>>>> 
>>>>>> Modified: ofbiz/trunk/framework/birt/ofbiz-component.xml
>>>>>> URL: 
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/birt/ofbiz-component.xml?rev=1354905&r1=1354904&r2=1354905&view=diff
>>>>>> ==============================================================================
>>>>>> --- ofbiz/trunk/framework/birt/ofbiz-component.xml (original)
>>>>>> +++ ofbiz/trunk/framework/birt/ofbiz-component.xml Thu Jun 28 10:35:33 
>>>>>> 2012
>>>>>> @@ -26,8 +26,4 @@ under the License.
>>>>>>    <classpath type="jar" location="build/lib/*"/>
>>>>>>    <classpath type="dir" location="config"/>
>>>>>>    <service-resource type="model" loader="main" 
>>>>>> location="servicedef/services.xml"/>
>>>>>> -
>>>>>> -    <!-- load the BIRT container -->
>>>>>> -    <container name="birt-container" 
>>>>>> class="org.ofbiz.birt.container.BirtContainer"/>
>>>>>> -
>>>>>> </ofbiz-component>
>>>>>> 
>>>>>> 
>>>>> 
>> 
>> 
> 

Reply via email to