public ClassSpace space() { return new URLClassSpace( getClass().getClassLoader() ); }
/** * Creates a {@link ClassSpace} backed by a {@link ClassLoader} with a restricted class path. * * @param loader The class loader to use when getting resources * @param path The class path to use when finding resources * @see #getResources(String) * @see #findEntries(String, String, boolean) */ public URLClassSpace( final ClassLoader loader, final URL[] path ) { this.loader = loader; if ( null != path && path.length > 0 ) { classPath = expandClassPath( path ); } else { classPath = NO_URLS; } }
final URL url = normalizeEntry( searchPath.get( i ) ); if ( null == url || !visited.add( url.toString() ) ) try classPathEntries = getClassPathEntries( url );
public URL[] getURLs() { return getClassPath().clone(); }
public Enumeration<URL> findEntries( final String path, final String glob, final boolean recurse ) { return new ResourceEnumeration( path, glob, recurse, getClassPath() ); }
public ClassSpace space() { return new URLClassSpace( getClass().getClassLoader() ); }
/** * Returns the associated {@link URL} class path; this can either be explicit or implicit. */ private synchronized URL[] getClassPath() { if ( null == classPath ) { for ( ClassLoader l = loader; l != null; l = l.getParent() ) { if ( l instanceof URLClassLoader ) { // pick first class loader with non-empty class path final URL[] path = ( (URLClassLoader) l ).getURLs(); if ( null != path && path.length > 0 ) { classPath = expandClassPath( path ); break; } } } if ( null == classPath ) { classPath = NO_URLS; // no detectable Class-Path } } return classPath; }
private ClassSpace createClassSpace(final ClassLoader parent, final URL[] urls) { if (log.isDebugEnabled()) { log.debug("Path:"); for (URL url : urls) { log.debug(" {}", url); } } return new URLClassSpace(parent, urls); } }
public ClassSpace space() { return new URLClassSpace( getClass().getClassLoader() ); }
public ClassSpace space() { return new URLClassSpace( getClass().getClassLoader() ); }
private ClassSpace createClassSpace(final ClassLoader parent, final URL[] urls) { if (log.isDebugEnabled()) { log.debug("Path:"); for (URL url : urls) { log.debug(" {}", url); } } return new URLClassSpace(parent, urls); } }
private ClassSpace createClassSpace() { URLClassSpace space; if (plugin.classLoader instanceof PluginClassLoader) { PluginClassLoader cl = (PluginClassLoader) plugin.classLoader; space = new URLClassSpace(cl, cl.getURLs()); // urls logged from PluginWrapperFactory } else { log.warn("Expected plugin to have PluginClassLoader; instead found: {}", plugin.classLoader.getClass().getName()); space = new URLClassSpace(plugin.classLoader); } return space; } }
private ClassSpace createClassSpace() { URLClassSpace space; if (plugin.classLoader instanceof PluginClassLoader) { PluginClassLoader cl = (PluginClassLoader) plugin.classLoader; space = new URLClassSpace(cl, cl.getURLs()); // urls logged from PluginWrapperFactory } else { log.warn("Expected plugin to have PluginClassLoader; instead found: {}", plugin.classLoader.getClass().getName()); space = new URLClassSpace(plugin.classLoader); } return space; } }
public static Module wire( final BeanScanning scanning, final Module... bindings ) { final Module[] modules = new Module[bindings.length + 1]; System.arraycopy( bindings, 0, modules, 0, bindings.length ); final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); modules[bindings.length] = new SpaceModule( new URLClassSpace( tccl ), scanning ); return new WireModule( modules ); }
protected SpaceModule createSpaceModule() { URLClassSpace space = new URLClassSpace(getClass().getClassLoader()); return new SpaceModule(space, BeanScanning.INDEX); }
@Override public void scan() throws IOException { ClassSpace space = new URLClassSpace(getClass().getClassLoader(), classPath); ClassSpaceScanner scanner = new ClassSpaceScanner(space); scanner.accept(_collector); } }
@Override public void scan() throws IOException { ClassSpace space = new URLClassSpace(getClass().getClassLoader()); ClassSpaceScanner scanner = new ClassSpaceScanner(space); scanner.accept(_collector); } }
private DeferredClass<?> cloneImplementation( final String implementation ) { if ( null == cloningClassSpace ) { cloningClassSpace = new URLClassSpace( AccessController.doPrivileged( new PrivilegedAction<ClassLoader>() { public ClassLoader run() { return new CloningClassLoader( space ); } } ), null ); } return cloningClassSpace.deferLoadClass( CloningClassLoader.proxyName( implementation, ++cloneCounter ) ); } }
private EventSpy loadDelegate() { checkState(locator != null); // Setup the Injector to load spy impls from URL[] scanPath = { getClass().getProtectionDomain().getCodeSource().getLocation(), }; URLClassSpace space = new URLClassSpace(getClass().getClassLoader(), scanPath); Injector injector = Guice.createInjector(new WireModule(new SpaceModule(space), this)); // Log what spies we know about if (log.isDebugEnabled()) { log.debug("Known spies:"); for (BeanEntry<Annotation, EventSpy> spy : locator.locate(Key.get(EventSpy.class))) { log.debug(" {}", spy); } } // Load the delegate, default to RemotingEventSpy String name = getProperty(DELEGATE_PROPERTY, RemotingEventSpy.class.getName()); log.debug("Loading delegate named: {}", name); Iterator<BeanEntry<Annotation, EventSpy>> itr = locator.locate(Key.get(EventSpy.class, Names.named(name))).iterator(); if (itr.hasNext()) { return itr.next().getValue(); } throw new RuntimeException("No such delegate: "+name); }
private EventSpy loadDelegate() { checkState(locator != null); // Setup the Injector to load spy impls from URL[] scanPath = { getClass().getProtectionDomain().getCodeSource().getLocation(), }; URLClassSpace space = new URLClassSpace(getClass().getClassLoader(), scanPath); Injector injector = Guice.createInjector(new WireModule(new SpaceModule(space), this)); // Log what spies we know about if (log.isDebugEnabled()) { log.debug("Known spies:"); for (BeanEntry<Annotation, EventSpy> spy : locator.locate(Key.get(EventSpy.class))) { log.debug(" {}", spy); } } // Load the delegate, default to RemotingEventSpy String name = getProperty(DELEGATE_PROPERTY, RemotingEventSpy.class.getName()); log.debug("Loading delegate named: {}", name); Iterator<BeanEntry<Annotation, EventSpy>> itr = locator.locate(Key.get(EventSpy.class, Names.named(name))).iterator(); if (itr.hasNext()) { return itr.next().getValue(); } throw new RuntimeException("No such delegate: "+name); }