/** * @see ClassRealm#createChildRealm */ public ClassRealm createChildRealm( String id ) { ClassRealm childRealm = new DefaultClassRealm( getWorld(), id ); childRealm.setParent( this ); return childRealm; } }
URL loadResourceDirect( String name ) { // 1. Try this realm's ClassLoader. // 2. If the realm has a parent try the parent's ClassLoader. URL resource = this.classLoader.findResource( name ); if ( resource == null && getParent() != null ) { resource = getParent().getResource( name ); } return resource; }
/** Retrieve a resource. * * @param name The resource name. * * @return The URL to the located resource or <code>null</code> * if none could be located. */ public URL getResource( String name ) { name = UrlUtils.normalizeUrlPath( name ); DefaultClassRealm sourceRealm = locateSourceRealm( name ); if ( sourceRealm == this ) { return loadResourceDirect( name ); } return sourceRealm.getResource( name ); }
/** Load a class. * * @param name The name of the class to load. * * @return The loaded class. * * @throws ClassNotFoundException If the class cannot be found. */ public Class loadClass( String name ) throws ClassNotFoundException { if ( name.startsWith( "org.codehaus.classworlds." ) ) { return getWorld().loadClass( name ); } DefaultClassRealm sourceRealm = locateSourceRealm( name ); if ( sourceRealm == this ) { return loadClassDirect( name ); } return sourceRealm.loadClass( name ); }
public ClassRealm newRealm( String id, ClassLoader classLoader ) throws DuplicateRealmException { if ( realms.containsKey( id ) ) { throw new DuplicateRealmException( this, id ); } ClassRealm realm = null; if ( classLoader != null ) { realm = new DefaultClassRealm( this, id, classLoader ); realms.put( id, realm ); } else { realm = new DefaultClassRealm( this, id ); } realms.put( id, realm ); return realm; }
return getWorld().loadClass( name ); ClassRealm sourceRealm = locateSourceRealm( name ); if ( getParent() != null ) return getParent().loadClass( name );
ClassRealm sourceRealm = locateSourceRealm( name ); for ( Enumeration parent = getParent().findResources(name); parent.hasMoreElements(); )
addConstituent( new URL( null, file.toURI().toURL().toExternalForm(), new BytesURLStreamHandler(b) ) );
public InputStream getResourceAsStream( String name ) { URL url = getResource( name ); InputStream is = null; if ( url != null ) { try { is = url.openStream(); } catch ( IOException e ) { // do nothing } } return is; }
/** Load a class. * * @param name The name of the class to load. * @param resolve If <code>true</code> then resolve the class. * * @return The loaded class. * * @throws ClassNotFoundException If the class cannot be found. */ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { return getRealm().loadClass( name ); }
/** Create a new <code>ClassRealm</code>. * * @param id The realm id. * * @return The newly created realm. * * @throws DuplicateRealmException If this class-world already * contains a realm with the specified id. */ public ClassRealm newRealm(String id) throws DuplicateRealmException { if ( this.realms.containsKey( id ) ) { throw new DuplicateRealmException( this, id ); } DefaultClassRealm realm = new DefaultClassRealm( this, id ); this.realms.put( id, realm ); return realm; }
ClassRealm sourceRealm = locateSourceRealm( name ); if ( resource == null && getParent() != null ) resource = getParent().getResource( name );
addConstituent( new URL( null, file.toURL().toExternalForm(), new BytesURLStreamHandler(b) ) );
public ClassRealm createChildRealm( String id ) throws DuplicateRealmException { ClassRealm childRealm = getWorld().newRealm( id ); childRealm.setParent( this ); return childRealm; }
/** @see ClassLoader */ public URL getResource( String name ) { return getRealm().getResource( name ); }
/** Load a class. * * @param name The name of the class to load. * @param resolve If <code>true</code> then resolve the class. * * @return The loaded class. * * @throws ClassNotFoundException If the class cannot be found. */ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { return getRealm().loadClass( name ); }
ClassRealm remoting = new DefaultClassRealm(launcher.getWorld(),"hudson-remoting", launcher.getSystemClassLoader());
addConstituent( new URL( null, file.toURI().toURL().toExternalForm(), new BytesURLStreamHandler(b) ) );
/** Import packages from another <code>ClassRealm</code>. * * <p> * Specific packages can be imported from another realm * instead of attempting to load them locally from this * one. When importing a package a realm defers <b>completely</b> * to the foreign realm to satisfy the package dependencies. * </p> * * @param realmId The realm id from which to import. * @param pkgName The package name to import. * * @throws NoSuchRealmException If the id of the realm from which * to import does not correspond to a foreign realm within * this realm's world. */ public void importFrom( String realmId, String pkgName ) throws NoSuchRealmException { this.imports.add( new Entry( getWorld().getRealmImpl( realmId ), pkgName ) ); }