Re: [plexus-scm] [7221] plexus-containers/trunk/plexus-container-default/src/main/aspect/org/codehaus/plexus/aspect/CompatibilityAspect.aj: Adding a compat aspect to restore lost methods for creating child containers.

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: [plexus-scm] [7221] plexus-containers/trunk/plexus-container-default/src/main/aspect/org/codehaus/plexus/aspect/CompatibilityAspect.aj: Adding a compat aspect to restore lost methods for creating child containers.

by Jason van Zyl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is this for 2.0.x compatibility?

Does this need to be an aspect? Or would it make more sense to just  
put the signature back?

On 21-Feb-08, at 7:20 PM, jdcasey@... wrote:

> 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
>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------

People develop abstractions by generalizing from concrete examples.
Every attempt to determine the correct abstraction on paper without
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  
examples
you look at, the more general your framework will be.

-- Ralph Johnson & Don Roberts, Patterns for Evolving Frameworks




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email