ResourceFinder finder = new ResourceFinder("META-INF/services/"); List<Class<? extends Plugin>> impls = finder.findAllImplementations(Plugin.class);
ResourceFinder finder = new ResourceFinder("META-INF/"); Map<String, Class<? extends URLStreamHandler>> handlers = finder.mapAllImplementations(URLStreamHandler.class); Class<? extends URLStreamHandler> fooHandler = handlers.get("foo");
@Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { AnnotationInfo annotationInfo = new AnnotationInfo(desc); info.getAnnotations().add(annotationInfo); getAnnotationInfos(annotationInfo.getName()).add(info); return new InfoBuildingVisitor(annotationInfo, classFinder); }
ResourceFinder finder = new ResourceFinder("META-INF/"); Map<String,Properties> plugins = finder.mapAllProperties(Plugin.class.getName()); Properties redDefinition = plugins.get("red");
@Override public AnnotationVisitor visitAnnotation(String desc, boolean visible) { AnnotationInfo annotationInfo = new AnnotationInfo(desc); info.getAnnotations().add(annotationInfo); getAnnotationInfos(annotationInfo.getName()).add(info); return null; }
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { ClassInfo classInfo = ((ClassInfo) info); FieldInfo fieldInfo = new FieldInfo(classInfo, name, desc); classInfo.getFields().add(fieldInfo); return new InfoBuildingVisitor(fieldInfo, classFinder); }
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { ClassInfo classInfo = ((ClassInfo) info); MethodInfo methodInfo = new MethodInfo(classInfo, name, desc); classInfo.getMethods().add(methodInfo); return new InfoBuildingVisitor(methodInfo, classFinder); }
@Override public AnnotationVisitor visitParameterAnnotation(int param, String desc, boolean visible) { MethodInfo methodInfo = ((MethodInfo) info); List<AnnotationInfo> annotationInfos = methodInfo.getParameterAnnotations(param); AnnotationInfo annotationInfo = new AnnotationInfo(desc); annotationInfos.add(annotationInfo); return new InfoBuildingVisitor(annotationInfo, classFinder); } }
URL url = new File("some.jar").toURI().toURL(); ResourceFinder finder = new ResourceFinder("META-INF/services/", url);
@Override public AnnotationVisitor visitParameterAnnotation(int param, String desc, boolean visible) { MethodInfo methodInfo = ((MethodInfo) info); List<AnnotationInfo> annotationInfos = methodInfo.getParameterAnnotations(param); AnnotationInfo annotationInfo = new AnnotationInfo(desc); annotationInfos.add(annotationInfo); return null; } }
public PackageInfo(String name, ClassFinder classFinder) { info = new ClassInfo(name, null, classFinder); this.name = name; this.pkg = null; }
private URL getResource(String fullUri) { if (urls == null){ return classLoaderInterface.getResource(fullUri); } return findResource(fullUri, urls); }
public Class get() throws ClassNotFoundException { if (clazz != null) return clazz; if (notFound != null) throw notFound; try { this.clazz = classFinder.getClassLoaderInterface().loadClass(name); return clazz; } catch (ClassNotFoundException notFound) { classFinder.getClassesNotLoaded().add(name); this.notFound = notFound; throw notFound; } }
/** * Executes {@link #findString(String)} assuming the contents URL found is the name of * a class that should be loaded and returned. * * @param uri * @return * @throws IOException * @throws ClassNotFoundException */ public Class findClass(String uri) throws IOException, ClassNotFoundException { String className = findString(uri); return (Class) classLoaderInterface.loadClass(className); }
/** * Ignores all URLs that are not "jar" or "file" * @param urls */ public UrlSet(Collection<URL> urls){ this(); load(urls); }
public PackageInfo(String name, ClassFinder classFinder) { info = new ClassInfo(name, null, classFinder); this.name = name; this.pkg = null; }
public PackageInfo(String name, ClassFinder classFinder) { info = new ClassInfo(name, null, classFinder); this.name = name; this.pkg = null; }