Class LaunchContext

java.lang.Object
com.codingchili.core.context.LaunchContext

public class LaunchContext extends Object
Provides context for the Launcher system, passed to the launcher when starting an application using the Launcher subsystem.
  • Constructor Details

    • LaunchContext

      public LaunchContext(String... args)
      Parameters:
      args - process arguments to create a launcher for.
  • Method Details

    • settings

      public LauncherSettings settings()
      Returns:
      the launcher settings, must be modified before starting the launcher.
    • service

      protected List<String> service(String block) throws CoreException
      Parameters:
      block - see link.
      Returns:
      see link.
      Throws:
      CoreException - see link.
      See Also:
      services(List)
    • services

      protected List<String> services(List<String> blocks) throws CoreException
      Get the configured services for the given blocks or remote identifier.
      Parameters:
      blocks - the handler of the configured block or the hostname.
      Returns:
      a list of configured services for the given block or host.
      Throws:
      RemoteBlockNotConfiguredException - when no block is configured for given host.
      BlockNotConfiguredException - when no block is configured for given block-handler.
      CoreException
    • args

      public String[] args()
      Returns:
      the commandline arguments that was passed to the constructor.
    • services

      public List<String> services() throws CoreException
      Retrieves a block of services that should be deployed. If no block is explicitly set as the second argument then the block is inferred from the host-to-block mappings. if there is no such mapping the 'default' block is deployed, if one is specified.
      Returns:
      a list of services to be deployed for the given arguments.
      Throws:
      CoreException - when the specified block does not exist or when no blocks are specified that match the host and the 'default' block is missing.
    • blockNames

      public List<String> blockNames()
      Returns:
      the name of the block being deployed.
    • getCommand

      public Optional<String> getCommand()
      Returns:
      the command that was passed to the launcher if existing.
    • logger

      public Logger logger()
      Returns:
      the active logger for the current context.
    • getCommand

      public LaunchContext getCommand(Command command)
      adds a new command to the command executor, is used to handle command line arguments.
      Parameters:
      command - the command to add.
      Returns:
      fluent.
    • setCommandExecutor

      public LaunchContext setCommandExecutor(CommandExecutor executor)
      Set the command handler used to parse and execute command line arguments.
      Parameters:
      executor - the executor to execute commands with.
      Returns:
      fluent.
    • execute

      public io.vertx.core.Future<CommandResult> execute()
      Returns:
      future resolved when the command executor for the launch context has executed.
    • getExecutor

      public CommandExecutor getExecutor()
      Get the CommandExecutor attached to the launch context.
      Returns:
      fluent
    • start

      public void start()
      Starts the launcher using this context.