Class SummerApplication

java.lang.Object
org.summerboot.jexpress.boot.cli.BootCLI
org.summerboot.jexpress.boot.SummerApplication

public abstract class SummerApplication extends BootCLI
Author:
Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
  • Field Details

    • log

      protected static org.apache.logging.log4j.Logger log
  • Constructor Details

    • SummerApplication

      protected SummerApplication()
  • Method Details

    • bind

      public static SummerApplication bind(Class controllerScanRootClass)
    • buildModule

      public static com.google.inject.Module buildModule(com.google.inject.AbstractModule appModule, Class callerClass)
      For Unit Testing only
      Parameters:
      appModule - application Google Inject Guice module
      callerClass - the main class
      Returns:
      combined (app and framework) Google Inject Guice module
    • isMockMode

      public static boolean isMockMode(String mockItemName)
      Check if a given name is provided in command line -mock option
      Parameters:
      mockItemName -
      Returns:
      true if mockItemName is available in command line args -mock <mockItemName1, mockItemName2, ...>
    • getAppMockOptions

      public static Set<String> getAppMockOptions()
    • getCallerRootPackageName

      public static String getCallerRootPackageName()
    • getCfgDefaultRB

      public Locale getCfgDefaultRB()
    • getEnvName

      public String getEnvName()
    • getCfgConfigDir

      public Path getCfgConfigDir()
    • getCfgEnvFolderPrefix

      public String getCfgEnvFolderPrefix()
    • getIocInjector

      public com.google.inject.Injector getIocInjector()
    • bind_AlertMessenger

      public <T extends SummerApplication> T bind_AlertMessenger(Class<? extends PostOffice> postOfficeClass)
      To override the default email sender instance with the app
      Type Parameters:
      T -
      Parameters:
      postOfficeClass -
      Returns:
    • bind_GuiceModule

      public <T extends SummerApplication> T bind_GuiceModule(com.google.inject.AbstractModule appModule)
      To bind Google Guice IoC container with the app
      Type Parameters:
      T -
      Parameters:
      appModule -
      Returns:
    • bind_NIOHandler

      public <T extends SummerApplication> T bind_NIOHandler(Class<? extends io.netty.channel.ChannelHandler> channelHandlerClass)
    • bind_NIOHandler

      public <T extends SummerApplication> T bind_NIOHandler(Class<? extends io.netty.channel.ChannelHandler> channelHandlerClass, String channelHandlerBindingName)
      To bind a unique named NIO Request Handler with the app
      Type Parameters:
      T -
      Parameters:
      channelHandlerClass -
      channelHandlerBindingName -
      Returns:
    • bind_BootConfig

      public <T extends SummerApplication> T bind_BootConfig(String configFileName, JExpressConfig config)
      To bind a configuration file implemented by a JExpressConfig instance, which will be loaded and managed by SummerBoot Application
      Type Parameters:
      T -
      Parameters:
      configFileName - file name only, without file path
      config - the JExpressConfig instance
      Returns:
    • bind_BootConfig

      public <T extends SummerApplication> T bind_BootConfig(String configFileName, JExpressConfig config, String mockName, boolean registerWhenMockIsEnabled)
      To bind a configuration file implemented by a JExpressConfig instance, which will be loaded and managed by SummerBoot Application
      Type Parameters:
      T -
      Parameters:
      configFileName -
      config -
      mockName -
      registerWhenMockIsEnabled -
      Returns:
    • enable_CLI_ListErrorCodes

      public <T extends SummerApplication> T enable_CLI_ListErrorCodes(Class errorCodeClass, boolean checkDuplicated) throws IllegalArgumentException, IllegalAccessException, com.fasterxml.jackson.core.JsonProcessingException
      To enable -errorcode CLI to list all error codes
      Type Parameters:
      T -
      Parameters:
      errorCodeClass -
      checkDuplicated - check duplicated if true
      Returns:
      Throws:
      IllegalArgumentException
      IllegalAccessException
      com.fasterxml.jackson.core.JsonProcessingException
    • enable_CLI_ListPOIs

      public <T extends SummerApplication> T enable_CLI_ListPOIs(Class poiNameClass, boolean checkDuplicated) throws IllegalArgumentException, IllegalAccessException, com.fasterxml.jackson.core.JsonProcessingException
      To enable -poi CLI to list all POI names
      Type Parameters:
      T -
      Parameters:
      poiNameClass -
      checkDuplicated - check duplicated if true
      Returns:
      Throws:
      IllegalArgumentException
      IllegalAccessException
      com.fasterxml.jackson.core.JsonProcessingException
    • enable_CLI_MockMode

      public <T extends SummerApplication> T enable_CLI_MockMode(Class<? extends Enum<?>> enumClass)
      To enable mock mode
      Type Parameters:
      T -
      Parameters:
      enumClass - the enum contains mock items
      Returns:
    • enable_CLI_MockMode

      public <T extends SummerApplication> T enable_CLI_MockMode(String... mockItemNames)
      To enable mock mode
      Type Parameters:
      T -
      Parameters:
      mockItemNames - the mock item names
      Returns:
    • enable_CLI_ViewConfig

      public <T extends SummerApplication> T enable_CLI_ViewConfig(Class... cs)
      To enable viewing config setting using CLI
      Type Parameters:
      T -
      Parameters:
      cs -
      Returns:
    • enable_Ping_HealthCheck

      public <T extends SummerApplication> T enable_Ping_HealthCheck(String contextRoot, String pingPath)
      To enable load balancer health check on the provided path via HTTP GET request
      Type Parameters:
      T -
      Parameters:
      contextRoot - the contect root like "myroot/myservice"
      pingPath - the ping command like "/ping", the the load balancer will do the health check vis GET /myroot/myservice/ping
      Returns:
    • enable_Ping_HealthCheck

      public <T extends SummerApplication> T enable_Ping_HealthCheck(String contextRoot, String pingPath, Class<? extends HealthInspector> healthInspectorClass)
      Override load balancer health check path and inspector
      Type Parameters:
      T -
      Parameters:
      contextRoot -
      pingPath -
      healthInspectorClass -
      Returns:
    • run

      public void run(String[] args, String version) throws Exception
      To run the SummerBoot Application
      Parameters:
      args -
      version -
      Throws:
      Exception
    • run

      public void run(String[] args, String version, boolean startNIO) throws Exception
      Parameters:
      args -
      version -
      startNIO -
      Throws:
      Exception
    • initCLIs_App

      protected void initCLIs_App(org.apache.commons.cli.Options options)
      callback to init customized CLIs
      Parameters:
      options -
    • processCLIs_App

      protected void processCLIs_App(org.apache.commons.cli.CommandLine cli)
      callback to process customized CLIs
      Parameters:
      cli -
    • getAddtionalI18n

      protected Class getAddtionalI18n()
      Returns:
      i18n class
    • locadCustomizedConfigs

      protected void locadCustomizedConfigs(Path configFolder) throws Exception
      callback to initialize based on customized config files in configDir
      Parameters:
      configFolder -
      Throws:
      Exception
    • beforeStart

      protected abstract void beforeStart(org.apache.commons.cli.CommandLine cli) throws Exception
      callback before NIO binding
      Parameters:
      cli -
      Throws:
      Exception
    • isJMXRequired

      protected boolean isJMXRequired()