use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class ClassAnnotationFinderTest method checkClassAnnotationOnConstructorDefaults.
@Test
public void checkClassAnnotationOnConstructorDefaults() {
final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(ClassAnnotatedClass.class, NotAnnotated.class));
final List<Constructor> annotations = finder.findAnnotatedConstructors(ClassAnnotation.class);
assertEquals(0, annotations.size());
}
use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class ClassAnnotationFinderTest method checkClassAnnotationOnConstructor.
@Test
public void checkClassAnnotationOnConstructor() throws Exception {
final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(ClassAnnotatedClass.class, NotAnnotated.class), false);
final List<Constructor> annotations = finder.findAnnotatedConstructors(ClassAnnotation.class);
assertEquals(1, annotations.size());
assertEquals(ClassAnnotatedClass.class.getDeclaredConstructor(), annotations.get(0));
}
use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class ClassAnnotationFinderTest method checkClassAnnotationIsNotFound.
@Test
public void checkClassAnnotationIsNotFound() {
final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(ClassAnnotatedClass.class, NotAnnotated.class));
final List<Class<?>> annotations = finder.findAnnotatedClasses(ClassAnnotation.class);
assertEquals(0, annotations.size());
}
use of org.apache.xbean.finder.archive.ClassesArchive in project geronimo-xbean by apache.
the class ClassAnnotationFinderTest method checkClassAnnotationOnMethodDefaults.
@Test
public void checkClassAnnotationOnMethodDefaults() {
final AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(ClassAnnotatedClass.class, NotAnnotated.class));
final List<Method> annotations = finder.findAnnotatedMethods(ClassAnnotation.class);
assertEquals(0, annotations.size());
}
use of org.apache.xbean.finder.archive.ClassesArchive in project tomee by apache.
the class ApplicationComposers method finderFromClasses.
private static IAnnotationFinder finderFromClasses(final DeploymentModule module, final Class<?>[] value, final Collection<File> others, final String[] excludes) {
final Collection<Archive> archives = new ArrayList<>(1 + (others == null ? 0 : others.size()));
final Filter filter = excludes == null || excludes.length == 0 ? null : Filters.invert(Filters.prefixes(excludes));
final Collection<Class<?>> classes = new ArrayList<>(asList(FinderFactory.ensureMinimalClasses(module)));
if (value != null) {
classes.addAll(asList(value));
}
final ClassesArchive classesArchive = new ClassesArchive(classes);
archives.add(filter == null ? classesArchive : new FilteredArchive(classesArchive, filter));
if (others != null) {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
for (final File f : others) {
try {
final Archive archive = f.isDirectory() ? new FileArchive(classLoader, f) : new JarArchive(classLoader, f.toURI().toURL());
archives.add(filter == null ? archive : new FilteredArchive(archive, filter));
} catch (final MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}
}
return new FinderFactory.OpenEJBAnnotationFinder(new CompositeArchive(archives)).link();
}
Aggregations