Examples of PlexusContainer


Examples of org.codehaus.plexus.PlexusContainer

    }

    private void releaseWagon( String protocol,
                               Wagon wagon )
    {
        PlexusContainer container = getWagonContainer( protocol );
        try
        {
            container.release( wagon );
        }
        catch ( ComponentLifecycleException e )
        {
            getLogger().error( "Problem releasing wagon - ignoring: " + e.getMessage() );
        }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

     * instantiation/composition problem.
     */
    public void contextualize( final Context context )
        throws ContextException
    {
        final PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );

        try
        {
            archiverManager = (ArchiverManager) container.lookup( ArchiverManager.ROLE );
        }
        catch ( final ComponentLookupException e )
        {
            throw new ContextException( "Error retrieving ArchiverManager instance: " + e.getMessage(), e );
        }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

     * instantiation/composition problem.
     */
    public void contextualize( final Context context )
        throws ContextException
    {
        final PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );

        try
        {
            archiverManager = (ArchiverManager) container.lookup( ArchiverManager.ROLE );
        }
        catch ( final ComponentLookupException e )
        {
            throw new ContextException( "Error retrieving ArchiverManager instance: " + e.getMessage(), e );
        }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

        // This is what we will generalize for the invocation of the command line.
        // ----------------------------------------------------------------------------

        try
        {
            PlexusContainer plexus = new DefaultPlexusContainer( "plexus.core", classWorld );

            invokePlexusComponent( cli, plexus );
        }
        catch ( PlexusContainerException e )
        {
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

                              Artifact pluginArtifact,
                              MavenProject project,
                              ArtifactRepository localRepository )
        throws PluginManagerException, InvalidPluginException
    {
        PlexusContainer child;

        try
        {
            MavenPluginValidator validator = new MavenPluginValidator( pluginArtifact );

            String key = PluginUtils.constructVersionedKey( plugin ).intern();
            child = container.createChildContainer( key,
                                                    Collections.singletonList( pluginArtifact.getFile() ),
                                                    Collections.EMPTY_MAP,
                                                    Arrays.asList( new ComponentDiscoveryListener[] { validator, pluginCollector } ) );

            // remove listeners for efficiency since they are only needed for the initial stage and
            // should not be applied to the plugin's dependencies
            child.removeComponentDiscoveryListener( validator );
            child.removeComponentDiscoveryListener( pluginCollector );

            if ( validator.hasErrors() )
            {
                String msg = "Plugin '" + key + "' has an invalid descriptor:";
                int count = 1;
                for ( Iterator i = validator.getErrors().iterator(); i.hasNext(); )
                {
                    msg += "\n" + count + ") " + i.next();
                    count++;
                }
                throw new PluginManagerException( msg );
            }

            try
            {
                child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.Xpp3Dom" );
                child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlPullParser" );
                child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlPullParserException" );
                child.getContainerRealm().importFrom( "plexus.core", "org.codehaus.plexus.util.xml.pull.XmlSerializer" );

                // MNG-2878
                child.getContainerRealm().importFrom( "plexus.core", "/default-report.xml" );
            }
            catch ( NoSuchRealmException e )
            {
                // won't happen
            }
        }
        catch ( PlexusContainerException e )
        {
            throw new PluginManagerException(
                "Failed to create plugin container for plugin '" + plugin + "': " + e.getMessage(), e );
        }

        // this plugin's descriptor should have been discovered in the child creation, so we should be able to
        // circle around and set the artifacts and class realm
        PluginDescriptor addedPlugin = pluginCollector.getPluginDescriptor( plugin );

        if ( addedPlugin == null )
        {
            throw new IllegalStateException( "The plugin descriptor for the plugin " + plugin + " was not found."
                + " Please verify that the plugin JAR " + pluginArtifact.getFile() + " is intact." );
        }

        addedPlugin.setClassRealm( child.getContainerRealm() );

        // we're only setting the plugin's artifact itself as the artifact list, to allow it to be retrieved
        // later when the plugin is first invoked. Retrieving this artifact will in turn allow us to
        // transitively resolve its dependencies, and add them to the plugin container...
        addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) );
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

            Thread.currentThread().setContextClassLoader( oldClassLoader );

            try
            {
                PlexusContainer pluginContainer = getPluginContainer( mojoDescriptor.getPluginDescriptor() );

                pluginContainer.release( plugin );
            }
            catch ( ComponentLifecycleException e )
            {
                if ( getLogger().isErrorEnabled() )
                {
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

    private PlexusContainer getPluginContainer( PluginDescriptor pluginDescriptor )
        throws PluginManagerException
    {
        String pluginKey = PluginUtils.constructVersionedKey( pluginDescriptor );

        PlexusContainer pluginContainer = container.getChildContainer( pluginKey );

        if ( pluginContainer == null )
        {
            throw new PluginManagerException( "Cannot find Plexus container for plugin: " + pluginKey );
        }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

    {
        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();

        PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();

        PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );

        // if this is the first time this plugin has been used, the plugin's container will only
        // contain the plugin's artifact in isolation; we need to finish resolving the plugin's
        // dependencies, and add them to the container.
        ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session );

        Mojo plugin;
        try
        {
            plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
            if ( report && !( plugin instanceof MavenReport ) )
            {
                // TODO: the mojoDescriptor should actually capture this information so we don't get this far
                return null;
            }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

                                      String roleHint )
        throws PluginManagerException, ComponentLookupException
    {
        PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );

        PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );
       
        return pluginContainer.lookup( role, roleHint );
    }
View Full Code Here

Examples of org.codehaus.plexus.PlexusContainer

                                    String role )
        throws ComponentLookupException, PluginManagerException
    {
        PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );

        PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );
       
        Set<String> pluginHints = findChildComponentHints( role, container, pluginContainer );
        Map<String, Object> components = new HashMap<String, Object>( pluginHints.size() );
        for ( String hint : pluginHints )
        {
            getLogger().debug( "Looking up plugin component: " + role + " with hint: " + hint );
            components.put( hint, pluginContainer.lookup( role, hint ) );
        }

        return components;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.