Examples of PlexusContainerAdapter


Examples of org.codehaus.plexus.spring.PlexusContainerAdapter

        PlexusClassPathXmlApplicationContext classPathApplicationContext = new PlexusClassPathXmlApplicationContext(
            new String[]{"classpath*:/META-INF/spring-context.xml", "classpath*:/META-INF/plexus/components.xml",
                "classpath*:/META-INF/plexus/plexus.xml"} );

        PlexusContainerAdapter container = new PlexusContainerAdapter();
        container.setApplicationContext( classPathApplicationContext );

        initializeWagon( container, setting );

        List<Artifact> artifacts = new ArrayList<Artifact>();
        artifacts.addAll(
            downloadArtifact( container, params.getGroupId(), params.getArtifactId(),
                                            params.getVersion(), setting ) );
        artifacts.addAll(
            downloadArtifact( container, "org.apache.continuum", managementArtifactId,
                                            applicationVersion, setting ) );
        artifacts.addAll( downloadArtifact( container, "jpox", "jpox", databaseFormat.getJpoxVersion(), setting ) );

        List<String> jars = new ArrayList<String>();

        // Little hack to make it work more nicely in the IDE
        List<String> exclusions = new ArrayList<String>();
        URLClassLoader cp = (URLClassLoader) DataManagementCli.class.getClassLoader();
        List<URL> jarUrls = new ArrayList<URL>();

        for ( URL url : cp.getURLs() )
        {
            String urlEF = url.toExternalForm();
            if ( urlEF.endsWith( "target/classes/" ) )
            {
                int idEndIdx = urlEF.length() - 16;
                String id = urlEF.substring( urlEF.lastIndexOf( '/', idEndIdx - 1 ) + 1, idEndIdx );
                // continuum-legacy included because the IDE doesn't do the proper assembly of enhanced classes and JDO metadata
                if ( !"data-management-api".equals( id ) && !"data-management-cli".equals( id ) &&
                    !"continuum-legacy".equals( id ) && !"continuum-model".equals( id ) &&
                    !"redback-legacy".equals( id ) )
                {
                    LOGGER.debug( "[IDE Help] Adding '" + id + "' as an exclusion and using one from classpath" );
                    exclusions.add( "org.apache.continuum:" + id );
                    jars.add( url.getPath() );
                    jarUrls.add( url );
                }
            }

            // Sometimes finds its way into the IDE. Make sure it is loaded in the extra classloader too
            if ( urlEF.contains( "jpox-enhancer" ) )
            {
                LOGGER.debug( "[IDE Help] Adding 'jpox-enhancer' as an exclusion and using one from classpath" );
                jars.add( url.getPath() );
                jarUrls.add( url );
            }
        }

        ArtifactFilter filter = new ExcludesArtifactFilter( exclusions );

        for ( Artifact a : artifacts )
        {
            if ( "jpox".equals( a.getGroupId() ) && "jpox".equals( a.getArtifactId() ) )
            {
                if ( a.getVersion().equals( databaseFormat.getJpoxVersion() ) )
                {
                    LOGGER.debug( "Adding artifact: " + a.getFile() );
                    jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + SPRING_CONTEXT_LOC );
                    jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + PLEXUS_XML_LOC );
                    jarUrls.add( new URL( FILE_PREFIX + a.getFile().getAbsolutePath() ) );
                }
            }
            else if ( filter.include( a ) )
            {
                LOGGER.debug( "Adding artifact: " + a.getFile() );
                jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + SPRING_CONTEXT_LOC );
                jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + PLEXUS_XML_LOC );
                jarUrls.add( new URL( FILE_PREFIX + a.getFile().getAbsolutePath() ) );
            }
        }

        URLClassLoader newClassLoader = new URLClassLoader( (URL[]) jarUrls.toArray( new URL[jarUrls.size()] ), cp );
        Thread.currentThread().setContextClassLoader( newClassLoader );
        classPathApplicationContext.setClassLoader( newClassLoader );

        PlexusFileSystemXmlApplicationContext fileSystemApplicationContext = new PlexusFileSystemXmlApplicationContext(
             (String[]) jars.toArray( new String[jars.size()] ), classPathApplicationContext );
        fileSystemApplicationContext.setClassLoader( newClassLoader );
        container.setApplicationContext( fileSystemApplicationContext );

        DatabaseFactoryConfigurator configurator = (DatabaseFactoryConfigurator) container.lookup(
                                DatabaseFactoryConfigurator.class.getName(), configRoleHint );
        configurator.configure( params );

        DataManagementTool manager =
            (DataManagementTool) container.lookup( DataManagementTool.class.getName(), toolRoleHint );

        if ( mode == OperationMode.EXPORT )
        {
            manager.backupDatabase( directory );
        }
