/** * Returns an {@code Iterator} containing all categories in this registry * the given {@code pProvider} <em>may be registered with</em>. * <p/> * The iterator does not support removal. * * @param pProvider the provider instance * @return an {@code Iterator} containing all categories in this registry * the given {@code pProvider} may be registered with */ protected Iterator<Class<?>> compatibleCategories(final Object pProvider) { return new FilterIterator<Class<?>>(categories(), new FilterIterator.Filter<Class<?>>() { public boolean accept(Class<?> pElement) { return pElement.isInstance(pProvider); } }); }
/** * Registers all provider implementations for this {@code ServiceRegistry} * found in the application classpath. * * @throws ServiceConfigurationError if an error occurred during registration */ public void registerApplicationClasspathSPIs() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Iterator<Class<?>> categories = categories(); while (categories.hasNext()) { Class<?> category = categories.next(); try { // Find all META-INF/services/ + name on class path String name = SERVICES + category.getName(); Enumeration<URL> spiResources = loader.getResources(name); while (spiResources.hasMoreElements()) { URL resource = spiResources.nextElement(); registerSPIs(resource, category, loader); } } catch (IOException e) { throw new ServiceConfigurationError(e); } } }
return new FilterIterator<Class<?>>(categories(), new FilterIterator.Filter<Class<?>>() { public boolean accept(Class<?> pElement) {
testRegistry.deregister(two); Iterator<Class<?>> categories = testRegistry.categories(); System.out.println("Categories: "); while (categories.hasNext()) {
@Test public void testCreateEmptyIterator() { // A completely useless registry... ServiceRegistry registry = new ServiceRegistry(Collections.<Class<?>>emptyList().iterator()); registry.registerApplicationClasspathSPIs(); while (registry.categories().hasNext()) { fail("No categories"); } }
/** * Returns an {@code Iterator} containing all categories in this registry * the given {@code pProvider} <em>may be registered with</em>. * <p/> * The iterator does not support removal. * * @param pProvider the provider instance * @return an {@code Iterator} containing all categories in this registry * the given {@code pProvider} may be registered with */ protected Iterator<Class<?>> compatibleCategories(final Object pProvider) { return new FilterIterator<Class<?>>(categories(), new FilterIterator.Filter<Class<?>>() { public boolean accept(Class<?> pElement) { return pElement.isInstance(pProvider); } }); }
/** * Returns an {@code Iterator} containing all categories in this registry * the given {@code pProvider} <em>may be registered with</em>. * <p/> * The iterator does not support removal. * * @param pProvider the provider instance * @return an {@code Iterator} containing all categories in this registry * the given {@code pProvider} may be registered with */ protected Iterator<Class<?>> compatibleCategories(final Object pProvider) { return new FilterIterator<Class<?>>(categories(), new FilterIterator.Filter<Class<?>>() { public boolean accept(Class<?> pElement) { return pElement.isInstance(pProvider); } }); }
/** * Returns an {@code Iterator} containing all categories in this registry * the given {@code pProvider} <em>may be registered with</em>. * <p/> * The iterator does not support removal. * * @param pProvider the provider instance * @return an {@code Iterator} containing all categories in this registry * the given {@code pProvider} may be registered with */ protected Iterator<Class<?>> compatibleCategories(final Object pProvider) { return new FilterIterator<Class<?>>(categories(), new FilterIterator.Filter<Class<?>>() { public boolean accept(Class<?> pElement) { return pElement.isInstance(pProvider); } }); }
return new FilterIterator<Class<?>>(categories(), new FilterIterator.Filter<Class<?>>() { public boolean accept(Class<?> pElement) {
return new FilterIterator<Class<?>>(categories(), new FilterIterator.Filter<Class<?>>() { public boolean accept(Class<?> pElement) {
/** * Registers all provider implementations for this {@code ServiceRegistry} * found in the application classpath. * * @throws ServiceConfigurationError if an error occured during registration */ public void registerApplicationClasspathSPIs() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Iterator<Class<?>> categories = categories(); while (categories.hasNext()) { Class<?> category = categories.next(); try { // Find all META-INF/services/ + name on class path String name = SERVICES + category.getName(); Enumeration<URL> spiResources = loader.getResources(name); while (spiResources.hasMoreElements()) { URL resource = spiResources.nextElement(); registerSPIs(resource, category, loader); } } catch (IOException e) { throw new ServiceConfigurationError(e); } } }
/** * Registers all provider implementations for this {@code ServiceRegistry} * found in the application classpath. * * @throws ServiceConfigurationError if an error occurred during registration */ public void registerApplicationClasspathSPIs() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Iterator<Class<?>> categories = categories(); while (categories.hasNext()) { Class<?> category = categories.next(); try { // Find all META-INF/services/ + name on class path String name = SERVICES + category.getName(); Enumeration<URL> spiResources = loader.getResources(name); while (spiResources.hasMoreElements()) { URL resource = spiResources.nextElement(); registerSPIs(resource, category, loader); } } catch (IOException e) { throw new ServiceConfigurationError(e); } } }
/** * Registers all provider implementations for this {@code ServiceRegistry} * found in the application classpath. * * @throws ServiceConfigurationError if an error occurred during registration */ public void registerApplicationClasspathSPIs() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Iterator<Class<?>> categories = categories(); while (categories.hasNext()) { Class<?> category = categories.next(); try { // Find all META-INF/services/ + name on class path String name = SERVICES + category.getName(); Enumeration<URL> spiResources = loader.getResources(name); while (spiResources.hasMoreElements()) { URL resource = spiResources.nextElement(); registerSPIs(resource, category, loader); } } catch (IOException e) { throw new ServiceConfigurationError(e); } } }
return new FilterIterator<Class<?>>(categories(), new FilterIterator.Filter<Class<?>>() { public boolean accept(Class<?> pElement) {
testRegistry.deregister(two); Iterator<Class<?>> categories = testRegistry.categories(); System.out.println("Categories: "); while (categories.hasNext()) {
testRegistry.deregister(two); Iterator<Class<?>> categories = testRegistry.categories(); System.out.println("Categories: "); while (categories.hasNext()) {
testRegistry.deregister(two); Iterator<Class<?>> categories = testRegistry.categories(); System.out.println("Categories: "); while (categories.hasNext()) {
@Test public void testCreateEmptyIterator() { // A completely useless registry... ServiceRegistry registry = new ServiceRegistry(Collections.<Class<?>>emptyList().iterator()); registry.registerApplicationClasspathSPIs(); while (registry.categories().hasNext()) { fail("No categories"); } }
@Test public void testCreateEmptyIterator() { // A completely useless registry... ServiceRegistry registry = new ServiceRegistry(Collections.<Class<?>>emptyList().iterator()); registry.registerApplicationClasspathSPIs(); while (registry.categories().hasNext()) { fail("No categories"); } }