Class LifecycleBuilder

java.lang.Object
org.eclipse.sisu.bean.LifecycleBuilder

final class LifecycleBuilder extends Object
Builds BeanLifecycles by searching class hierarchies for JSR250 annotations.
  • Field Details

    • startMethods

      private final List<Method> startMethods
    • stopMethods

      private final List<Method> stopMethods
    • hierarchy

      private final List<Class<?>> hierarchy
  • Constructor Details

    • LifecycleBuilder

      LifecycleBuilder()
  • Method Details

    • build

      public BeanLifecycle build(Class<?> clazz)
      Builds a new BeanLifecycle for the given bean type.
      Parameters:
      clazz - The bean type
      Returns:
      Lifecycle for the bean
    • addLifecycleMethods

      private void addLifecycleMethods(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.
      Parameters:
      clazz -
    • isOverridden

      private boolean isOverridden(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; otherwise false
    • isCandidateMethod

      private static boolean isCandidateMethod(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; otherwise false
    • samePackage

      private static boolean samePackage(Method lhs, Method rhs)
      Returns:
      true if the methods were declared in the same package; otherwise false