avalon-phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Krieg" <dkr...@kc.rr.com>
Subject Re: Phoenix and the Web
Date Mon, 07 Oct 2002 12:48:55 GMT

>> I am currently reworking some of my implementation of CatalinaSevak..
>> current version skips the Phoenix class loader and goes directly to the
>> SystemLoader.  This causes ClassLoader problems when other Blocks in the
>> same SAR try to interoperate.  I have modified my approach (use
>> PhoenixClassLoader) and seem to be able to create Avalon compliant
>> to wrap the Catalina implementations.

>The problem is that Phoenix ClassLoader system does not allow you to easily
>modify ClassLoader hierarchies. I am currently in the process of adding in
>support for this and you can see the early documentation at
>which actually talks about setting up a ClassLoader hierarchy for a Servlet
>Theres about 2-3 hours work left to finish off the implementation and test
>cases. However probably a bit more time to actually document it properly.
>Have a look at the web pages and tell me if they help you and if not - what
>need to do to make it easier to use/understand.
The way I tackled this...a bit of a hack perhaps...is to use URLClassLoader
to create a ClassLoader that points to Catalina's bootstrap.jar which
contains Catalina's StandardClassLoader, load this class and create an
instance of it (StandardClassLoader) using reflection, and establish the
classpaths for this ClassLoader instance.  This seems to be working.  How
does Phoenix's ClassLoader complicate modifying ClassLoader
hierarchies...what problems should I watch out for?

    private ClassLoader createClassLoader( File unpacked[], File packed[],
ClassLoader parent ) throws Exception {
        getLogger().debug( "Creating new class loader" );

        // Construct the "class path" for this class loader
        // Construct the class loader itself
        String[] classPath = (String[]) stringList.toArray( new String[
stringList.size() ] );
        URL[] urlArray = (URL[]) urlList.toArray( new URL[
urlList.size() ] );
        Class loaderClass = ( parent == null ) ?
URLClassLoader.newInstance( urlArray ).loadClass(
"org.apache.catalina.loader.StandardClassLoader" )
                : URLClassLoader.newInstance( urlArray,
parent ).loadClass( "org.apache.catalina.loader.StandardClassLoader" );

        getLogger().debug( loaderClass.getName() + " successfully
loaded." );
        Object loader = null;

        if( parent == null ) {
            loader = loaderClass.getConstructor( new
Class[]{classPath.getClass()} )
                    .newInstance( new Object[]{classPath} );
        } else {
            loader = loaderClass.getConstructor( new
Class[]{classPath.getClass(), ClassLoader.class} )
                    .newInstance( new Object[]{classPath, parent} );

        getLogger().debug( "Setting loader to delegate=true" );
        Method delegating = loader.getClass().getMethod( "setDelegate", new
Class[]{Boolean.TYPE} );
        delegating.invoke( loader, new Object[]{Boolean.TRUE} );
        getLogger().debug( "Class Loader Intance: " + loader );

        getLogger().debug( "ClassLoader creation completed..." );
        return (ClassLoader) loader;

>>  In doing so, I must delegate the
>> lifecycle from one class to another, i.e. CatalinaSevak contains
>> CatalinaSevakServer contains CatalinaSevakService, etc.  Is it
>> common/accepted to allow this brand of containmnet within Avalon or is it
>> discouraged?

>I am not actually sure what you mean. Would you be able to point me at a
public class CatalinaSevakServer extends CatalinaSevakLogEnabled
            implements Lifecycle, Server, Configurable, Serviceable,
    private CatalinaSevakService m_service;
    public void configure(Configuration configuration) throws
ConfigurationException {
            Configuration[] children = m_configuration.getChildren();
            for (int i = 0; i < children.length; i++) {
                Configuration child = children[i];
                final String name = child.getName();
                } else if(name.equals("Service")) {
                    m_service = new CatalinaSevakService();
                    ContainerUtil.service(m_service, m_serviceManager);
                    ContainerUtil.configure(m_service, child);
                    getSevakLogger().debug("Service Added: " +
        getSevakLogger().debug("CatalinaSevakServer configured...");

To unsubscribe, e-mail:   <mailto:avalon-phoenix-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-phoenix-dev-help@jakarta.apache.org>

View raw message