Package net.solarnetwork.node.runtime
Class DefaultPlatformService
java.lang.Object
net.solarnetwork.node.runtime.DefaultPlatformService
- All Implemented Interfaces:
PlatformService
Default implementation of
PlatformService.- Version:
- 2.0
- Author:
- matt
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.solarnetwork.node.service.PlatformService
PlatformService.PlatformState, PlatformService.PlatformTask<T>, PlatformService.PlatformTaskInfo, PlatformService.PlatformTaskStatus, PlatformService.PlatformTaskStatusHandler -
Field Summary
Fields inherited from interface net.solarnetwork.node.service.PlatformService
EVENT_TOPIC_PLATFORM_STATE_CHANGED, MSG_TOPIC_PLATFORM_TASK_INFO, OLD_PLATFORM_STATE_PROPERTY, PLATFORM_STATE_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the current active platform state.activePlatformTaskInfo(Locale locale) Get the current active platform task status, localized into task info.Get the current active platform task status.<T> Future<T> Perform a platform state-altering task.voidsetEventAdmin(net.solarnetwork.service.OptionalService<org.osgi.service.event.EventAdmin> eventAdmin) Set theEventAdminto use.voidsetMessageSendingOperations(net.solarnetwork.service.OptionalService<org.springframework.messaging.simp.SimpMessageSendingOperations> messageSendingOps) Set aSimpMessageSendingOperationsfor posting messages to.voidsetSingletonExecutorService(ExecutorService singletonExecutorService) Configure theExecutorServiceto use for the singleton task queue.voidRegister a subscription to the active platform task's status updates for a specific locale.
-
Constructor Details
-
DefaultPlatformService
public DefaultPlatformService()Default constructor.
-
-
Method Details
-
activePlatformState
Description copied from interface:PlatformServiceGet the current active platform state.- Specified by:
activePlatformStatein interfacePlatformService- Returns:
- the active platform state
-
activePlatformTaskStatus
Description copied from interface:PlatformServiceGet the current active platform task status.- Specified by:
activePlatformTaskStatusin interfacePlatformService- Returns:
- the task info, or null if no task is active
-
activePlatformTaskInfo
Description copied from interface:PlatformServiceGet the current active platform task status, localized into task info.- Specified by:
activePlatformTaskInfoin interfacePlatformService- Parameters:
locale- the desired locale of the info, or null for the system default- Returns:
- the localized platform task info
-
subscribeToActivePlatformTaskInfo
Description copied from interface:PlatformServiceRegister a subscription to the active platform task's status updates for a specific locale.Once registered, this service will post messages to the
PlatformService.MSG_TOPIC_PLATFORM_TASK_INFOtopic.- Specified by:
subscribeToActivePlatformTaskInfoin interfacePlatformService- Parameters:
locale- the locale to register for updates
-
performTaskWithState
public <T> Future<T> performTaskWithState(PlatformService.PlatformState state, PlatformService.PlatformTask<T> task) Description copied from interface:PlatformServicePerform a platform state-altering task.This method will schedule a task such that while that task is running the provided state is applied to the platform. While
taskis executing thePlatformService.activePlatformState()method will return the givenstate.- Specified by:
performTaskWithStatein interfacePlatformService- Type Parameters:
T- the task result type- Parameters:
state- the state the task must run withtask- the task to execute- Returns:
- a future with the task results
-
setSingletonExecutorService
Configure theExecutorServiceto use for the singleton task queue.This service is expected to perform just one task at a time.
- Parameters:
singletonExecutorService- the service to use; defaults to a service using an array-based blocking queue with a single thread
-
setEventAdmin
public void setEventAdmin(net.solarnetwork.service.OptionalService<org.osgi.service.event.EventAdmin> eventAdmin) Set theEventAdminto use.- Parameters:
eventAdmin- the service to use
-
setMessageSendingOperations
public void setMessageSendingOperations(net.solarnetwork.service.OptionalService<org.springframework.messaging.simp.SimpMessageSendingOperations> messageSendingOps) Set aSimpMessageSendingOperationsfor posting messages to.- Parameters:
messageSendingOps- the message sender to use
-