ProcessContainer

Inversion of control (IoC) container that runs as a system process.

Extends: Container

Description

The ProcessContainer class allows you to create an inversion of control (IoC) container that runs as a system process.

Important points

  • It processes command line arguments and handles unhandled exceptions and Ctrl-C signal to shutdown the container properly.

Command line arguments

  • –config / -c path to a JSON or YAML file with the container’s configuration (default: “./config/config.yml”)
  • –param / –params / -p configuration parameters
  • –help / -h prints the container usage help

Constructors

Creates a new instance of the container.

public constructor(name?: string, description?: string)

  • name: string - (optional) container’s name (accessible via ContextInfo)
  • description: string - (optional) container’s description (accessible via ContextInfo)

Fields

_configPath

Path to the configuration file.

protected String _configPath = “./config/config.yml”

Instance methods

run

Runs the container by instantiating and running components inside the container.

It reads the container configuration, and creates, configures, references and opens components. On process exit; it closes, unreferences and destroys components in order to shutdown properly.

public void run(String[] args) throws Exception

  • args: String[] - command line arguments

Examples

{
  ProcessContainer container = new ProcessContainer();
  container.addFactory(new MyComponentFactory());
 
  container.run(process.getArgs());
  }

See also