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
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanstatic ScheduledExecutorServicestatic final Loggerstatic final Stringstatic final intprotected final Map<Class<? extends org.openremote.model.ContainerService>,org.openremote.model.ContainerService> protected ThreadFields inherited from interface org.openremote.model.Container
OR_DEV_MODE, OR_DEV_MODE_DEFAULT -
Constructor Summary
ConstructorsConstructorDescriptionDiscoverContainerServices usingServiceLoader; services are then ordered byContainerService.getPriority().Container(org.openremote.model.ContainerService... services) -
Method Summary
Modifier and TypeMethodDescription<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) booleanbooleanvoidstart()voidStarts the container and a non-daemon thread that waits forever.voidstop()
-
Field Details
-
LOG
-
EXECUTOR_SERVICE
-
OR_SCHEDULED_TASKS_THREADS_MAX
- See Also:
-
OR_SCHEDULED_TASKS_THREADS_MAX_DEFAULT
public static final int OR_SCHEDULED_TASKS_THREADS_MAX_DEFAULT -
config
-
devMode
protected final boolean devMode -
waitingThread
-
services
-
-
Constructor Details
-
Container
public Container()DiscoverContainerServices usingServiceLoader; services are then ordered byContainerService.getPriority(). -
Container
public Container(org.openremote.model.ContainerService... services) -
Container
-
Container
-
-
Method Details
-
getConfig
- Specified by:
getConfigin interfaceorg.openremote.model.Container
-
isDevMode
public boolean isDevMode()- Specified by:
isDevModein 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:
getServicesin interfaceorg.openremote.model.Container
-
getServices
- Specified by:
getServicesin interfaceorg.openremote.model.Container
-
hasService
- Specified by:
hasServicein interfaceorg.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:
getServicein interfaceorg.openremote.model.Container- Throws:
IllegalStateException
-
getExecutorService
- Specified by:
getExecutorServicein interfaceorg.openremote.model.Container
-