Class DefaultPlatformService

java.lang.Object
net.solarnetwork.node.runtime.DefaultPlatformService
All Implemented Interfaces:
PlatformService

public class DefaultPlatformService extends Object implements PlatformService
Default implementation of PlatformService.
Version:
2.0
Author:
matt
  • Constructor Details

    • DefaultPlatformService

      public DefaultPlatformService()
  • Method Details

    • activePlatformState

      public PlatformService.PlatformState activePlatformState()
      Description copied from interface: PlatformService
      Get the current active platform state.
      Specified by:
      activePlatformState in interface PlatformService
      Returns:
      the active platform state
    • activePlatformTaskStatus

      public PlatformService.PlatformTaskStatus activePlatformTaskStatus()
      Description copied from interface: PlatformService
      Get the current active platform task status.
      Specified by:
      activePlatformTaskStatus in interface PlatformService
      Returns:
      the task info, or null if no task is active
    • activePlatformTaskInfo

      public PlatformService.PlatformTaskInfo activePlatformTaskInfo(Locale locale)
      Description copied from interface: PlatformService
      Get the current active platform task status, localized into task info.
      Specified by:
      activePlatformTaskInfo in interface PlatformService
      Parameters:
      locale - the desired locale of the info, or null for the system default
      Returns:
      the localized platform task info
    • subscribeToActivePlatformTaskInfo

      public void subscribeToActivePlatformTaskInfo(Locale locale)
      Description copied from interface: PlatformService
      Register 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_INFO topic.

      Specified by:
      subscribeToActivePlatformTaskInfo in interface PlatformService
      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: PlatformService
      Perform 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 task is executing the PlatformService.activePlatformState() method will return the given state.

      Specified by:
      performTaskWithState in interface PlatformService
      Type Parameters:
      T - the task result type
      Parameters:
      state - the state the task must run with
      task - the task to execute
      Returns:
      a future with the task results
    • setSingletonExecutorService

      public void setSingletonExecutorService(ExecutorService singletonExecutorService)
      Configure the ExecutorService to 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 the EventAdmin to use.
      Parameters:
      eventAdmin - the service to use
    • setMessageSendingOperations

      public void setMessageSendingOperations(net.solarnetwork.service.OptionalService<org.springframework.messaging.simp.SimpMessageSendingOperations> messageSendingOps)
      Set a SimpMessageSendingOperations for posting messages to.
      Parameters:
      messageSendingOps - the message sender to use