/** * Constructs a new registry. */ public DefaultExtensionPointRegistry() { this.discovery = ServiceDiscovery.getInstance(); }
/** * Set the thread context classloader (TCCL) to a classloader that delegates to a collection * of classloaders * @param parent The parent classloader * @param delegates A list of classloaders to try * @return The existing TCCL */ public static ClassLoader setContextClassLoader(ClassLoader parent, ClassLoader... delegates) { ClassLoaderContext context = new ClassLoaderContext(parent, delegates); return context.setContextClassLoader(); }
/** * Create a context with the parent classloader and a list of service types that can be discovered * by the {@link ServiceDiscovery} * @param parent * @param discovery * @param serviceTypes */ public ClassLoaderContext(ClassLoader parent, ServiceDiscovery discovery, String... serviceTypes) { this(parent, getClassLoaders(discovery, serviceTypes)); }
/** * @param sd */ public LazyBindingBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
private static ClassLoader getClassLoader(ServiceDiscovery discovery, Class<?> serviceType) { try { ServiceDeclaration sd = discovery.getServiceDeclaration(serviceType); if (sd != null) { return sd.loadClass().getClassLoader(); } } catch (Exception e) { // Ignore } return null; }
/** * Discover all service providers that are compatible with the service type * @param serviceType * @return * @throws IOException */ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType) throws IOException { return getServiceDeclarations(serviceType, false); }
@Override protected Class<?> findClass(String name) throws ClassNotFoundException { return sd.loadClass(name); }
@Override protected URL findResource(String name) { return sd.getResource(name); }
public Class<?> loadClass() throws ClassNotFoundException { if (className == null) { return null; } if (javaClass == null) { javaClass = loadClass(className); } return javaClass; }
@Override protected Enumeration<URL> findResources(String name) throws IOException { return sd.getResources(name); }
/** * Set the context classloader so that it can access the list of service providers * @param parent The parent classloader * @param serviceNames A list of service provider names * @return The old TCCL if a new one is set, otherwise null */ public static ClassLoader setContextClassLoader(ClassLoader parent, ServiceDiscovery discovery, String... serviceNames) { ClassLoaderContext context = new ClassLoaderContext(parent, discovery, serviceNames); return context.setContextClassLoader(); }
/** * @param sd */ public LazyBindingBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
private static ClassLoader getClassLoader(ServiceDiscovery discovery, Class<?> serviceType) { try { ServiceDeclaration sd = discovery.getServiceDeclaration(serviceType); if (sd != null) { return sd.loadClass().getClassLoader(); } } catch (Exception e) { // Ignore } return null; }
/** * Create a context with the parent classloader and a list of service types that can be discovered * by the {@link ServiceDiscovery} * @param parent * @param discovery * @param serviceTypes */ public ClassLoaderContext(ClassLoader parent, ServiceDiscovery discovery, String... serviceTypes) { this(parent, getClassLoaders(discovery, serviceTypes)); }
public Class<?> loadClass() throws ClassNotFoundException { if (className == null) { return null; } if (javaClass == null) { javaClass = loadClass(className); } return javaClass; }
/** * Set the context classloader so that it can access the list of service providers * @param parent The parent classloader * @param serviceNames A list of service provider names * @return The old TCCL if a new one is set, otherwise null */ public static ClassLoader setContextClassLoader(ClassLoader parent, ServiceDiscovery discovery, Class<?>... serviceTypes) { ClassLoaderContext context = new ClassLoaderContext(parent, discovery, serviceTypes); return context.setContextClassLoader(); }
/** * @param sd */ public LazyImplementationBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
/** * Set the context classloader so that it can access the list of service providers * @param parent The parent classloader * @param serviceNames A list of service provider names * @return The old TCCL if a new one is set, otherwise null */ public static ClassLoader setContextClassLoader(ClassLoader parent, ServiceDiscovery discovery, String... serviceNames) { ClassLoaderContext context = new ClassLoaderContext(parent, discovery, serviceNames); return context.setContextClassLoader(); }
/** * Set the thread context classloader (TCCL) to a classloader that delegates to a collection * of classloaders * @param parent The parent classloader * @param delegates A list of classloaders to try * @return The existing TCCL */ public static ClassLoader setContextClassLoader(ClassLoader parent, ClassLoader... delegates) { ClassLoaderContext context = new ClassLoaderContext(parent, delegates); return context.setContextClassLoader(); }
/** * Set the context classloader so that it can access the list of service providers * @param parent The parent classloader * @param serviceNames A list of service provider names * @return The old TCCL if a new one is set, otherwise null */ public static ClassLoader setContextClassLoader(ClassLoader parent, ServiceDiscovery discovery, Class<?>... serviceTypes) { ClassLoaderContext context = new ClassLoaderContext(parent, discovery, serviceTypes); return context.setContextClassLoader(); }