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. To execute tasks in a standard way two ExecutorServices are provided:

  • Field Details

    • LOG

      public static final System.Logger LOG
    • SCHEDULED_EXECUTOR

      public static ScheduledExecutorService SCHEDULED_EXECUTOR
    • EXECUTOR

      public static ExecutorService EXECUTOR
    • OR_SCHEDULED_EXECUTOR_THREADS

      public static final String OR_SCHEDULED_EXECUTOR_THREADS
      See Also:
    • OR_SCHEDULED_EXECUTOR_THREADS_DEFAULT

      public static final int OR_SCHEDULED_EXECUTOR_THREADS_DEFAULT
    • OR_EXECUTOR_THREADS_MIN

      public static final String OR_EXECUTOR_THREADS_MIN
      See Also:
    • OR_EXECUTOR_THREADS_MAX

      public static final String OR_EXECUTOR_THREADS_MAX
      See Also:
    • OR_EXECUTOR_THREADS_MIN_DEFAULT

      public static final int OR_EXECUTOR_THREADS_MIN_DEFAULT
    • OR_EXECUTOR_THREADS_MAX_DEFAULT

      public static final int OR_EXECUTOR_THREADS_MAX_DEFAULT
    • config

      protected final Map<String,String> config
    • devMode

      protected final boolean devMode
    • meterRegistry

      protected io.micrometer.core.instrument.MeterRegistry meterRegistry
    • 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
    • getMeterRegistry

      public io.micrometer.core.instrument.MeterRegistry getMeterRegistry()
      Description copied from interface: org.openremote.model.Container
      Get the MeterRegistry to use for micrometer metrics gathering
      Specified by:
      getMeterRegistry in interface org.openremote.model.Container
      Returns:
      Null if metrics has been disabled
    • 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
    • getScheduledExecutor

      public ScheduledExecutorService getScheduledExecutor()
      Specified by:
      getScheduledExecutor in interface org.openremote.model.Container
    • getExecutor

      public ExecutorService getExecutor()
      Specified by:
      getExecutor in interface org.openremote.model.Container