Class AbstractConsole<T extends AbstractConsole>

  • 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 Detail

      • logger

        protected final org.slf4j.Logger logger
      • externalConfigurationPath

        protected Optional<String> externalConfigurationPath
      • configured

        protected boolean configured
      • started

        protected boolean started
      • 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 interface Console<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 interface Console<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 interface Console<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()
      • 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 interface Console<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 interface Console<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 interface Console<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
      • tryToUnwrapInjectorException

        protected Exception tryToUnwrapInjectorException​(Exception exception)