cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <alexander.klimetsc...@mindquarry.com>
Subject Re: Shielded class loading between blocks
Date Mon, 20 Nov 2006 12:38:39 GMT
Another requirement what just popped up is to allow "groups" of servlets 
that use the same classloader. This is useful if you have some Servlets 
and jsps that ought to be used together, because the multiple Servlets 
and JSPs access some singleton / static Java class. Here it is necessary 
that all servlets and stuff are loaded by the same classloader.

A simple idea would be to pass the BlockServlet (that will manage the 
shielding) a parameter "shieldingGroup" that will name a group that uses 
the same classloader. There should be some kind of static Map which maps 
that groupname to a classloader so that it can be reused when another 
BlockServlet with the same groupname comes up.

WDYT?

Alex


Carsten Ziegeler schrieb:
> Alexander Klimetschek wrote:
>> The optimal solution would be the OSGi support (!?), but this is too 
>> much work and won't be part of cocoon 2.2. My patch is a lot simpler, 
>> just fixing the BootstrapClassLoaderManager and the blocks-fw (where I 
>> just implemented the not-yet implemented methods of those servlet 
>> interfaces). Then it is just a simple configuration of the block servlet 
>> using the ShieldingServlet. Here is the xml snippet, the full config can 
>> be found in the jira issue:
>>
>>
>> <bean id="my-block"
>>    class="org.apache.cocoon.blocks.BlockServlet">
>>    <property name="mountPath" value="/my-block" />
>>
>>    <property name="servletClass"
>>      value="org.apache.cocoon.bootstrap.servlet.ShieldingServlet" />
>>
>>    <property name="blockContextURL"
>>      value="blockcontext:/mindquarry-solr-block/" />
>>
>>    <property name="properties">
>>      <map>
>>        <entry key="servlet-class"
>>          value="org.apache.cocoon.sitemap.SitemapServlet" />
>>        <entry key="bootstrap-classpath-file"
>>          value="/paranoid-classpath.txt" />
>>        <entry key="bootstrap-classloader-debug" value="true" />
>>        <entry key="bootstrap-classloader-factory"
>>        value="org.apache.cocoon.classloader.DefaultClassLoaderFactory" />
>>      </map>
>>    </property>
>> </bean>
>>
>>
>> So can this made be simpler? Having standard paths in the block 
>> directory for the shielded libs and some config option to enable 
>> shielding, which could be integrated directly in the BlockServlet?
>>
> Hmm, yes, what about directly adding the support to the BlockServlet
> (where imho it belongs):
> 
> <bean id="my-block" class="org.apache.cocoon.blocks.BlockServlet">
>     <property name="mountPath" value="/my-block" />
> 
>     <property name="blockContextURL"
>       value="blockcontext:/mindquarry-solr-block/" />
> 
>     <property name="properties">
>       <map>
>         <entry key="classpath-file"
>           value="/paranoid-classpath.txt" />
>         <entry key="classloader-debug" value="true" />
>         <entry key="classloader-factory"
>         value="org.apache.cocoon.classloader.DefaultClassLoaderFactory"
> 
>       </map>
>     </property>
>  </bean>
> 
> And yes, I think this should support some default paths, like
> {blockdir}/config/libs and {blockdir}/config/classes.
> 
> Carsten


-- 
Alexander Klimetschek
http://www.mindquarry.com


Mime
View raw message