public ClassWorld( String realmId, ClassLoader classLoader ) { this(); try { newRealm( realmId, classLoader ); } catch ( DuplicateRealmException e ) { // Will never happen as we are just creating the world. } }
public ClassRealm newRealm( String id ) throws DuplicateRealmException { return newRealm( id, null ); }
/** */ protected Abstract2StageLocator(Option ... options) { try { this.classWorld = new ClassWorld(); this.realm = this.classWorld.newRealm(DEFAULT_REALM); } catch (DuplicateRealmException e) { // } }
public static void extendPluginClasspath(List<String> elements) throws MojoExecutionException { ClassWorld world = new ClassWorld(); try { ClassRealm realm = world.newRealm("maven", Thread.currentThread().getContextClassLoader()); for (String element : elements) { File elementFile = new File(element); realm.addConstituent(elementFile.toURI().toURL()); } Thread.currentThread().setContextClassLoader(realm.getClassLoader()); } catch (Exception ex) { throw new MojoExecutionException(ex.toString(), ex); } }
public Object run() { try { // Try to create a new ClassWorld object ClassPathManager.this.classWorld = new ClassWorld(); // Create a core realm (for internal and classpath://* plugins) try { ClassPathManager.this.classWorld.newRealm("core", getClass().getClassLoader()); } catch (DuplicateRealmException e) { e.printStackTrace(); } // Signal that we are okay. ClassPathManager.this.initializedProperly = true; } catch (SecurityException e) { ClassPathManager.this.logger.warning("Proper initialization failed due to security restrictions. Only classpath://xxx URIs will work. Sorry."); } return null; } });
public ClassRealm createChildRealm( String id ) throws DuplicateRealmException { ClassRealm childRealm = getWorld().newRealm( id ); childRealm.setParent( this ); return childRealm; }
/** * Adds a classpath location to this manager. * * @param location */ 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) { e.printStackTrace(); } }
public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id ) throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException { try { return ClassRealmReverseAdapter.getInstance( world.newRealm( id ) ); } catch ( DuplicateRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() ); } }
public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id ) throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException { try { return ClassRealmReverseAdapter.getInstance( world.newRealm( id ) ); } catch ( DuplicateRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() ); } }
public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id, ClassLoader classLoader ) throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException { try { return ClassRealmReverseAdapter.getInstance( world.newRealm( id, classLoader ) ); } catch ( DuplicateRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() ); } }
public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id, ClassLoader classLoader ) throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException { try { return ClassRealmReverseAdapter.getInstance( world.newRealm( id, classLoader ) ); } catch ( DuplicateRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() ); } }
protected synchronized PlexusContainer getContainer() { if ( container == null ) { container = (PlexusContainer) getProject().getReference( PlexusContainer.class.getName() ); if ( container == null ) { try { ClassWorld classWorld = new ClassWorld(); classWorld.newRealm( "plexus.core", getClass().getClassLoader() ); Embedder embedder = new Embedder(); embedder.start( classWorld ); container = embedder.getContainer(); } catch ( PlexusContainerException e ) { throw new BuildException( "Unable to start embedder", e ); } catch ( DuplicateRealmException e ) { throw new BuildException( "Unable to create embedder ClassRealm", e ); } getProject().addReference( PlexusContainer.class.getName(), container ); } } return container; }
protected synchronized Embedder getEmbedder() { if ( embedder == null ) { embedder = (Embedder) getProject().getReference( Embedder.class.getName() ); if ( embedder == null ) { embedder = new Embedder(); try { ClassWorld classWorld = new ClassWorld(); classWorld.newRealm( "plexus.core", getClass().getClassLoader() ); embedder.start( classWorld ); } catch ( PlexusContainerException e ) { throw new BuildException( "Unable to start embedder", e ); } catch ( DuplicateRealmException e ) { throw new BuildException( "Unable to create embedder ClassRealm", e ); } getProject().addReference( Embedder.class.getName(), embedder ); } } return embedder; }
private static synchronized ClassRealm getOrCreateClassRealm(final ClassRealm classRealm, final File jrubyJar) throws MalformedURLException, ScriptException { ClassRealm jruby; try { jruby = classRealm.getWorld().getRealm("jruby"); } catch (final NoSuchRealmException e) { try { jruby = classRealm.getWorld().newRealm("jruby"); if(jrubyJar != null){ jruby.addConstituent(jrubyJar.toURI().toURL()); } } catch (final DuplicateRealmException ee) { throw new ScriptException("could not setup classrealm for jruby", ee); } } return jruby; }
ClassRealm containerRealm = world.newRealm("plugin.fornax.oaw.container", Thread.currentThread() .getContextClassLoader());
try realm = world.newRealm( "hexacss", null ); for( Artifact artifact : dependencyArtifacts )
ClassRealm realm = classRealm.getWorld().newRealm("jruby-all"); for (String path : getProjectClasspath()) { realm.addConstituent(new File(path).toURI().toURL());
ClassRealm realm = classRealm.getWorld().newRealm("jruby-all"); for (String path : getProjectClasspath()) { realm.addConstituent(new File(path).toURI().toURL());
ClassWorld classWorld = new ClassWorld(); classWorld.newRealm("plexus.fabric", getClass().getClassLoader());
jruby = classRealm.getWorld().newRealm("jruby"); if(jrubyJar != null){ jruby.addConstituent(jrubyJar.toURI().toURL());