Package org.eclipse.sisu.bean
Class LifecycleBuilder
- java.lang.Object
-
- org.eclipse.sisu.bean.LifecycleBuilder
-
final class LifecycleBuilder extends java.lang.Object
BuildsBeanLifecycle
s by searching class hierarchies for JSR250 annotations.
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description LifecycleBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addLifecycleMethods(java.lang.Class<?> clazz)
Adds any declaredPostConstruct
andPreDestroy
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 newBeanLifecycle
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)
-
-
-
Method Detail
-
build
public BeanLifecycle build(java.lang.Class<?> clazz)
Builds a newBeanLifecycle
for the given bean type.- Parameters:
clazz
- The bean type- Returns:
- Lifecycle for the bean
-
addLifecycleMethods
private void addLifecycleMethods(java.lang.Class<?> clazz)
Adds any declaredPostConstruct
andPreDestroy
methods to the current lifecycle.
Ignores methods overridden in subclasses, as well as multiple declarations of each annotation.- Parameters:
clazz
-
-
isOverridden
private boolean isOverridden(java.lang.reflect.Method method)
Tests to see if the given method is overridden in the subclass hierarchy.- Parameters:
method
- The method to test- Returns:
true
if the method was overridden; otherwisefalse
-
isCandidateMethod
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.- Parameters:
method
- The method to test- Returns:
true
if the method is acceptable; otherwisefalse
-
samePackage
private static boolean samePackage(java.lang.reflect.Method lhs, java.lang.reflect.Method rhs)
- Returns:
true
if the methods were declared in the same package; otherwisefalse
-
-