Example usage for org.springframework.core.type.filter AnnotationTypeFilter AnnotationTypeFilter

List of usage examples for org.springframework.core.type.filter AnnotationTypeFilter AnnotationTypeFilter

Introduction

In this page you can find the example usage for org.springframework.core.type.filter AnnotationTypeFilter AnnotationTypeFilter.

Prototype

public AnnotationTypeFilter(Class<? extends Annotation> annotationType) 

Source Link

Document

Create a new AnnotationTypeFilter for the given annotation type.

Usage

From source file:name.marcelomorales.siqisiqi.openjpa.spring.SpringRegistrar.java

public static void registerEntities(EntityRepository provider, String... basePackage) {
    for (String pack : basePackage) {
        ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
                false);/* ww  w  . j  a va2  s. c  o m*/

        scanner.addIncludeFilter(new AnnotationTypeFilter(Entity.class));

        for (BeanDefinition bd : scanner.findCandidateComponents(pack)) {
            try {
                final Class<?> aClass = Class.forName(bd.getBeanClassName());
                LOGGER.info("Adding {} to entity repository", aClass);
                provider.register(aClass);
            } catch (ClassNotFoundException e) {
                LOGGER.error("Error", e);
            }
        }
    }
}

From source file:com.jk.annotations.AnnotationDetector.java

/**
 * Utility method to scan the given package and handler for the annotation
 * of the given class. Its uses the Spring annotation detector
 *
 * @param clas/*from  ww w .ja v a 2s .  c  o m*/
 *            the clas
 * @param basePackage
 *            the base package
 * @param handler
 *            the handler
 */
public static void scan(final Class<? extends Annotation> clas, final String[] basePackage,
        final AnnotationHandler handler) {
    final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
            false);
    scanner.setResourceLoader(
            new PathMatchingResourcePatternResolver(Thread.currentThread().getContextClassLoader()));
    scanner.addIncludeFilter(new AnnotationTypeFilter(clas));
    for (final String pck : basePackage) {
        for (final BeanDefinition bd : scanner.findCandidateComponents(pck)) {
            handler.handleAnnotationFound(bd.getBeanClassName());
        }
    }
}

From source file:org.lightadmin.core.config.bootstrap.scanning.AdministrationClassScanner.java

public AdministrationClassScanner() {
    super(new AnnotationTypeFilter(Administration.class),
            new AssignableTypeFilter(AdministrationConfiguration.class));
}

From source file:com.ethercis.servicemanager.service.ServiceClassScanner.java

public ServiceClassScanner() {
    super(false);
    addIncludeFilter(new AnnotationTypeFilter(Service.class));
}

From source file:org.elasticsoftware.elasticactors.spring.ActorSystemApplicationContextInitializer.java

@Override
public void initialize(AnnotationConfigWebApplicationContext applicationContext) {
    // ensure the EA annotations are scanned
    applicationContext.addIncludeFilters(new AnnotationTypeFilter(ServiceActor.class));
    // generate correct names for ServiceActor annotated actors
    applicationContext.setBeanNameGenerator(new ActorAnnotationBeanNameGenerator());
    // add all the elastic actors base packages to the scan configuration
    applicationContext.scan(ScannerHelper.findBasePackagesOnClasspath(applicationContext.getClassLoader()));
}

From source file:com.oembedler.moon.graphql.engine.GraphQLSchemaDiscoverer.java

public static Set<Class<?>> findSchemaClasses(final String basePackage) throws ClassNotFoundException {

    Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();

    if (StringUtils.hasText(basePackage)) {
        ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
                false);// ww  w.j av  a 2s .  c om
        componentProvider.addIncludeFilter(new AnnotationTypeFilter(GRAPH_QL_SCHEMA_ANNOTATION));

        for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
            initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(),
                    GraphQLSchemaDiscoverer.class.getClassLoader()));
        }
    }
    return initialEntitySet;
}

From source file:com.p5solutions.core.jpa.orm.annotations.EntityAnnotationScanner.java

public EntityAnnotationScanner() {
    super();
    addIncludeFilter(new AnnotationTypeFilter(Entity.class));
}

From source file:com.baidu.terminator.register.scanner.AnnotationScanner.java

@SuppressWarnings("unchecked")
public List<Class<? extends T>> scanAnnotatedClass() {
    List<Class<? extends T>> classList = new ArrayList<Class<? extends T>>();

    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
            false);/*from  ww w  . ja v a2  s  .  c  om*/
    scanner.addIncludeFilter(new AnnotationTypeFilter(annotationType));
    Set<BeanDefinition> components = scanner.findCandidateComponents(scannerPackage);

    for (BeanDefinition bd : components) {
        String className = bd.getBeanClassName();
        try {
            Class<? extends T> clazz = (Class<? extends T>) Class.forName(className);
            classList.add(clazz);
        } catch (ClassNotFoundException e) {
            LOGGER.warn("can not find class" + className, e.getCause());
        }
    }
    return classList;
}

From source file:com.clicktravel.cheddar.server.rest.resource.config.RestResourceConfig.java

public RestResourceConfig() {
    scanner = new ClassPathScanningCandidateComponentProvider(true);
    scanner.resetFilters(false);/*from  w  w w.j  a  v  a  2s.  c  om*/
    scanner.addIncludeFilter(new AnnotationTypeFilter(Path.class));
    scanner.addIncludeFilter(new AnnotationTypeFilter(Provider.class));
    register(RequestContextFilter.class);
    register(MultiPartFeature.class);
    registerResources("com.clicktravel.cheddar.rest.exception.mapper",
            "com.clicktravel.cheddar.server.http.filter", "com.clicktravel.cheddar.server.rest.resource.status",
            "com.clicktravel.services");
}

From source file:org.codehaus.grepo.core.config.GenericRepositoryBeanDefinitionScanner.java

/**
 * @param genericRepositoryType The generic repository interface.
 *///from   ww w.  ja  va2s.  c om
public GenericRepositoryBeanDefinitionScanner(Class<?> genericRepositoryType) {
    super(false);

    if (genericRepositoryType != null) {
        // Note: we add default type filter which finds repositories which are of approriate
        // interface type and annotated with the Repository annotation
        CompositeTypeFilter typeFilter = new CompositeTypeFilter();
        typeFilter.addTypeFilters(new AssignableTypeFilter(genericRepositoryType),
                new AnnotationTypeFilter(Repository.class));
        addIncludeFilter(typeFilter);
    }
}