public String nextResourceName() { return iterator.nextResourceName(); }
private String getNextResourceName() { while (inputNames.hasNext() && (resourceNames == null || !resourceNames.hasNext())) { resourceNames = findResourceNames(inputNames.nextResourceName()); } return (resourceNames != null && resourceNames.hasNext()) ? resourceNames.nextResourceName() : null; } };
public static <T> List<T> discoverExtensions(Class<T> type, ClassLoader... cls) { List<T> r = new ArrayList<T>(); Set<String> classNames = new HashSet<String>(); for (ClassLoader cl : cls) { ClassLoaders classLoaders = new ClassLoaders(); classLoaders.put(cl); DiscoverServiceNames dc = new DiscoverServiceNames(classLoaders); ResourceNameIterator itr = dc.findResourceNames(type.getName()); while(itr.hasNext()) { String name = itr.nextResourceName(); if (!classNames.add(name)) continue; // avoid duplication Class<?> c; try { c = cl.loadClass(name); } catch (ClassNotFoundException e) { LOGGER.log(Level.WARNING, "Failed to load "+name,e); continue; } try { r.add((T)c.newInstance()); } catch (InstantiationException e) { LOGGER.log(Level.WARNING, "Failed to instantiate "+c,e); } catch (IllegalAccessException e) { LOGGER.log(Level.WARNING, "Failed to instantiate "+c,e); } } } return r; }
public static <T> List<T> discoverExtensions(Class<T> type, ClassLoader... cls) { List<T> r = new ArrayList<T>(); Set<String> classNames = new HashSet<String>(); for (ClassLoader cl : cls) { ClassLoaders classLoaders = new ClassLoaders(); classLoaders.put(cl); DiscoverServiceNames dc = new DiscoverServiceNames(classLoaders); ResourceNameIterator itr = dc.findResourceNames(type.getName()); while(itr.hasNext()) { String name = itr.nextResourceName(); if (!classNames.add(name)) continue; // avoid duplication Class<?> c; try { c = cl.loadClass(name); } catch (ClassNotFoundException e) { LOGGER.log(Level.WARNING, "Failed to load "+name,e); continue; } try { r.add((T)c.newInstance()); } catch (InstantiationException e) { LOGGER.log(Level.WARNING, "Failed to instanticate "+c,e); } catch (IllegalAccessException e) { LOGGER.log(Level.WARNING, "Failed to instanticate "+c,e); } } } return r; }
public static <T> List<T> discoverExtensions(Class<T> type, ClassLoader... cls) { List<T> r = new ArrayList<T>(); Set<String> classNames = new HashSet<String>(); for (ClassLoader cl : cls) { ClassLoaders classLoaders = new ClassLoaders(); classLoaders.put(cl); DiscoverServiceNames dc = new DiscoverServiceNames(classLoaders); ResourceNameIterator itr = dc.findResourceNames(type.getName()); while(itr.hasNext()) { String name = itr.nextResourceName(); if (!classNames.add(name)) continue; // avoid duplication Class<?> c; try { c = cl.loadClass(name); } catch (ClassNotFoundException e) { LOGGER.log(Level.WARNING, "Failed to load "+name,e); continue; } try { r.add((T)c.newInstance()); } catch (InstantiationException e) { LOGGER.log(Level.WARNING, "Failed to instantiate "+c,e); } catch (IllegalAccessException e) { LOGGER.log(Level.WARNING, "Failed to instantiate "+c,e); } } } return r; }
/** * Executes the Apache Ant task, discovering the set service name * * @throws Exception if any error occurs */ public void execute() throws Exception { System.out.printf("Discovering service '%s'...%n", name); DiscoverResources disc = new DiscoverResources(); disc.addClassLoader( JDKHooks.getJDKHooks().getThreadContextClassLoader() ); disc.addClassLoader( this.getClass().getClassLoader() ); ResourceNameIterator iterator = disc.findResources(name); List<String> resources = new LinkedList<String>(); while (iterator.hasNext()) { String resourceInfo = iterator.nextResourceName(); resources.add(resourceInfo); if (debug > 0) { System.out.printf("Found '%s'%n", resourceInfo); } } drivers = new String[resources.size()]; resources.toArray(drivers); }
ResourceNameIterator iter = dsn.findResourceNames(LIFECYCLE_PROVIDER); while (iter.hasNext()) { String className = iter.nextResourceName(); try
ResourceNameIterator iter = dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME); while (iter.hasNext()) { String className = iter.nextResourceName(); try { Object o = Class.forName(className).newInstance();
ResourceNameIterator iter = dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME); while (iter.hasNext()) { String className = iter.nextResourceName(); try { Object o = Class.forName(className).newInstance();
ResourceNameIterator iter = dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME); while (iter.hasNext()) { String className = iter.nextResourceName(); try { Object o = Class.forName(className).newInstance();
ResourceNameIterator iter = dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME); while (iter.hasNext()) { String className = iter.nextResourceName(); try { Object o = Class.forName(className).newInstance();
ResourceNameIterator iter = dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME); while (iter.hasNext()) { String className = iter.nextResourceName(); try { Object o = Class.forName(className).newInstance();
private Resource getNextResource() { while (inputNames.hasNext() && (resources == null || !resources.hasNext())) { resources = findResources(inputNames.nextResourceName()); } return (resources != null && resources.hasNext()) ? resources.nextResource() : null; } };
ResourceNameIterator iter = dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME); while (iter.hasNext()) { String className = iter.nextResourceName(); try { Object o = Class.forName(className).newInstance();
private ResourceClass<T> getNextResource() { while (inputNames.hasNext() && (classes == null || !classes.hasNext())) { classes = findResourceClasses(inputNames.nextResourceName()); } return (classes != null && classes.hasNext()) ? classes.nextResourceClass() : null; } };