Class Container

java.lang.Object
org.openremote.container.Container
All Implemented Interfaces:
org.openremote.model.Container

public class Container extends Object implements org.openremote.model.Container
A thread-safe registry of ContainerServices.

Create the container with ContainerServices, then let it manage the life cycle of these services.

Access environment configuration through getConfig() and the helper methods in MapAccess. Consider using Container.OR_DEV_MODE to distinguish between development and production environments.

  • Field Details

    • LOG

      public static final Logger LOG
    • EXECUTOR_SERVICE

      public static ScheduledExecutorService EXECUTOR_SERVICE
    • OR_SCHEDULED_TASKS_THREADS_MAX

      public static final String OR_SCHEDULED_TASKS_THREADS_MAX
      See Also:
    • OR_SCHEDULED_TASKS_THREADS_MAX_DEFAULT

      public static final int OR_SCHEDULED_TASKS_THREADS_MAX_DEFAULT
    • config

      protected final Map<String,String> config
    • devMode

      protected final boolean devMode
    • waitingThread

      protected Thread waitingThread
    • services

      protected final Map<Class<? extends org.openremote.model.ContainerService>,org.openremote.model.ContainerService> services
  • Constructor Details

    • Container

      public Container()
      Discover ContainerServices using ServiceLoader; services are then ordered by ContainerService.getPriority().
    • Container

      public Container(org.openremote.model.ContainerService... services)
    • Container

      public Container(Iterable<org.openremote.model.ContainerService> services)
    • Container

      public Container(Map<String,String> config, Iterable<org.openremote.model.ContainerService> services)
  • Method Details

    • getConfig

      public Map<String,String> getConfig()
      Specified by:
      getConfig in interface org.openremote.model.Container
    • isDevMode

      public boolean isDevMode()
      Specified by:
      isDevMode in interface org.openremote.model.Container
    • isRunning

      public boolean isRunning()
    • start

      public void start() throws Exception
      Throws:
      Exception
    • stop

      public void stop()
    • startBackground

      public void startBackground() throws Exception
      Starts the container and a non-daemon thread that waits forever.
      Throws:
      Exception
    • getServices

      public org.openremote.model.ContainerService[] getServices()
      Specified by:
      getServices in interface org.openremote.model.Container
    • getServices

      public <T extends org.openremote.model.ContainerService> Collection<T> getServices(Class<T> type)
      Specified by:
      getServices in interface org.openremote.model.Container
    • hasService

      public <T extends org.openremote.model.ContainerService> boolean hasService(Class<T> type)
      Specified by:
      hasService in interface org.openremote.model.Container
    • getService

      public <T extends org.openremote.model.ContainerService> T getService(Class<T> type) throws IllegalStateException
      Get a service instance matching the specified type exactly, or if that yields no result, try to get the first service instance that has a matching interface.
      Specified by:
      getService in interface org.openremote.model.Container
      Throws:
      IllegalStateException
    • getExecutorService

      public ScheduledExecutorService getExecutorService()
      Specified by:
      getExecutorService in interface org.openremote.model.Container