/** * Determine the protection domain. If we are a copy of the original * deployment, use the original url as the codebase. * @return the protection domain * @todo certificates and principles? */ protected ProtectionDomain getProtectionDomain() { return getProtectionDomain(origURL != null ? origURL : url); } }
public URL getResource(String name, ClassLoader cl) { URL res = null; if( cl instanceof UnifiedClassLoader ) { UnifiedClassLoader ucl = (UnifiedClassLoader) cl; res = ucl.getResourceLocally(name); } else { res = cl.getResource(name); } return res; } public void getResources(String name, ClassLoader cl, List urls)
/** * UnifiedClassLoader constructor that can be used to * register with a particular Loader Repository identified by ObjectName. * * @param url an <code>URL</code> value * @param origURL the possibly null original URL from which url may * be a local copy or nested jar. * @param server a <code>MBeanServer</code> value * @param repositoryName an <code>ObjectName</code> value * @exception Exception if an error occurs */ public UnifiedClassLoader(final URL url, final URL origURL, final MBeanServer server, final ObjectName repositoryName) throws Exception { this(url, origURL); LoaderRepository rep = (LoaderRepository)server.invoke(repositoryName, "registerClassLoader", new Object[] {this}, new String[] {getClass().getName()}); this.setRepository(rep); }
public RepositoryClassLoader newClassLoader(final URL url, boolean addToRepository) throws Exception { UnifiedClassLoader ucl = new UnifiedClassLoader(url); if( addToRepository ) this.addClassLoader(ucl); return ucl; } public RepositoryClassLoader newClassLoader(final URL url, final URL origURL, boolean addToRepository)
/** * Retruns a string representaion of this UCL. */ public String toString() { StringBuffer tmp = new StringBuffer(super.toString()); tmp.setCharAt(tmp.length()-1, ','); tmp.append("addedOrder="); tmp.append(getAddedOrder()); tmp.append('}'); return tmp.toString(); } }
public void getResources(String name, ClassLoader cl, List<URL> urls) { Enumeration<URL> resURLs = null; try { if( cl instanceof UnifiedClassLoader ) { UnifiedClassLoader ucl = (UnifiedClassLoader) cl; resURLs = ucl.findResourcesLocally(name); } else { resURLs = cl.getResources(name); } while( resURLs.hasMoreElements() ) urls.add(resURLs.nextElement()); } catch(Exception e) { } } }
/** * @return the ClassLoader that will be associated with the DU. It will load * the classes in the DU and will be also used for JNDI objects * under ENC - java:comp/env * @throws DeploymentException */ protected RepositoryClassLoader createDUClassLoader() throws DeploymentException { try { UnifiedClassLoader ucl = (UnifiedClassLoader) Thread .currentThread().getContextClassLoader(); UnifiedLoaderRepository3 lr = (UnifiedLoaderRepository3) ucl .getLoaderRepository(); RepositoryClassLoader cl = lr.newClassLoader( getTempClassDeploymentDir().toURL(), new File( getUnitJarFile().getName()).toURL(), true); // make sure to call ucl.unregister() on undeploy() return cl; } catch (MalformedURLException e1) { throw new DeploymentException( "Bad ULR for tempClassDeploymentDir: " + getTempClassDeploymentDir()); } catch (Exception e) { throw new DeploymentException( "Failed Creating ClassLoader for tempClassDeploymentDir: " + getTempClassDeploymentDir()); } }
public RepositoryClassLoader newClassLoader(final URL url, boolean addToRepository) throws Exception { UnifiedClassLoader ucl = new UnifiedClassLoader(url); if( addToRepository ) this.addClassLoader(ucl); return ucl; } public RepositoryClassLoader newClassLoader(final URL url, final URL origURL, boolean addToRepository)
/** * Retruns a string representaion of this UCL. */ public String toString() { StringBuffer tmp = new StringBuffer(super.toString()); tmp.setCharAt(tmp.length()-1, ','); tmp.append("addedOrder="); tmp.append(getAddedOrder()); tmp.append('}'); return tmp.toString(); } }
public void getResources(String name, ClassLoader cl, List urls) { Enumeration resURLs = null; try { if( cl instanceof UnifiedClassLoader ) { UnifiedClassLoader ucl = (UnifiedClassLoader) cl; resURLs = ucl.findResourcesLocally(name); } else { resURLs = cl.getResources(name); } while( resURLs.hasMoreElements() ) urls.add(resURLs.nextElement()); } catch(Exception e) { } } }
public RepositoryClassLoader newClassLoader(final URL url, final URL origURL, boolean addToRepository) throws Exception { UnifiedClassLoader ucl = new UnifiedClassLoader(url, origURL); if( addToRepository ) this.addClassLoader(ucl); return ucl; } public Class<?> loadClass(String name, boolean resolve, ClassLoader cl)
/** * UnifiedClassLoader constructor that can be used to * register with a particular Loader Repository identified by ObjectName. * * @param url an <code>URL</code> value * @param origURL the possibly null original URL from which url may * be a local copy or nested jar. * @param server a <code>MBeanServer</code> value * @param repositoryName an <code>ObjectName</code> value * @exception Exception if an error occurs */ public UnifiedClassLoader(final URL url, final URL origURL, final MBeanServer server, final ObjectName repositoryName) throws Exception { this(url, origURL); LoaderRepository rep = (LoaderRepository)server.invoke(repositoryName, "registerClassLoader", new Object[] {this}, new String[] {getClass().getName()}); this.setRepository(rep); }
/** * Determine the protection domain. If we are a copy of the original * deployment, use the original url as the codebase. * @return the protection domain * @todo certificates and principles? */ protected ProtectionDomain getProtectionDomain() { return getProtectionDomain(origURL != null ? origURL : url); } }
public URL getResource(String name, ClassLoader cl) { URL res = null; if( cl instanceof UnifiedClassLoader ) { UnifiedClassLoader ucl = (UnifiedClassLoader) cl; res = ucl.getResourceLocally(name); } else { res = cl.getResource(name); } return res; } public void getResources(String name, ClassLoader cl, List<URL> urls)
public RepositoryClassLoader newClassLoader(final URL url, final URL origURL, boolean addToRepository) throws Exception { UnifiedClassLoader ucl = new UnifiedClassLoader(url, origURL); if( addToRepository ) this.addClassLoader(ucl); return ucl; } public Class loadClass(String name, boolean resolve, ClassLoader cl)
/** * Construct a <tt>UnifiedClassLoader</tt> and registers it to the given * repository. * @param url The single URL to load classes from. * @param origURL the possibly null original URL from which url may * be a local copy or nested jar. * @param repository the repository this classloader delegates to * be a local copy or nested jar. */ public UnifiedClassLoader(URL url, URL origURL, LoaderRepository repository) { this(url, origURL); // set the repository reference this.setRepository(repository); // register this loader to the given repository repository.addClassLoader(this); }
/** * Construct a <tt>UnifiedClassLoader</tt> and registers it to the given * repository. * @param url The single URL to load classes from. * @param origURL the possibly null original URL from which url may * be a local copy or nested jar. * @param repository the repository this classloader delegates to * be a local copy or nested jar. */ public UnifiedClassLoader(URL url, URL origURL, LoaderRepository repository) { this(url, origURL); // set the repository reference this.setRepository(repository); // register this loader to the given repository repository.addClassLoader(this); }