Class ReflectionLifecycleStrategy

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose​(java.lang.Object component)
      Invoke the "dispose" method on the component instance if this is disposable.
      boolean hasLifecycle​(java.lang.Class<?> type)
      Test if a component instance has a lifecycle.
      protected void monitorAndThrowReflectionLifecycleException​(java.lang.reflect.Method method, java.lang.Throwable e, java.lang.Object component)  
      void start​(java.lang.Object component)
      Invoke the "start" method on the component instance if this is startable.
      void stop​(java.lang.Object component)
      Invoke the "stop" method on the component instance if this is stoppable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReflectionLifecycleStrategy

        public ReflectionLifecycleStrategy​(ComponentMonitor monitor)
        Construct a ReflectionLifecycleStrategy.
        Parameters:
        monitor - the monitor to use
        Throws:
        java.lang.NullPointerException - if the monitor is null
      • ReflectionLifecycleStrategy

        public ReflectionLifecycleStrategy​(ComponentMonitor monitor,
                                           java.lang.String startMethodName,
                                           java.lang.String stopMethodName,
                                           java.lang.String disposeMethodName)
        Construct a ReflectionLifecycleStrategy with individual method names. Note, that a lifecycle method does not have any arguments.
        Parameters:
        monitor - the monitor to use
        startMethodName - the name of the start method
        stopMethodName - the name of the stop method
        disposeMethodName - the name of the dispose method
        Throws:
        java.lang.NullPointerException - if the monitor is null
    • Method Detail

      • start

        public void start​(java.lang.Object component)
        Invoke the "start" method on the component instance if this is startable. It is up to the implementation of the strategy what "start" and "startable" means.
        Parameters:
        component - the instance of the component to start
      • stop

        public void stop​(java.lang.Object component)
        Invoke the "stop" method on the component instance if this is stoppable. It is up to the implementation of the strategy what "stop" and "stoppable" means.
        Parameters:
        component - the instance of the component to stop
      • dispose

        public void dispose​(java.lang.Object component)
        Invoke the "dispose" method on the component instance if this is disposable. It is up to the implementation of the strategy what "dispose" and "disposable" means.
        Parameters:
        component - the instance of the component to dispose
      • monitorAndThrowReflectionLifecycleException

        protected void monitorAndThrowReflectionLifecycleException​(java.lang.reflect.Method method,
                                                                   java.lang.Throwable e,
                                                                   java.lang.Object component)
      • hasLifecycle

        public boolean hasLifecycle​(java.lang.Class<?> type)
        Test if a component instance has a lifecycle. The component has a lifecycle if at least one of the three methods is present.
        Parameters:
        type - the component's type
        Returns:
        true if the component has a lifecycle