Package org.codehaus.classworlds

Examples of org.codehaus.classworlds.ClassRealm


            log.trace("Processing classworld realm: " + name);
        }
       
        // Get or create a new realm for this name
        ClassWorld world = getTwiddle().getClassWorld();
        ClassRealm realm = null;
        try {
            realm = world.getRealm(name);
        }
        catch (NoSuchRealmException e) {
            realm = world.newRealm(name);
        }
       
        String[] constituents = config.getLoadURLConfig();
        if (constituents != null) {
            log.trace("Processing constituents...");
           
            for (int i=0; i<constituents.length; i++) {
                assert constituents[i] != null;
               
                String urlspec = valueParser.parse(constituents[i], true);
                URL[] urls = parseGlobURLs(urlspec);
                for (int j=0; j<urls.length; j++) {
                    if (trace) {
                        log.trace("Adding constituent: " + urls[j]);
                    }
                    realm.addConstituent(urls[j]);
                }
            }
        }
       
        ImportPackageConfig[] imports = config.getImportPackageConfig();
        if (imports != null) {
            log.trace("Processing imports...");
           
            for (int i=0; i<imports.length; i++) {
                assert imports[i] != null;
                assert imports[i].getRealm() != null;
                assert imports[i].getContent() != null;
               
                String from = valueParser.parse(imports[i].getRealm(), true);
                String pkg = valueParser.parse(imports[i].getContent(), true);
                if (trace) {
                    log.trace("Importing " + pkg + " from realm " + from);
                }
                realm.importFrom(from, pkg);
            }
        }
    }
