Examples of AnnotationTypeFilter


Examples of org.springframework.core.type.filter.AnnotationTypeFilter

  public void testNonInheritedAnnotationDoesNotMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);

    AnnotationTypeFilter filter = new AnnotationTypeFilter(NonInheritedAnnotation.class);
    // Must fail as annotation isn't inherited
    assertFalse(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

  public void testNonAnnotatedClassDoesntMatch() throws Exception {
    MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
    String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTests$SomeNonCandidateClass";
    MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest);

    AnnotationTypeFilter filter = new AnnotationTypeFilter(Component.class);
    assertFalse(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

    assertEquals(0, candidates.size());
  }

  public void testWithComponentAnnotationOnly() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
    provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class));
    provider.addExcludeFilter(new AnnotationTypeFilter(Service.class));
    provider.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
    Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
    assertEquals(6, candidates.size());
    assertTrue(containsBeanClass(candidates, NamedComponent.class));
    assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class));
    assertFalse(containsBeanClass(candidates, FooServiceImpl.class));
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

  }

  @SuppressWarnings("unchecked")
  public void testWithAspectAnnotationOnly() throws Exception {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.addIncludeFilter(new AnnotationTypeFilter(
        ClassUtils.forName("org.aspectj.lang.annotation.Aspect")));
    Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
    assertEquals(1, candidates.size());
    assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class));
  }
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

    assertTrue(containsBeanClass(candidates, MessageBean.class));
  }

  public void testWithMultipleMatchingFilters() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
    provider.addIncludeFilter(new AssignableTypeFilter(FooServiceImpl.class));
    Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
    assertEquals(9, candidates.size());
    assertTrue(containsBeanClass(candidates, NamedComponent.class));
    assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class));
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

    assertTrue(containsBeanClass(candidates, FooServiceImpl.class));
  }

  public void testExcludeTakesPrecedence() {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
    provider.addIncludeFilter(new AssignableTypeFilter(FooServiceImpl.class));
    provider.addExcludeFilter(new AssignableTypeFilter(FooService.class));
    Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
    assertEquals(8, candidates.size());
    assertTrue(containsBeanClass(candidates, NamedComponent.class));
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

   * {@link Component @Component} meta-annotation including the
   * {@link Repository @Repository}, {@link Service @Service}, and
   * {@link Controller @Controller} stereotype annotations.
   */
  protected void registerDefaultFilters() {
    this.includeFilters.add(new AnnotationTypeFilter(Component.class));
  }
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

  protected TypeFilter createTypeFilter(Element element, ClassLoader classLoader) {
    String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE);
    String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE);
    try {
      if ("annotation".equals(filterType)) {
        return new AnnotationTypeFilter((Class<Annotation>) classLoader.loadClass(expression));
      }
      else if ("assignable".equals(filterType)) {
        return new AssignableTypeFilter(classLoader.loadClass(expression));
      }
      else if ("aspectj".equals(filterType)) {
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

    private static final Log log = LogFactory.getLog(DwrClassPathBeanDefinitionScanner.class);

    public DwrClassPathBeanDefinitionScanner(BeanDefinitionRegistry registry)
    {
        super(registry, false);
        addExcludeFilter(new AnnotationTypeFilter(Component.class));
        addExcludeFilter(new AnnotationTypeFilter(Service.class));
        addExcludeFilter(new AnnotationTypeFilter(Repository.class));
        addExcludeFilter(new AnnotationTypeFilter(Controller.class));
        setScopedProxyMode(ScopedProxyMode.INTERFACES);
    }
View Full Code Here

Examples of org.springframework.core.type.filter.AnnotationTypeFilter

        {
            scanProxies = Boolean.parseBoolean(proxies);
        }
        if (scanProxies)
        {
            scanner.addIncludeFilter(new AnnotationTypeFilter(RemoteProxy.class));
        }
        String conv = element.getAttribute("scanDataTransferObject");
        if (hasText(conv) && ("TRUE".equals(conv.toUpperCase()) || "FALSE".equals(conv.toUpperCase())))
        {
            scanConverters = Boolean.parseBoolean(conv);
        }
        if (scanConverters)
        {
            scanner.addIncludeFilter(new AnnotationTypeFilter(DataTransferObject.class));
        }
        String filters = element.getAttribute("scanGlobalFilter");
        if (hasText(filters) && ("TRUE".equals(filters.toUpperCase()) || "FALSE".equals(filters.toUpperCase())))
        {
            scanFilters = Boolean.parseBoolean(filters);
        }
        if (scanFilters)
        {
            scanner.addIncludeFilter(new AnnotationTypeFilter(GlobalFilter.class));
        }
        if (scanProxies | scanConverters | scanFilters)
        {
            scanner.scan(basePackage == null ? "" : basePackage);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.