final class LifecycleBuilder
extends java.lang.Object
BeanLifecycle
s by searching class hierarchies for JSR250 annotations.Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.Class<?>> |
hierarchy |
private java.util.List<java.lang.reflect.Method> |
startMethods |
private java.util.List<java.lang.reflect.Method> |
stopMethods |
Constructor and Description |
---|
LifecycleBuilder() |
Modifier and Type | Method and Description |
---|---|
private void |
addLifecycleMethods(java.lang.Class<?> clazz)
Adds any declared
PostConstruct and PreDestroy methods to the current lifecycle.Ignores methods overridden in subclasses, as well as multiple declarations of each annotation. |
BeanLifecycle |
build(java.lang.Class<?> clazz)
Builds a new
BeanLifecycle for the given bean type. |
private static boolean |
isCandidateMethod(java.lang.reflect.Method method)
Tests to see if this method is a lifecycle candidate: void return, not static/abstract, no parameters.
|
private boolean |
isOverridden(java.lang.reflect.Method method)
Tests to see if the given method is overridden in the subclass hierarchy.
|
private static boolean |
samePackage(java.lang.reflect.Method lhs,
java.lang.reflect.Method rhs) |
private final java.util.List<java.lang.reflect.Method> startMethods
private final java.util.List<java.lang.reflect.Method> stopMethods
private final java.util.List<java.lang.Class<?>> hierarchy
public BeanLifecycle build(java.lang.Class<?> clazz)
BeanLifecycle
for the given bean type.clazz
- The bean typeprivate void addLifecycleMethods(java.lang.Class<?> clazz)
PostConstruct
and PreDestroy
methods to the current lifecycle.clazz
- private boolean isOverridden(java.lang.reflect.Method method)
method
- The method to testtrue
if the method was overridden; otherwise false
private static boolean isCandidateMethod(java.lang.reflect.Method method)
method
- The method to testtrue
if the method is acceptable; otherwise false
private static boolean samePackage(java.lang.reflect.Method lhs, java.lang.reflect.Method rhs)
true
if the methods were declared in the same package; otherwise false