> Revision7221AuthorjdcaseyDate2008-02-21 21:20:29 -0600 (Thu, 21 Feb
> 2008)Log Message
> Adding a compat aspect to restore lost methods for creating child
> containers.
> Added Paths
> • plexus-containers/trunk/plexus-container-default/src/main/aspect/
> org/codehaus/plexus/aspect/CompatibilityAspect.aj
> Diff
> Added: plexus-containers/trunk/plexus-container-default/src/main/
> aspect/org/codehaus/plexus/aspect/CompatibilityAspect.aj (0 => 7221)
> --- plexus-containers/trunk/plexus-container-default/src/main/aspect/
> org/codehaus/plexus/aspect/
> CompatibilityAspect.aj (rev 0)
> +++ plexus-containers/trunk/plexus-container-default/src/main/aspect/
> org/codehaus/plexus/aspect/CompatibilityAspect.aj 2008-02-22
> 03:20:29 UTC (rev 7221)
> @@ -0,0 +1,72 @@
> +package org.codehaus.plexus.aspect;
> +
> +import org.codehaus.plexus.classworlds.ClassWorld;
> +import org.codehaus.plexus.classworlds.realm.ClassRealm;
> +import
> org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
> +import org.codehaus.plexus.DefaultContainerConfiguration;
> +import org.codehaus.plexus.ContainerConfiguration;
> +import org.codehaus.plexus.DefaultPlexusContainer;
> +import org.codehaus.plexus.PlexusContainerException;
> +import org.codehaus.plexus.DuplicateChildContainerException;
> +import org.codehaus.plexus.PlexusContainer;
> +
> +import java.io.File;
> +import java.net.MalformedURLException;
> +import java.util.Collections;
> +import java.util.Iterator;
> +import java.util.List;
> +import java.util.Map;
> +
> +public aspect CompatibilityAspect
> +{
> +
> + public PlexusContainer
> PlexusContainer.createChildContainer( String name,
> + List classpath,
> + Map context )
> + throws PlexusContainerException
> + {
> + return createChildContainer( name, classpath, context,
> Collections.EMPTY_LIST );
> + }
> +
> + public PlexusContainer
> PlexusContainer.createChildContainer( String name,
> + List classpath,
> + Map context,
> + List
> discoveryListeners )
> + throws PlexusContainerException
> + {
> + if ( hasChildContainer( name ) )
> + {
> + throw new DuplicateChildContainerException( getName(),
> name );
> + }
> +
> + ClassRealm realm = new ClassRealm( new ClassWorld(), name );
> + for ( Iterator it = classpath.iterator(); it.hasNext(); )
> + {
> + File jar = (File) it.next();
> + try
> + {
> + realm.addURL( jar.toURI().toURL() );
> + }
> + catch ( MalformedURLException e )
> + {
> + throw new PlexusContainerException( "Cannot add jar
> resource: " + jar + " (bad URL)", e );
> + }
> + }
> +
> + ContainerConfiguration config = new
> DefaultContainerConfiguration();
> +
> + config.setRealm( realm );
> + config.setName( name );
> + config.setParentContainer( this );
> + config.setContext( context );
> +
> + for ( Iterator it = discoveryListeners.iterator();
> it.hasNext(); )
> + {
> + ComponentDiscoveryListener listener =
> (ComponentDiscoveryListener) it.next();
> + config.addComponentDiscoveryListener( listener );
> + }
> +
> + return new DefaultPlexusContainer( config );
> + }
> +
> +}
>
> To unsubscribe from this list please visit:
>
>
http://xircles.codehaus.org/manage_email>
actually developing a running system is doomed to failure. No one
is that smart. A framework is a resuable design, so you develop it by
looking at the things it is supposed to be a design of. The more