Package com.example

Source Code of com.example.WithNestedAnnotation

package com.example;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.stereotype.Component;

public class ComponentScanTest {

  @Test
  public void withScanner() {
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(bf);
    scanner.scan("com.example");
    for (String name : bf.getBeanDefinitionNames()) {
      //System.out.println(name);
    }
  }

  @Test
  public void withACAC() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan("com.example");
    ctx.refresh();
  }

}

@Component
class WithNestedAnnotation {

  @Target({ ElementType.TYPE })
  @Retention(RetentionPolicy.RUNTIME)
  @Documented
  @Component
  public static @interface MyComponent {

    String value() default "";
  }
}
TOP

Related Classes of com.example.WithNestedAnnotation

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.