View Full Code Here


        throws ClassNotFoundException, IllegalAccessException,
               InvocationTargetException, NoSuchRealmException,
               IOException
    {
        // Get a handle on the class realm to load the class from
        ClassRealm realm = getClassRealm();
        ClassLoader cl = realm.getClassLoader();
       
        // Load the command instance
        Command command = (Command)Beans.instantiate(cl, config.getCode());
       
        // Configure the command attributes
View Full Code Here

     */
    public void registerLocation(AbstractClassPathLocation location) {
        if (!this.initializedProperly) return;

        try {
            final ClassRealm newRealm = this.classWorld.newRealm(location.getRealm(), getClass().getClassLoader());
            newRealm.addConstituent(location.getLocation().toURL());
        } catch (DuplicateRealmException e) {
            // Happens for #classpath realms ...
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
View Full Code Here

    public static void customizeContext( PlexusContainer container, File basedir, File mavenHome, File mavenHomeLocal )
        throws Exception
    {
        ClassWorld classWorld = new ClassWorld();

        ClassRealm rootClassRealm = classWorld.newRealm( "root", Thread.currentThread().getContextClassLoader() );

        container.addContextValue( "rootClassRealm", rootClassRealm );

        container.addContextValue( "maven.home", mavenHome.getAbsolutePath() );
View Full Code Here

        // * componentConfiguration 3rd param is org.codehaus.classworlds.ClassRealm
        // so use some reflection see MSITE-609
        try
        {
            Method methodContainerRealm = container.getClass().getMethod( "getContainerRealm" );
            ClassRealm realm = (ClassRealm) methodContainerRealm.invoke( container, null );

            Method methodConfigure = componentConfigurator.getClass().getMethod( "configureComponent",
                                                                                 new Class[]{ Object.class,
                                                                                     PlexusConfiguration.class,
                                                                                     ClassRealm.class } );
View Full Code Here

    public static void customizeContext( PlexusContainer container, File basedir, File mavenHome, File mavenHomeLocal )
        throws Exception
    {
        ClassWorld classWorld = new ClassWorld();

        ClassRealm rootClassRealm = classWorld.newRealm( "root", Thread.currentThread().getContextClassLoader() );

        container.addContextValue( "rootClassRealm", rootClassRealm );

        container.addContextValue( "maven.home", mavenHome.getAbsolutePath() );
View Full Code Here

            log.trace("Processing classworld realm: " + name);
        }
       
        // Get or create a new realm for this name
        ClassWorld world = getTwiddle().getClassWorld();
        ClassRealm realm = null;
        try {
            realm = world.getRealm(name);
        }
        catch (NoSuchRealmException e) {
            realm = world.newRealm(name);
        }
       
        String[] constituents = config.getLoadURLConfig();
        if (constituents != null) {
            log.trace("Processing constituents...");
           
            for (int i=0; i<constituents.length; i++) {
                assert constituents[i] != null;
               
                String urlspec = valueParser.parse(constituents[i], true);
                URL[] urls = parseGlobURLs(urlspec);
                for (int j=0; j<urls.length; j++) {
                    if (trace) {
                        log.trace("Adding constituent: " + urls[j]);
                    }
                    realm.addConstituent(urls[j]);
                }
            }
        }
       
        ImportPackageConfig[] imports = config.getImportPackageConfig();
        if (imports != null) {
            log.trace("Processing imports...");
           
            for (int i=0; i<imports.length; i++) {
                assert imports[i] != null;
                assert imports[i].getRealm() != null;
                assert imports[i].getContent() != null;
               
                String from = valueParser.parse(imports[i].getRealm(), true);
                String pkg = valueParser.parse(imports[i].getContent(), true);
                if (trace) {
                    log.trace("Importing " + pkg + " from realm " + from);
                }
                realm.importFrom(from, pkg);
            }
        }
    }
View Full Code Here

        throws ClassNotFoundException, IllegalAccessException,
               InvocationTargetException, NoSuchRealmException,
               IOException
    {
        // Get a handle on the class realm to load the class from
        ClassRealm realm = getClassRealm();
        ClassLoader cl = realm.getClassLoader();
       
        // Load the command instance
        Command command = (Command)Beans.instantiate(cl, config.getCode());
       
        // Configure the command attributes
View Full Code Here

        DefaultPlexusContainer child = new DefaultPlexusContainer();

        ClassWorld classWorld = container.getClassWorld();
        child.setClassWorld( classWorld );

        ClassRealm childRealm = null;

        // note: ideally extensions would live in their own realm, but this would mean that things like wagon-scm would
        // have no way to obtain SCM extensions
        String childRealmId = "plexus.core.child-container[" + CONTAINER_NAME + "]";
        try
        {
            childRealm = classWorld.getRealm( childRealmId );
        }
        catch ( NoSuchRealmException e )
        {
            try
            {
                childRealm = classWorld.newRealm( childRealmId );
            }
            catch ( DuplicateRealmException impossibleError )
            {
                getLogger().error( "An impossible error has occurred. After getRealm() failed, newRealm() " +
                    "produced duplication error on same id!", impossibleError );
            }
        }

        childRealm.setParent( container.getContainerRealm() );

        child.setCoreRealm( childRealm );

        child.setName( CONTAINER_NAME );
View Full Code Here

            {
                getLogger().fatalError(
                                        plugin.getClass().getName() + "#execute() caused a linkage error ("
                                            + e.getClass().getName() + ") and may be out-of-date. Check the realms:" );

                ClassRealm pluginRealm = mojoDescriptor.getPluginDescriptor().getClassRealm();
                StringBuffer sb = new StringBuffer();
                sb.append( "Plugin realm = " + pluginRealm.getId() ).append( '\n' );
                for ( int i = 0; i < pluginRealm.getConstituents().length; i++ )
                {
                    sb.append( "urls[" + i + "] = " + pluginRealm.getConstituents()[i] );
                    if ( i != ( pluginRealm.getConstituents().length - 1 ) )
                    {
                        sb.append( '\n' );
                    }
                }
                getLogger().fatalError( sb.toString() );

                ClassRealm containerRealm = container.getContainerRealm();
                sb = new StringBuffer();
                sb.append( "Container realm = " + containerRealm.getId() ).append( '\n' );
                for ( int i = 0; i < containerRealm.getConstituents().length; i++ )
                {
                    sb.append( "urls[" + i + "] = " + containerRealm.getConstituents()[i] );
                    if ( i != ( containerRealm.getConstituents().length - 1 ) )
                    {
                        sb.append( '\n' );
                    }
                }
                getLogger().fatalError( sb.toString() );
View Full Code Here

TOP

Related Classes of org.codehaus.classworlds.ClassRealm

Copyright © 2018 www.massapicom. 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.