@startuml
skinparam backgroundColor LightYellow

actor User
participant "org.ofbiz.base.start.\n<b>Start</b>" as start
participant "org.ofbiz.base.start.\n<b>Config</b>" as config
participant "org.ofbiz.base.start.\n<b>StartupLoader</b>" as startupLoader

note right of User
 Through typing "ant start" or
 "java -jar ofbiz.jar"
 at command line to start OFBiz.
end note
User -> start : Start.main()
activate start
start -> start: new Start()
activate start

start -> start: Start.init()
group Init
    activate start
      start -> config: Config.getInstance()
      activate config
      config -> config: Config.getConfigFileName()
      activate config
      note right of config
        Default config file - org/ofbiz/base/start/start.properties
      end note
      deactivate config
      config -> config: new
      config -> config: Config.readConfig()
      activate config
        config -> config: Check JDK version (At least 1.6).
        config -> config: Config.getPropertiesFile()
        activate config
        deactivate config
        config -> config: Setup OFBiz home.
        note right of config
          Setup OFBiz home at OFBiz project directory.
          ofbiz.home = ./
        end note
        config -> config: Setup OFBiz all properties.
        note right of config
          ofbiz.base.config = ${ofbiz.home}/framework/base/config;
          ofbiz.base.dtd = ${ofbiz.home}/framework/base/schema;
          ofbiz.base.lib = ${ofbiz.home}/framework/base/lib;
          ofbiz.base.jar = ${ofbiz.home}/framework/base/build/lib/ofbiz-base.jar;
          Setup java tools.jar path if necessary;
          Setup java comm.jar path, if necessary;
          ofbiz.log.dir = ${ofbiz.home}/runtime/logs;
          ofbiz.continar.config = ${ofbiz.home}/framework/base/config/ofbiz-containers.xml;
          ofbiz.admin.host = 127.0.0.1;
          ofbiz.admin.port = 0;
          ofbiz.admin.key = NA;
          derby.system.home = ${ofbiz.home}/runtime/data/derby;
          log4j.configuration = log4j.xml;

          ofbiz.enable.hook = true;
          ofbiz.auto.shutdown = false;
          java.awt.headless = true;
          ofbiz.start.splash.logo = null;
          org.mortbay.jetty.servlet.AbstractSessionManager.24SessionDestroyed = true;
          user.language = ${ofbiz.locale.default}; - en
          ofbiz.timeZone.default = System time zone.
        end note

        loop start.properties:ofbiz.start.loader...
          note right of config
            Default there is one loader stay in start.properties file,
            that is org.ofbiz.base.container.ContainerLoader.
          end note
          config -> config: Put each loader into Config.loaders.
        end loop
        config -->config
      deactivate config




      config --> start: Return instance of Config
      deactivate config
      /' initialize the classpath '/
      start -> start: Start.initClasspath()
      activate start
      start -> config: Config.initClasspath()
      activate config
      config --> start
      deactivate config
      deactivate start

      /' create the log directory '/
      start -> start: Start.createLogDirectory()
      activate start
      deactivate start

      /' create the listener thread '/
      start -> start: Start.createListenerThread()
      activate start

      create "org.ofbiz.base.start.Start.\n<b>AdminPortThread</b>" as adminPortThread
      start -> adminPortThread: new
      activate adminPortThread
      start -> adminPortThread: AdminPortThread.start()
      activate adminPortThread
      deactivate start

      /' initialize the startup loaders '/
      start -> start: Start.initStartLoaders()
      activate start
        loop config.loaders
          note right of start
            Create StartLoader instance,
            put all loader instance into Start.loaders
          end note
          start -> startupLoader : New instance
          create "org.ofbiz.base.container.\n<b>ContainerLoader</b>" as containerLoader
          startupLoader -> containerLoader: New instance: org.ofbiz.base.container.ContainerLoader..
          activate containerLoader
          containerLoader --> start: Instance of ContainerLoader.
          start -> startupLoader : StartupLoader.load()
          startupLoader -> containerLoader: ContainerLoader.load()
          activate containerLoader
          create "org.ofbiz.base.container.\n<b>ContainerConfig</b>" as containerConfig
          containerLoader -> containerConfig: org.ofbiz.base.container.ContainerConfig.getContainers()
          note left of containerConfig
            List of register containers - ofbiz.continar.config:${ofbiz.home}/framework/base/config/ofbiz-containers.xml;
              component-container - org.ofbiz.base.container.ComponentContainer
              classloader-container - org.ofbiz.base.container.ClassLoaderContainer
              naming-container - org.ofbiz.base.container.NamingServiceContainer
              rmi-dispatcher - org.ofbiz.service.rmi.RmiServiceContainer
              catalina-container - org.ofbiz.catalina.container.CatalinaContainer
              birt-container - org.ofbiz.birt.container.BirtContainer
          end note
          containerConfig --> containerLoader: Collection of org.ofbiz.base.container.ContainerConfig.Container
          note over containerLoader
            After get all registered containers, OFBiz will create instance of those containers
            and invoke it's init() method.
          end note

          containerLoader --> start
          deactivate containerLoader
        end
        start -->start: End of initStartLoaders().
      deactivate start
end
start -->start: End of init().
deactivate start

group Start Container Loaders
    start -> start: Start.startStartLoaders()

    activate start
    loop Start.loaders
      start -> startupLoader: startupLoader.start()
      startupLoader -> containerLoader: containerLoader.start()
      activate containerLoader
      note right containerLoader
        All registered containers will startup, if any of them start failed,
        whole start process failed.
      end note
      containerLoader --> startupLoader
      deactivate containerLoader
      startupLoader --> start
    end
    start -->start: End of startStartLoaders()
    deactivate start
end

@enduml

