Package ninja.standalone
Class AbstractConsole<T extends AbstractConsole>
- java.lang.Object
-
- ninja.standalone.AbstractConsole<T>
-
- Type Parameters:
T- The concrete console implementation
- All Implemented Interfaces:
Console<T>
- Direct Known Subclasses:
AbstractStandalone,NinjaConsole
public abstract class AbstractConsole<T extends AbstractConsole> extends Object implements Console<T>
Abstract Console that implements most functionality required to write a concrete Console. See NinjaConsole for example concrete implementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanconfiguredprotected Optional<String>externalConfigurationPathprotected org.slf4j.Loggerloggerprotected Stringnameprotected NinjaModeninjaModeprotected NinjaPropertiesImplninjaPropertiesprotected OverlayedNinjaPropertiesoverlayedNinjaPropertiesprotected Optional<com.google.inject.Module>overrideModuleOptprotected Optional<Map<String,String>>overridePropertiesOptprotected booleanstarted
-
Constructor Summary
Constructors Constructor Description AbstractConsole(String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckConfigured()protected voidcheckNotConfigured()protected voidcheckStarted()Tconfigure()Configures the standalone to prepare for being started.protected abstract voiddoConfigure()protected voiddoPostConfigure()protected voiddoPreConfigure()protected abstract voiddoShutdown()protected abstract voiddoStart()TexternalConfigurationPath(String externalConfigurationPath)Optional<String>getExternalConfigurationPath()StringgetName()NinjaModegetNinjaMode()NinjaPropertiesImplgetNinjaProperties()Gets the NinjaProperties that were used to configure Ninja.protected voidlogStarted()Tname(String name)TninjaMode(NinjaMode ninjaMode)ToverrideModule(com.google.inject.Module overrideModule)Override Guice module bindings as described here: https://google.github.io/guice/api-docs/3.0/javadoc/com/google/inject/util/Modules.htmlToverrideProperties(Map<String,String> overrideProperties)Override specific properties programmatically.Tshutdown()Shutdown Ninja and underlying server as safely as possible (tries not to cause exceptions to be thrown).Tstart()Configures (if not yet done), boots Ninja application and starts the underlying server.protected ExceptiontryToUnwrapInjectorException(Exception exception)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ninja.standalone.Console
getInjector
-
-
-
-
Field Detail
-
logger
protected final org.slf4j.Logger logger
-
ninjaMode
protected NinjaMode ninjaMode
-
name
protected String name
-
configured
protected boolean configured
-
started
protected boolean started
-
ninjaProperties
protected NinjaPropertiesImpl ninjaProperties
-
overlayedNinjaProperties
protected OverlayedNinjaProperties overlayedNinjaProperties
-
overrideModuleOpt
protected Optional<com.google.inject.Module> overrideModuleOpt
-
-
Constructor Detail
-
AbstractConsole
public AbstractConsole(String name)
-
-
Method Detail
-
configure
public final T configure() throws Exception
Description copied from interface:ConsoleConfigures the standalone to prepare for being started.- Specified by:
configurein interfaceConsole<T extends AbstractConsole>- Returns:
- This standalone
- Throws:
Exception- Thrown if an exception occurs during configuration
-
start
public final T start() throws Exception
Description copied from interface:ConsoleConfigures (if not yet done), boots Ninja application and starts the underlying server.- Specified by:
startin interfaceConsole<T extends AbstractConsole>- Returns:
- This standalone
- Throws:
Exception- Thrown if an exception occurs during Ninja boot or server start
-
shutdown
public final T shutdown()
Description copied from interface:ConsoleShutdown Ninja and underlying server as safely as possible (tries not to cause exceptions to be thrown).- Specified by:
shutdownin interfaceConsole<T extends AbstractConsole>- Returns:
- This standalone
-
doShutdown
protected abstract void doShutdown()
-
logStarted
protected void logStarted()
-
checkNotConfigured
protected void checkNotConfigured()
-
checkConfigured
protected void checkConfigured()
-
checkStarted
protected void checkStarted()
-
getNinjaMode
public NinjaMode getNinjaMode()
- Specified by:
getNinjaModein interfaceConsole<T extends AbstractConsole>
-
ninjaMode
public T ninjaMode(NinjaMode ninjaMode)
- Specified by:
ninjaModein interfaceConsole<T extends AbstractConsole>
-
getExternalConfigurationPath
public Optional<String> getExternalConfigurationPath()
- Specified by:
getExternalConfigurationPathin interfaceConsole<T extends AbstractConsole>
-
externalConfigurationPath
public T externalConfigurationPath(String externalConfigurationPath)
- Specified by:
externalConfigurationPathin interfaceConsole<T extends AbstractConsole>
-
getName
public String getName()
- Specified by:
getNamein interfaceConsole<T extends AbstractConsole>
-
getNinjaProperties
public NinjaPropertiesImpl getNinjaProperties()
Description copied from interface:ConsoleGets the NinjaProperties that were used to configure Ninja. This value is only accessible after configure() is successfully called.- Specified by:
getNinjaPropertiesin interfaceConsole<T extends AbstractConsole>- Returns:
- The NinjaProperties implementation
-
overrideModule
public T overrideModule(com.google.inject.Module overrideModule)
Description copied from interface:ConsoleOverride Guice module bindings as described here: https://google.github.io/guice/api-docs/3.0/javadoc/com/google/inject/util/Modules.html- Specified by:
overrideModulein interfaceConsole<T extends AbstractConsole>- Parameters:
overrideModule- Any bindings in this bindings will override all other bindings. This is very useful in tests.- Returns:
- this instance for chaining
-
overrideProperties
public T overrideProperties(Map<String,String> overrideProperties)
Description copied from interface:ConsoleOverride specific properties programmatically.- Specified by:
overridePropertiesin interfaceConsole<T extends AbstractConsole>- Parameters:
overrideProperties- Any properties in this map will override properties in any configuration file. This is very useful in tests.- Returns:
- this instance for chaining
-
-