|
29 | 29 | * 2016/11/11/011 |
30 | 30 | */ |
31 | 31 | public class ApplicationX { |
32 | | - private static final AtomicInteger SHUTDOWN_HOOKID_INCR = new AtomicInteger(); |
| 32 | + private static final AtomicInteger SHUTDOWN_HOOK_ID_INCR = new AtomicInteger(); |
33 | 33 | private static final Method[] EMPTY_METHOD_ARRAY = {}; |
34 | 34 | private static final PropertyDescriptor[] EMPTY_DESCRIPTOR_ARRAY = {}; |
35 | 35 | private static final Constructor<ConcurrentMap> CONCURRENT_REFERENCE_MAP_CONSTRUCTOR = getAnyConstructor( |
@@ -63,6 +63,7 @@ public class ApplicationX { |
63 | 63 | private final Collection<Class<? extends Annotation>> factoryMethodAnnotations = new LinkedHashSet<>( |
64 | 64 | Arrays.asList(Bean.class)); |
65 | 65 | private final Collection<String> beanSkipLifecycles = new LinkedHashSet<>(8); |
| 66 | + //BeanPostProcessor接口是为了将每个bean的处理阶段的处理, 抽象成接口, 让用户可以根据不同需求不同处理. 比如自动注入,AOP,定时任务,异步注解,servlet注入,错误页注册 |
66 | 67 | private final Collection<BeanPostProcessor> beanPostProcessors = new TreeSet<>(new OrderComparator(orderedAnnotations)); |
67 | 68 | private final Map<String,BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<>(64); |
68 | 69 | private final Map<Class,String[]> beanNameMap = new ConcurrentHashMap<>(64); |
@@ -97,7 +98,7 @@ public ApplicationX(Supplier<ClassLoader> resourceLoader) { |
97 | 98 | addInstance(this); |
98 | 99 | addBeanPostProcessor(new RegisteredBeanPostProcessor(this)); |
99 | 100 | addBeanPostProcessor(new AutowiredConstructorPostProcessor(this)); |
100 | | - Runtime.getRuntime().addShutdownHook(new Thread(this::shutdownHook,"app.shutdownHook-"+SHUTDOWN_HOOKID_INCR.getAndIncrement())); |
| 101 | + Runtime.getRuntime().addShutdownHook(new Thread(this::shutdownHook,"app.shutdownHook-"+ SHUTDOWN_HOOK_ID_INCR.getAndIncrement())); |
101 | 102 | } |
102 | 103 |
|
103 | 104 | public static void main(String[] args) throws Exception { |
|
0 commit comments