Package org.codehaus.classworlds

Examples of org.codehaus.classworlds.ClassRealm


        // for maven2 builds ClassRealm doesn't extends ClassLoader !
        // so check stuff with reflection
        Method method = ReflectionUtils.getPublicMethodNamed( pd.getClass(), "getClassRealm" );
      
        if ( ReflectionUtils.invokeMethod( method, pd ) instanceof ClassRealm) {
            ClassRealm cr = (ClassRealm) ReflectionUtils.invokeMethod( method, pd );
            cl = cr.getClassLoader();
        } else {
            cl = mojoExecution.getMojoDescriptor().getPluginDescriptor().getClassRealm();
        }
        ConfigurationConverter converter = converterLookup.lookupConverterForType(type);
        return type.cast(converter.fromConfiguration(converterLookup,child,type,
View Full Code Here


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

        try {
            final ClassRealm newRealm = this.classWorld.newRealm(location.getRealm(), getClass().getClassLoader());
            final URI[] classpathLocations = location.getClasspathLocations();
            for (URI uri : classpathLocations) {
                newRealm.addConstituent(uri.toURL());
            }

        } catch (DuplicateRealmException e) {
            // Happens for #classpath realms ...
        } catch (MalformedURLException e) {
View Full Code Here

     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        ClassWorld cw = new ClassWorld();
        ClassRealm realm = cw.newRealm("http://x.as?2");       
        realm.addConstituent(new File("bin/").toURI().toURL());
        ClassLoader classLoader = realm.getClassLoader();
       
        Class<?> loadClass = classLoader.loadClass("net.xeoh.plugins.base.Plugin");
        System.out.println(loadClass);
       
        ClassRealm realm2 = cw.newRealm("ASd");
        ClassLoader classLoader2 = realm2.getClassLoader();
        Class<?> loadClass2 = classLoader2.loadClass("net.xeoh.plugins.base.Plugin");
        System.out.println(loadClass2);
       
       
    }
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

            {
                getLogger().fatalError(
                                        configurator.getClass().getName() + "#configureComponent(...) 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

        DefaultPlexusContainer child = new DefaultPlexusContainer();

        child.classWorld = classWorld;

        ClassRealm childRealm = null;

        String childRealmId = getName() + ".child-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( plexusRealm );

        child.coreRealm = childRealm;

        child.plexusRealm = childRealm;
View Full Code Here

    private ValidationFailures bootIsisThenShutdown() throws MojoExecutionException, MojoFailureException {
        ClassWorld classWorld = null;
        IsisMetaModel isisMetaModel = null;
        try {
            classWorld = new ClassWorld();
            final ClassRealm isisRealm = classWorld.newRealm(ISIS_REALM);

            addClassesToRealm(isisRealm);

            List<Object> serviceList = createServicesFromConfiguration(isisRealm);
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

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