Package org.codehaus.plexus.classworlds

Examples of org.codehaus.plexus.classworlds.ClassWorld


    public void configure( InputStream is )
        throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
    {
        if ( world == null )
        {
            world = new ClassWorld();
        }

        curRealm = null;

        foreignClassLoader = null;
View Full Code Here


    @Test
    public void loadSnappyByDiffentClassloadersInTheSameJVM() throws Exception {

        // Parent class loader cannot see Snappy.class
        ClassLoader parent = this.getClass().getClassLoader().getParent();
        ClassWorld cw = new ClassWorld();
        ClassRealm P = cw.newRealm("P", parent);
        try {
            P.loadClass("org.xerial.snappy.Snappy");
            fail("org.xerial.snappy.Snappy is found in the parent");
        }
        catch (ClassNotFoundException e) {
            // OK
        }

        // Prepare the child class loaders which can load Snappy.class
        URL classPath = new File("target/classes").toURI().toURL();
        ClassRealm L1 = cw.newRealm("l1", URLClassLoader.newInstance(new URL[] { classPath }, parent));
        ClassRealm L2 = cw.newRealm("l2", URLClassLoader.newInstance(new URL[] { classPath }, parent));

        // Actually load Snappy.class in a child class loader

        Class< ? > S1 = L1.loadClass("org.xerial.snappy.Snappy");
        Method m = S1.getMethod("compress", String.class);
View Full Code Here

    public void configure( InputStream is )
        throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
    {
        if ( world == null )
        {
            world = new ClassWorld();
        }

        curRealm = null;

        foreignClassLoader = null;
View Full Code Here

        return null;
    }

    public int execute( String[] args )
    {
        ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() );

        return execute( args, classWorld );
    }
View Full Code Here

            throw new DuplicateChildContainerException( getName(), name );
        }

        ContainerConfiguration c = new DefaultContainerConfiguration()
            .setName( name )
            .setClassWorld( new ClassWorld( name, classLoader ) );

        return new DefaultPlexusContainer( c );
    }
View Full Code Here

        this.classWorld = c.getClassWorld();

        // Make sure we have a valid ClassWorld
        if ( this.classWorld == null )
        {
            this.classWorld = new ClassWorld( DEFAULT_REALM_NAME, Thread.currentThread().getContextClassLoader() );
        }

        containerRealm = c.getRealm();

        if ( containerRealm == null )
View Full Code Here

    }

    private void extendClassLoader() throws DuplicateRealmException, MalformedURLException {
        ClassRealm realm = descriptor.getClassRealm();
        if (realm == null) {
            ClassWorld world = new ClassWorld();
            realm = world.newRealm("maven.plugin." + getClass().getSimpleName(), Thread
                    .currentThread().getContextClassLoader());
        }
        File cls = new File(buildDir + File.separator + DEFAULT_CLASSES_DIRECTORY);
        File testCls = new File(buildDir + File.separator + DEFAULT_TEST_CLASSES_DIRECTORY);
        realm.addURL(cls.toURI().toURL());
View Full Code Here

  @Test
  public void detect_plugins_compiled_for_bad_java_version() throws Exception {
    thrown.expect(SonarException.class);
    thrown.expectMessage("The plugin checkstyle is not supported with Java 1.");

    ClassWorld world = mock(ClassWorld.class);
    when(world.newRealm(anyString(), any(ClassLoader.class))).thenThrow(new UnsupportedClassVersionError());

    classloaders = new PluginClassloaders(getClass().getClassLoader(), world);

    DefaultPluginMetadata checkstyle = DefaultPluginMetadata.create("checkstyle")
      .setMainClass("org.sonar.plugins.checkstyle.CheckstylePlugin")
View Full Code Here

  private ClassWorld world;
  private ClassLoader baseClassloader;
  private boolean done = false;

  public PluginClassloaders(ClassLoader baseClassloader) {
    this(baseClassloader, new ClassWorld());
  }
View Full Code Here

        this.classWorld = classWorld;

        // Make sure we have a valid ClassWorld
        if ( this.classWorld == null )
        {
            this.classWorld = new ClassWorld( DEFAULT_REALM_NAME, Thread.currentThread().getContextClassLoader() );
        }

        containerRealm = realm;

        if ( containerRealm == null )
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.classworlds.ClassWorld

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.