Package org.openremote.container
Class Container
java.lang.Object
org.openremote.container.Container
- All Implemented Interfaces:
org.openremote.model.Container
A thread-safe registry of
ContainerService
s.
Create the container with ContainerService
s, 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 ExecutorService
s are provided:
EXECUTOR
- A dynamicThreadPoolExecutor
withOR_EXECUTOR_THREADS_MIN
core threads and max pool size ofOR_EXECUTOR_THREADS_MAX
for general task execution/li>SCHEDULED_EXECUTOR
- AScheduledThreadPoolExecutor
which is a fixed thread pool of sizeOR_SCHEDULED_EXECUTOR_THREADS
for scheduled task execution
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final boolean
static ExecutorService
static final System.Logger
protected io.micrometer.core.instrument.MeterRegistry
static final String
static final int
static final String
static final int
static final String
static final int
static ScheduledExecutorService
protected final Map<Class<? extends org.openremote.model.ContainerService>,
org.openremote.model.ContainerService> protected Thread
Fields inherited from interface org.openremote.model.Container
OR_DEV_MODE, OR_DEV_MODE_DEFAULT, OR_METRICS_ENABLED, OR_METRICS_ENABLED_DEFAULT
-
Constructor Summary
ConstructorsConstructorDescriptionDiscoverContainerService
s usingServiceLoader
; services are then ordered byContainerService.getPriority()
.Container
(org.openremote.model.ContainerService... services) -
Method Summary
Modifier and TypeMethodDescriptionio.micrometer.core.instrument.MeterRegistry
Get theMeterRegistry
to use for micrometer metrics gathering<T extends org.openremote.model.ContainerService>
TgetService
(Class<T> type) 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.org.openremote.model.ContainerService[]
<T extends org.openremote.model.ContainerService>
Collection<T>getServices
(Class<T> type) <T extends org.openremote.model.ContainerService>
booleanhasService
(Class<T> type) boolean
boolean
void
start()
void
Starts the container and a non-daemon thread that waits forever.void
stop()
-
Field Details
-
LOG
-
SCHEDULED_EXECUTOR
-
EXECUTOR
-
OR_SCHEDULED_EXECUTOR_THREADS
- See Also:
-
OR_SCHEDULED_EXECUTOR_THREADS_DEFAULT
public static final int OR_SCHEDULED_EXECUTOR_THREADS_DEFAULT -
OR_EXECUTOR_THREADS_MIN
- See Also:
-
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
-
devMode
protected final boolean devMode -
meterRegistry
protected io.micrometer.core.instrument.MeterRegistry meterRegistry -
waitingThread
-
services
-
-
Constructor Details
-
Container
public Container()DiscoverContainerService
s usingServiceLoader
; services are then ordered byContainerService.getPriority()
. -
Container
public Container(org.openremote.model.ContainerService... services) -
Container
-
Container
-
-
Method Details
-
getConfig
- Specified by:
getConfig
in interfaceorg.openremote.model.Container
-
isDevMode
public boolean isDevMode()- Specified by:
isDevMode
in interfaceorg.openremote.model.Container
-
isRunning
public boolean isRunning() -
start
- Throws:
Exception
-
stop
public void stop() -
startBackground
Starts the container and a non-daemon thread that waits forever.- Throws:
Exception
-
getServices
public org.openremote.model.ContainerService[] getServices()- Specified by:
getServices
in interfaceorg.openremote.model.Container
-
getServices
- Specified by:
getServices
in interfaceorg.openremote.model.Container
-
hasService
- Specified by:
hasService
in interfaceorg.openremote.model.Container
-
getMeterRegistry
public io.micrometer.core.instrument.MeterRegistry getMeterRegistry()Description copied from interface:org.openremote.model.Container
Get theMeterRegistry
to use for micrometer metrics gathering- Specified by:
getMeterRegistry
in interfaceorg.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 interfaceorg.openremote.model.Container
- Throws:
IllegalStateException
-
getScheduledExecutor
- Specified by:
getScheduledExecutor
in interfaceorg.openremote.model.Container
-
getExecutor
- Specified by:
getExecutor
in interfaceorg.openremote.model.Container
-