public AnnotationFinder select(Iterable<String> clazz) { return new AnnotationFinder(this, clazz); }
public AnnotationFinder select(Iterable<String> clazz) { return new AnnotationFinder(this, clazz); }
public AnnotationFinder select(Iterable<String> clazz) { return new AnnotationFinder(this, clazz); }
public AnnotationFinder select(String... clazz) { return new AnnotationFinder(this, Arrays.asList(clazz)); }
public AnnotationFinder select(String... clazz) { return new AnnotationFinder(this, Arrays.asList(clazz)); }
public AnnotationFinder select(String... clazz) { return new AnnotationFinder(this, Arrays.asList(clazz)); }
public AnnotationFinder select(Class<?>... clazz) { String[] names = new String[clazz.length]; int i = 0; for (Class<?> name : clazz) { names[i++] = name.getName(); } return new AnnotationFinder(this, Arrays.asList(names)); }
public AnnotationFinder select(Class<?>... clazz) { String[] names = new String[clazz.length]; int i = 0; for (Class<?> name : clazz) { names[i++] = name.getName(); } return new AnnotationFinder(this, Arrays.asList(names)); }
public AnnotationFinder select(Class<?>... clazz) { String[] names = new String[clazz.length]; int i = 0; for (Class<?> name : clazz) { names[i++] = name.getName(); } return new AnnotationFinder(this, Arrays.asList(names)); }
public XbeanScanningLoader(final Archive archive) { final AnnotationFinder finder = new AnnotationFinder(archive); for (final Method method : finder.findAnnotatedMethods(Command.class)) { classes.add(method.getDeclaringClass()); } }
public XbeanScanningLoader(final Archive archive) { final AnnotationFinder finder = new AnnotationFinder(archive); for (final Method method : finder.findAnnotatedMethods(Command.class)) { classes.add(method.getDeclaringClass()); } }
final AnnotationFinder scanner = new AnnotationFinder(archive);
private static void doGenerateSettings(final File file, final PrintWriter writer) { writer.println("== Settings"); writer.println(); new AnnotationFinder(new FileArchive(Thread.currentThread().getContextClassLoader(), file)) .findAnnotatedClasses(DynamicSettings.class).stream() .sorted(Comparator.comparing(Class::getName)) .forEach(s -> buildTree(true, s).childrenValues().forEach(n -> n.write("=== ", writer))); }
/** * Creates a list of the specified class and all its parent * classes then creates a AnnotationFinder from that list which * can be used for easy annotation scanning. * * @param classes * @return */ private AnnotationFinder createFinder(final Class<?>... classes) { final Set<Class<?>> parents = new HashSet<Class<?>>(); for (final Class<?> clazz : classes) { parents.addAll(Classes.ancestors(clazz)); } return new AnnotationFinder(new ClassesArchive(parents)).enableMetaAnnotations(); // no need to have subclasses/impl here }
/** * Creates a list of the specified class and all its parent * classes then creates a AnnotationFinder from that list which * can be used for easy annotation scanning. * * @param classes * @return */ private AnnotationFinder createFinder(final Class<?>... classes) { final Set<Class<?>> parents = new HashSet<Class<?>>(); for (final Class<?> clazz : classes) { parents.addAll(Classes.ancestors(clazz)); } return new AnnotationFinder(new ClassesArchive(parents)).enableMetaAnnotations(); // no need to have subclasses/impl here }
private static void generatedJUnitEnvironment(final File generatedDir) throws MalformedURLException { final File file = new File(generatedDir, "generated_junit-environments.adoc"); try (final PrintStream stream = new PrintStream(new WriteIfDifferentStream(file))) { stream.println(); stream.println("NOTE: the configuration is read from system properties, environment variables, ...."); stream.println(); final File api = jarLocation(BaseEnvironmentProvider.class); final ClassLoader loader = Thread.currentThread().getContextClassLoader(); final AnnotationFinder finder = new AnnotationFinder( api.isDirectory() ? new FileArchive(loader, api) : new JarArchive(loader, api.toURI().toURL())); finder .link() .findSubclasses(BaseEnvironmentProvider.class) .stream() .filter(c -> !Modifier.isAbstract(c.getModifiers())) .sorted(Comparator.comparing(Class::getName)) .forEach(type -> { final BaseEnvironmentProvider environment; try { environment = BaseEnvironmentProvider.class.cast(type.getConstructor().newInstance()); } catch (final InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new IllegalStateException(e); } stream.println(environment.getName() + ":: " + "__class: " + type.getSimpleName() + "_. "); }); stream.println(); } }
@Override protected void doExecute() { final AnnotationFinder finder = new AnnotationFinder(new CompositeArchive(Stream .of(classes) .map(c -> new FileArchive(Thread.currentThread().getContextClassLoader(), c)) .toArray(Archive[]::new))); final List<Class<?>> icons = finder.findAnnotatedClasses(Icon.class); final List<Package> packages = finder.findAnnotatedPackages(Icon.class); if (!icons.isEmpty()) { final List<IconModel> foundIcons = Stream .concat(icons.stream(), packages.stream()) .map(type -> type.getAnnotation(Icon.class)) .map(icon -> { final boolean isCustom = icon.value() == CUSTOM; final String name = isCustom ? icon.custom() : icon.value().getKey(); return new IconModel(project.getArtifactId(), name, findIcon(name), isCustom); }) .collect(toList()); final GlobalReporter reporter = getReporter(); synchronized (reporter) { reporter.icons.addAll(foundIcons); } } }
public void load() { final AnnotationFinder finder = new AnnotationFinder(new CompositeArchive(thisArchive(), cpArchive())).enableFindSubclasses(); for (final Annotated<Class<?>> clazz : finder.findMetaAnnotatedClasses(Editor.class)) { PropertyEditorManager.registerEditor(clazz.getAnnotation(Editor.class).value(), clazz.get()); } } }
private AppModule createTribestreamNotificationCoreModule() { final ClassLoader loader = ParentClassLoaderFinder.Helper.get(); final EjbModule module = new EjbModule(new EjbJar(moduleName), new OpenejbJar()); // activate CDI final Beans beans = new Beans(); beans.addManagedClass(AlterPersisterObserver.class); module.setBeans(beans); // find all from current jar final File jar = JarLocation.jarLocation(Installer.class); try { module.setFinder(new AnnotationFinder( new FilteredArchive( jar.isDirectory() ? new FileArchive(loader, jar) : new JarArchive(loader, jar.toURI().toURL()), Filters.packages("com.tomitribe.tribestream.notifications.core"))) .link()); } catch (final MalformedURLException e) { throw new IllegalStateException(e); } // add unit for persistence final PersistenceUnit unit = new PersistenceUnit(unitName); unit.setJtaDataSource(dataSourceName); unit.setNonJtaDataSource(dataSourceName + "NonJta"); unit.addClass(Alert.class); unit.setExcludeUnlistedClasses(true); unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); // here we are, assemble eveything final AppModule appModule = new AppModule(module); appModule.addPersistenceModule(new PersistenceModule("", new Persistence(unit))); return appModule; }
private AppModule createTribestreamCoreModule() { final ClassLoader loader = ParentClassLoaderFinder.Helper.get(); final EjbModule module = new EjbModule(new EjbJar(moduleName), new OpenejbJar()); // activate CDI final Beans beans = new Beans(); module.setBeans(beans); // find all from current jar final File jar = JarLocation.jarLocation(SignaturesService.class); try { module.setFinder(new AnnotationFinder( new FilteredArchive( jar.isDirectory() ? new FileArchive(loader, jar) : new JarArchive(loader, jar.toURI().toURL()), Filters.packages("com.tomitribe.tribestream.security.signatures"))) .link()); } catch (final MalformedURLException e) { throw new IllegalStateException(e); } // add unit for persistence final PersistenceUnit unit = new PersistenceUnit(unitName); unit.setJtaDataSource(dataSourceName); unit.setNonJtaDataSource(dataSourceName + "NonJta"); unit.addClass(KeyId.class); unit.addClass(Key.class); unit.setExcludeUnlistedClasses(true); unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); // here we are, assemble everything final AppModule appModule = new AppModule(module); appModule.addPersistenceModule(new PersistenceModule("", new Persistence(unit))); return appModule; }