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
 
 public abstract class AbstractLightyModule extends Object implements LightyModule This abstract class implementLightyModuleinterface with synchronization ofLightyModule.start(),LightyModule.startBlocking()andLightyModule.shutdown()methods. Users who don't want to implement their own synchronization can extend this class and provide justinitProcedure()andstopProcedure()methods.These methods will be then automatically called instart(),startBlocking()andshutdown()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 Constructor Description AbstractLightyModule()AbstractLightyModule(ExecutorService executorService)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleaninitProcedure()This method is called instart()method.com.google.common.util.concurrent.ListenableFuture<Boolean>shutdown()Shutdown module.com.google.common.util.concurrent.ListenableFuture<Boolean>start()Start in background and return immediately.voidstartBlocking()Start and block until shutdown is requested.voidstartBlocking(Consumer<Boolean> initFinishCallback)Start and block until shutdown is requested.protected abstract booleanstopProcedure()This method is called inshutdown()method.
 
- 
- 
- 
Constructor Detail- 
AbstractLightyModulepublic AbstractLightyModule(ExecutorService executorService) 
 - 
AbstractLightyModulepublic AbstractLightyModule() 
 
- 
 - 
Method Detail- 
initProcedureprotected abstract boolean initProcedure() throws InterruptedExceptionThis method is called instart()method. Implementation of this method should initialize everything necessary.- Returns:
- success of initialization
- Throws:
- InterruptedException- if initialization was interrupted.
 
 - 
stopProcedureprotected abstract boolean stopProcedure() throws InterruptedExceptionThis 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.
 
 - 
startpublic com.google.common.util.concurrent.ListenableFuture<Boolean> start() Description 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.
 
 - 
startBlockingpublic void startBlocking() throws InterruptedExceptionDescription copied from interface:LightyModuleStart and block until shutdown is requested.- Specified by:
- startBlockingin interface- LightyModule
- Throws:
- InterruptedException- thrown in case module initialization fails.
 
 - 
startBlockingpublic void startBlocking(Consumer<Boolean> initFinishCallback) throws InterruptedException Start 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.
 
 - 
shutdownpublic com.google.common.util.concurrent.ListenableFuture<Boolean> shutdown() Description copied from interface:LightyModuleShutdown module.- Specified by:
- shutdownin interface- LightyModule
- Returns:
- true if module shutdown was successful, false or exception otherwise.
 
 
- 
 
-