View Full Code Here

Examples of org.codehaus.plexus.spring.PlexusContainerAdapter

        PlexusClassPathXmlApplicationContext classPathApplicationContext = new PlexusClassPathXmlApplicationContext(
            new String[]{"classpath*:/META-INF/spring-context.xml", "classpath*:/META-INF/plexus/components.xml",
                "classpath*:/META-INF/plexus/plexus.xml"} );

        PlexusContainerAdapter container = new PlexusContainerAdapter();
        container.setApplicationContext( classPathApplicationContext );

        initializeWagon( container, setting );

        List<Artifact> artifacts = new ArrayList<Artifact>();
        artifacts.addAll( downloadArtifact( container, params.getGroupId(), params.getArtifactId(), params.getVersion(),
                                            setting ) );
        artifacts.addAll( downloadArtifact( container, "org.apache.continuum", managementArtifactId, applicationVersion,
                                            setting ) );
        artifacts.addAll( downloadArtifact( container, "jpox", "jpox", databaseFormat.getJpoxVersion(), setting ) );

        List<String> jars = new ArrayList<String>();

        // Little hack to make it work more nicely in the IDE
        List<String> exclusions = new ArrayList<String>();
        URLClassLoader cp = (URLClassLoader) DataManagementCli.class.getClassLoader();
        List<URL> jarUrls = new ArrayList<URL>();

        for ( URL url : cp.getURLs() )
        {
            String urlEF = url.toExternalForm();
            if ( urlEF.endsWith( "target/classes/" ) )
            {
                int idEndIdx = urlEF.length() - 16;
                String id = urlEF.substring( urlEF.lastIndexOf( '/', idEndIdx - 1 ) + 1, idEndIdx );
                // continuum-legacy included because the IDE doesn't do the proper assembly of enhanced classes and JDO metadata
                if ( !"data-management-api".equals( id ) && !"data-management-cli".equals( id ) &&
                    !"continuum-legacy".equals( id ) && !"continuum-model".equals( id ) &&
                    !"redback-legacy".equals( id ) )
                {
                    LOGGER.debug( "[IDE Help] Adding '" + id + "' as an exclusion and using one from classpath" );
                    exclusions.add( "org.apache.continuum:" + id );
                    jars.add( url.getPath() );
                    jarUrls.add( url );
                }
            }

            // Sometimes finds its way into the IDE. Make sure it is loaded in the extra classloader too
            if ( urlEF.contains( "jpox-enhancer" ) )
            {
                LOGGER.debug( "[IDE Help] Adding 'jpox-enhancer' as an exclusion and using one from classpath" );
                jars.add( url.getPath() );
                jarUrls.add( url );
            }
        }

        ArtifactFilter filter = new ExcludesArtifactFilter( exclusions );

        for ( Artifact a : artifacts )
        {
            if ( "jpox".equals( a.getGroupId() ) && "jpox".equals( a.getArtifactId() ) )
            {
                if ( a.getVersion().equals( databaseFormat.getJpoxVersion() ) )
                {
                    LOGGER.debug( "Adding artifact: " + a.getFile() );
                    jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + SPRING_CONTEXT_LOC );
                    jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + PLEXUS_XML_LOC );
                    jarUrls.add( new URL( FILE_PREFIX + a.getFile().getAbsolutePath() ) );
                }
            }
            else if ( filter.include( a ) )
            {
                LOGGER.debug( "Adding artifact: " + a.getFile() );
                jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + SPRING_CONTEXT_LOC );
                jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + PLEXUS_XML_LOC );
                jarUrls.add( new URL( FILE_PREFIX + a.getFile().getAbsolutePath() ) );
            }
        }

        URLClassLoader newClassLoader = new URLClassLoader( (URL[]) jarUrls.toArray( new URL[jarUrls.size()] ), cp );
        Thread.currentThread().setContextClassLoader( newClassLoader );
        classPathApplicationContext.setClassLoader( newClassLoader );

        PlexusFileSystemXmlApplicationContext fileSystemApplicationContext = new PlexusFileSystemXmlApplicationContext(
            (String[]) jars.toArray( new String[jars.size()] ), classPathApplicationContext );
        fileSystemApplicationContext.setClassLoader( newClassLoader );
        container.setApplicationContext( fileSystemApplicationContext );

        DatabaseFactoryConfigurator configurator = (DatabaseFactoryConfigurator) container.lookup(
            DatabaseFactoryConfigurator.class.getName(), configRoleHint );
        configurator.configure( params );

        DataManagementTool manager = (DataManagementTool) container.lookup( DataManagementTool.class.getName(),
                                                                            toolRoleHint );

        if ( mode == OperationMode.EXPORT )
        {
            manager.backupDatabase( directory );
View Full Code Here

Examples of org.codehaus.plexus.spring.PlexusContainerAdapter

     * @see org.springframework.context.support.AbstractApplicationContext#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
     */
    protected void postProcessBeanFactory( ConfigurableListableBeanFactory beanFactory, ApplicationContext context )
    {
        // Register a PlexusContainerAdapter bean to allow context lookups using plexus API
        PlexusContainerAdapter plexus = new PlexusContainerAdapter();
        plexus.setApplicationContext( context );
        beanFactory.registerSingleton( "plexusContainer", plexus );

        // Register a beanPostProcessor to handle plexus interface-based lifecycle management
        lifecycleBeanPostProcessor = new PlexusLifecycleBeanPostProcessor();
        lifecycleBeanPostProcessor.setBeanFactory( context );
View Full Code Here

Examples of org.codehaus.plexus.spring.PlexusContainerAdapter

    }

    public void testProfiles()
        throws IOException, ConsumerException, ParserConfigurationException, SAXException
    {
        PlexusContainerAdapter container = new PlexusContainerAdapter();
        container.setApplicationContext( getApplicationContext() );
       
        consumer.beginScan( repository, null );

        String path = "org/apache/maven/surefire/surefire-testng/2.0/surefire-testng-2.0.pom";
        consumer.processFile( path );
View Full Code Here

Examples of org.codehaus.plexus.spring.PlexusContainerAdapter

    }

    public void testProfiles()
        throws IOException, ConsumerException, ParserConfigurationException, SAXException
    {
        PlexusContainerAdapter container = new PlexusContainerAdapter();
        container.setApplicationContext( getApplicationContext() );
       
        DefaultProfileManager m = new DefaultProfileManager( container );
       
        consumer.beginScan( repository, null );
View Full Code Here

Examples of org.codehaus.plexus.spring.PlexusContainerAdapter

        PlexusClassPathXmlApplicationContext classPathApplicationContext = new PlexusClassPathXmlApplicationContext(
            new String[]{"classpath*:/META-INF/spring-context.xml", "classpath*:/META-INF/plexus/components.xml",
                "classpath*:/META-INF/plexus/plexus.xml"} );

        PlexusContainerAdapter container = new PlexusContainerAdapter();
        container.setApplicationContext( classPathApplicationContext );

        initializeWagon( container, setting );

        List<Artifact> artifacts = new ArrayList<Artifact>();
        artifacts.addAll(
            downloadArtifact( container, params.getGroupId(), params.getArtifactId(),
                                            params.getVersion(), setting ) );
        artifacts.addAll(
            downloadArtifact( container, "org.apache.continuum", managementArtifactId,
                                            applicationVersion, setting ) );
        artifacts.addAll( downloadArtifact( container, "jpox", "jpox", databaseFormat.getJpoxVersion(), setting ) );

        List<String> jars = new ArrayList<String>();

        // Little hack to make it work more nicely in the IDE
        List<String> exclusions = new ArrayList<String>();
        URLClassLoader cp = (URLClassLoader) DataManagementCli.class.getClassLoader();
        List<URL> jarUrls = new ArrayList<URL>();

        for ( URL url : cp.getURLs() )
        {
            String urlEF = url.toExternalForm();
            if ( urlEF.endsWith( "target/classes/" ) )
            {
                int idEndIdx = urlEF.length() - 16;
                String id = urlEF.substring( urlEF.lastIndexOf( '/', idEndIdx - 1 ) + 1, idEndIdx );
                // continuum-legacy included because the IDE doesn't do the proper assembly of enhanced classes and JDO metadata
                if ( !"data-management-api".equals( id ) && !"data-management-cli".equals( id ) &&
                    !"continuum-legacy".equals( id ) && !"continuum-model".equals( id ) &&
                    !"redback-legacy".equals( id ) )
                {
                    LOGGER.debug( "[IDE Help] Adding '" + id + "' as an exclusion and using one from classpath" );
                    exclusions.add( "org.apache.continuum:" + id );
                    jars.add( url.getPath() );
                    jarUrls.add( url );
                }
            }

            // Sometimes finds its way into the IDE. Make sure it is loaded in the extra classloader too
            if ( urlEF.contains( "jpox-enhancer" ) )
            {
                LOGGER.debug( "[IDE Help] Adding 'jpox-enhancer' as an exclusion and using one from classpath" );
                jars.add( url.getPath() );
                jarUrls.add( url );
            }
        }

        ArtifactFilter filter = new ExcludesArtifactFilter( exclusions );

        for ( Artifact a : artifacts )
        {
            if ( "jpox".equals( a.getGroupId() ) && "jpox".equals( a.getArtifactId() ) )
            {
                if ( a.getVersion().equals( databaseFormat.getJpoxVersion() ) )
                {
                    LOGGER.debug( "Adding artifact: " + a.getFile() );
                    jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + SPRING_CONTEXT_LOC );
                    jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + PLEXUS_XML_LOC );
                    jarUrls.add( new URL( FILE_PREFIX + a.getFile().getAbsolutePath() ) );
                }
            }
            else if ( filter.include( a ) )
            {
                LOGGER.debug( "Adding artifact: " + a.getFile() );
                jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + SPRING_CONTEXT_LOC );
                jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + PLEXUS_XML_LOC );
                jarUrls.add( new URL( FILE_PREFIX + a.getFile().getAbsolutePath() ) );
            }
        }

        URLClassLoader newClassLoader = new URLClassLoader( (URL[]) jarUrls.toArray( new URL[jarUrls.size()] ), cp );
        Thread.currentThread().setContextClassLoader( newClassLoader );
        classPathApplicationContext.setClassLoader( newClassLoader );

        PlexusFileSystemXmlApplicationContext fileSystemApplicationContext = new PlexusFileSystemXmlApplicationContext(
             (String[]) jars.toArray( new String[jars.size()] ), classPathApplicationContext );
        fileSystemApplicationContext.setClassLoader( newClassLoader );
        container.setApplicationContext( fileSystemApplicationContext );

        DatabaseFactoryConfigurator configurator = (DatabaseFactoryConfigurator) container.lookup(
                                DatabaseFactoryConfigurator.class.getName(), configRoleHint );
        configurator.configure( params );

        DataManagementTool manager =
            (DataManagementTool) container.lookup( DataManagementTool.class.getName(), toolRoleHint );

        if ( mode == OperationMode.EXPORT )
        {
            manager.backupDatabase( directory );
        }
View Full Code Here

Examples of org.codehaus.plexus.spring.PlexusContainerAdapter

     * @see org.springframework.context.support.AbstractApplicationContext#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
     */
    protected void postProcessBeanFactory( ConfigurableListableBeanFactory beanFactory, ApplicationContext context )
    {
        // Register a PlexusContainerAdapter bean to allow context lookups using plexus API
        PlexusContainerAdapter plexus = new PlexusContainerAdapter();
        plexus.setApplicationContext( context );
        beanFactory.registerSingleton( "plexusContainer", plexus );

        // Register a beanPostProcessor to handle plexus interface-based lifecycle management
        lifecycleBeanPostProcessor = new PlexusLifecycleBeanPostProcessor();
        lifecycleBeanPostProcessor.setBeanFactory( context );
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.