Package io.lighty.core.controller.api
Class AbstractLightyModule
java.lang.Object
io.lighty.core.controller.api.AbstractLightyModule
- All Implemented Interfaces:
- LightyModule
- Direct Known Subclasses:
- LightyControllerImpl
This abstract class implement 
LightyModule interface with
 synchronization of LightyModule.start(),
 LightyModule.startBlocking() and LightyModule.shutdown()
 methods. Users who don't want to implement their own synchronization
 can extend this class and provide just
 initProcedure() and
 stopProcedure() methods.These methods
 will be then automatically called in
 start(),
 startBlocking() and
 shutdown() methods.
 Example usage:
 
     public class MyLightyModule extends AbstractLightyModule {
         private SomeBean someBean;
         ...
        @Override
         protected boolean initProcedure() {
             this.someBean = new SomeBean();
             boolean success = this.someBean.init();
             return success;
         }
        @Override
         protected boolean stopProcedure() {
             boolean stopSuccess = this.someBean.stop();
             this.someBean = null;
             return stopSuccess;
         }
     }
 
 - Author:
- andrej.zan
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract booleanThis method is called instart()method.com.google.common.util.concurrent.ListenableFuture<Boolean>shutdown()Shutdown module.final booleanShutdown module and wait for completion for specified amount of time.com.google.common.util.concurrent.ListenableFuture<Boolean>start()Start in background and return immediately.voidStart and block until shutdown is requested.voidstartBlocking(Consumer<Boolean> initFinishCallback) Start and block until shutdown is requested.protected abstract booleanThis method is called inshutdown()method.
- 
Constructor Details- 
AbstractLightyModule
- 
AbstractLightyModulepublic AbstractLightyModule()
 
- 
- 
Method Details- 
initProcedureThis method is called instart()method. Implementation of this method should initialize everything necessary.- Returns:
- success of initialization
- Throws:
- InterruptedException- if initialization was interrupted.
 
- 
stopProcedureThis method is called inshutdown()method. Implementation of this method should do everything necessary to shutdown correctly (e.g. stop initialized beans, release resources, ...).- Returns:
- success of stop.
- Throws:
- InterruptedException- if stopping was interrupted.
 
- 
startDescription copied from interface:LightyModuleStart in background and return immediately.- Specified by:
- startin interface- LightyModule
- Returns:
- true if module initialization was successful, false or exception otherwise.
 
- 
startBlockingDescription copied from interface:LightyModuleStart and block until shutdown is requested.- Specified by:
- startBlockingin interface- LightyModule
- Throws:
- InterruptedException- thrown in case module initialization fails.
 
- 
startBlockingStart and block until shutdown is requested.- Parameters:
- initFinishCallback- callback that will be called after start is completed.
- Throws:
- InterruptedException- thrown in case module initialization fails.
 
- 
shutdownDescription copied from interface:LightyModuleShutdown module.- Specified by:
- shutdownin interface- LightyModule
- Returns:
- true if module shutdown was successful, false or exception otherwise.
 
- 
shutdownDescription copied from interface:LightyModuleShutdown module and wait for completion for specified amount of time.- Specified by:
- shutdownin interface- LightyModule
- Parameters:
- duration- duration of time to wait for completion
- unit- unit of time duration
- Returns:
- true if module shutdown was successful in specified time, false otherwise.
 
 
-