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 boolean
configured
protected Optional<String>
externalConfigurationPath
protected org.slf4j.Logger
logger
protected String
name
protected NinjaMode
ninjaMode
protected NinjaPropertiesImpl
ninjaProperties
protected OverlayedNinjaProperties
overlayedNinjaProperties
protected Optional<com.google.inject.Module>
overrideModuleOpt
protected Optional<Map<String,String>>
overridePropertiesOpt
protected boolean
started
-
Constructor Summary
Constructors Constructor Description AbstractConsole(String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkConfigured()
protected void
checkNotConfigured()
protected void
checkStarted()
T
configure()
Configures the standalone to prepare for being started.protected abstract void
doConfigure()
protected void
doPostConfigure()
protected void
doPreConfigure()
protected abstract void
doShutdown()
protected abstract void
doStart()
T
externalConfigurationPath(String externalConfigurationPath)
Optional<String>
getExternalConfigurationPath()
String
getName()
NinjaMode
getNinjaMode()
NinjaPropertiesImpl
getNinjaProperties()
Gets the NinjaProperties that were used to configure Ninja.protected void
logStarted()
T
name(String name)
T
ninjaMode(NinjaMode ninjaMode)
T
overrideModule(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.htmlT
overrideProperties(Map<String,String> overrideProperties)
Override specific properties programmatically.T
shutdown()
Shutdown Ninja and underlying server as safely as possible (tries not to cause exceptions to be thrown).T
start()
Configures (if not yet done), boots Ninja application and starts the underlying server.protected Exception
tryToUnwrapInjectorException(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:Console
Configures the standalone to prepare for being started.- Specified by:
configure
in 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:Console
Configures (if not yet done), boots Ninja application and starts the underlying server.- Specified by:
start
in 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:Console
Shutdown Ninja and underlying server as safely as possible (tries not to cause exceptions to be thrown).- Specified by:
shutdown
in 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:
getNinjaMode
in interfaceConsole<T extends AbstractConsole>
-
ninjaMode
public T ninjaMode(NinjaMode ninjaMode)
- Specified by:
ninjaMode
in interfaceConsole<T extends AbstractConsole>
-
getExternalConfigurationPath
public Optional<String> getExternalConfigurationPath()
- Specified by:
getExternalConfigurationPath
in interfaceConsole<T extends AbstractConsole>
-
externalConfigurationPath
public T externalConfigurationPath(String externalConfigurationPath)
- Specified by:
externalConfigurationPath
in interfaceConsole<T extends AbstractConsole>
-
getName
public String getName()
- Specified by:
getName
in interfaceConsole<T extends AbstractConsole>
-
getNinjaProperties
public NinjaPropertiesImpl getNinjaProperties()
Description copied from interface:Console
Gets the NinjaProperties that were used to configure Ninja. This value is only accessible after configure() is successfully called.- Specified by:
getNinjaProperties
in interfaceConsole<T extends AbstractConsole>
- Returns:
- The NinjaProperties implementation
-
overrideModule
public T overrideModule(com.google.inject.Module overrideModule)
Description copied from interface:Console
Override Guice module bindings as described here: https://google.github.io/guice/api-docs/3.0/javadoc/com/google/inject/util/Modules.html- Specified by:
overrideModule
in 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:Console
Override specific properties programmatically.- Specified by:
overrideProperties
in 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
-
-