Examples of AnnotationTypeFilter


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

  }

  public void testCustomIncludeFilterWithoutDefaultsButIncludingPostProcessors() {
    GenericApplicationContext context = new GenericApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class));
    int beanCount = scanner.scan(BASE_PACKAGE);
    assertEquals(5, beanCount);
    assertTrue(context.containsBean("messageBean"));
    assertTrue(context.containsBean(AnnotationConfigUtils.AUTOWIRED_ANNOTATION_PROCESSOR_BEAN_NAME));
    assertTrue(context.containsBean(AnnotationConfigUtils.COMMON_ANNOTATION_PROCESSOR_BEAN_NAME));
View Full Code Here

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

  }

  public void testCustomIncludeFilterWithoutDefaultsAndNoPostProcessors() {
    GenericApplicationContext context = new GenericApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class));
    int beanCount = scanner.scan(BASE_PACKAGE);
    assertEquals(5, beanCount);
    assertTrue(context.containsBean("messageBean"));
    assertFalse(context.containsBean("serviceInvocationCounter"));
    assertFalse(context.containsBean("fooServiceImpl"));
View Full Code Here

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

  }

  public void testCustomIncludeFilterAndDefaults() {
    GenericApplicationContext context = new GenericApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true);
    scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class));
    int beanCount = scanner.scan(BASE_PACKAGE);
    assertEquals(14, beanCount);
    assertTrue(context.containsBean("messageBean"));
    assertTrue(context.containsBean("serviceInvocationCounter"));
    assertTrue(context.containsBean("fooServiceImpl"));
View Full Code Here

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

  }

  public void testCustomAnnotationExcludeFilterAndDefaults() {
    GenericApplicationContext context = new GenericApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true);
    scanner.addExcludeFilter(new AnnotationTypeFilter(Aspect.class));
    int beanCount = scanner.scan(BASE_PACKAGE);
    assertEquals(12, beanCount);
    assertFalse(context.containsBean("serviceInvocationCounter"));
    assertTrue(context.containsBean("fooServiceImpl"));
    assertTrue(context.containsBean("stubFooDao"));
View Full Code Here

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

  public void testMultipleCustomExcludeFiltersAndDefaults() {
    GenericApplicationContext context = new GenericApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true);
    scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class));
    scanner.addExcludeFilter(new AnnotationTypeFilter(Aspect.class));
    int beanCount = scanner.scan(BASE_PACKAGE);
    assertEquals(11, beanCount);
    assertFalse(context.containsBean("fooServiceImpl"));
    assertFalse(context.containsBean("serviceInvocationCounter"));
    assertTrue(context.containsBean("stubFooDao"));
View Full Code Here

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

  private ApplicationContext createContext(ScopedProxyMode scopedProxyMode) {
    GenericWebApplicationContext context = new GenericWebApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false);
    scanner.setIncludeAnnotationConfig(false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(ScopeTestComponent.class));
    scanner.setBeanNameGenerator(new BeanNameGenerator() {
      public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
        String beanClassName = ClassUtils.getShortName(definition.getBeanClassName());
        int begin = beanClassName.lastIndexOf('.') + 1;
        int end = beanClassName.lastIndexOf("ScopedTestBean");
View Full Code Here

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

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

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

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

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

    AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
    // Must fail as annotation on interfaces should not be considered a match
    assertFalse(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }
View Full Code Here

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

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

    AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class);
    assertTrue(filter.match(metadataReader, metadataReaderFactory));
    ClassloadingAssertions.assertClassNotLoaded(classUnderTest);
  }
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.