Class AbstractDelegatingService<S extends Service>

java.lang.Object
de.iip_ecosphere.platform.services.environment.AbstractDelegatingService<S>
Type Parameters:
S - the type of service to delegate to
All Implemented Interfaces:
ParameterConfigurerProvider, Service, ServiceBase
Direct Known Subclasses:
AbstractDelegatingMultiService

public abstract class AbstractDelegatingService<S extends Service> extends Object implements Service
A service that delegates it's core operations to a nested service.
Author:
Holger Eichelberger, SSE
  • Field Details

    • service

      private S extends Service service
  • Constructor Details

    • AbstractDelegatingService

      public AbstractDelegatingService(YamlService yaml)
      Creates an instance.
      Parameters:
      yaml - the service description YAML
      See Also:
  • Method Details

    • initService

      protected void initService(YamlService yaml)
      Assigns the service by calling assignService(YamlService). May be overridden to do nothing if assignService(YamlService) is called later.
      Parameters:
      yaml - the service description YAML
      See Also:
    • assignService

      protected final void assignService(YamlService yaml)
      Assigns the service by calling createService(YamlService).
      Parameters:
      yaml - the service description YAML
    • createService

      protected abstract S createService(YamlService yaml)
      Creates the nested service instance to delegate to.
      Parameters:
      yaml - the service description YAML
      Returns:
      the service instance
    • getName

      public String getName()
      Description copied from interface: Service
      The name of the service.
      Specified by:
      getName in interface Service
      Returns:
      the name
    • getVersion

      public de.iip_ecosphere.platform.support.Version getVersion()
      Description copied from interface: Service
      The version of the service.
      Specified by:
      getVersion in interface Service
      Returns:
      the version
    • getDescription

      public String getDescription()
      Description copied from interface: Service
      The description of the service.
      Specified by:
      getDescription in interface Service
      Returns:
      the description, may be empty
    • isDeployable

      public boolean isDeployable()
      Description copied from interface: Service
      Returns whether the service is deployable in distributable manner or fixed in deployment location.
      Specified by:
      isDeployable in interface Service
      Returns:
      true for deployable, false for fixed
    • isTopLevel

      public boolean isTopLevel()
      Description copied from interface: Service
      Returns whether the service is a top-level service.
      Specified by:
      isTopLevel in interface Service
      Returns:
      true for top-level, false for nested
    • getKind

      public ServiceKind getKind()
      Description copied from interface: Service
      Returns the service kind.
      Specified by:
      getKind in interface Service
      Returns:
      the service kind
    • migrate

      public void migrate(String resourceId) throws ExecutionException
      Description copied from interface: Service
      Migrates a service. However, it may be required to migrate/move the containing artifact. [adaptation]
      Specified by:
      migrate in interface Service
      Parameters:
      resourceId - the target resource id, e.g., a device
      Throws:
      ExecutionException - if migration fails
    • update

      public void update(URI location) throws ExecutionException
      Description copied from interface: Service
      Updates the service by the service in the given location. This operation is responsible for stopping the running service (if needed), replacing it, starting the new service.
      Specified by:
      update in interface Service
      Parameters:
      location - the location of the new service, e.g., an URL
      Throws:
      ExecutionException - if the given service cannot be updated for some reason, e.g., because the replacement service is not an evolved version of the running service
    • switchTo

      public void switchTo(String targetId) throws ExecutionException
      Description copied from interface: Service
      Switches to an interface-compatible service. This method cares for stopping the old service, performing a handover if adequate, starting the target service. [adaptation]
      Specified by:
      switchTo in interface Service
      Parameters:
      targetId - the id of the target service
      Throws:
      ExecutionException - if switching the service cannot be performed for some reason
    • activate

      public void activate() throws ExecutionException
      Description copied from interface: Service
      Activates the service. [adaptation]
      Specified by:
      activate in interface Service
      Throws:
      ExecutionException - in case that activating fails, e.g., because the service is already active
    • passivate

      public void passivate() throws ExecutionException
      Description copied from interface: Service
      Passivates the service. [adaptation]
      Specified by:
      passivate in interface Service
      Throws:
      ExecutionException - in case that passivating fails, e.g., because the service is already passive
    • reconfigure

      public void reconfigure(Map<String,String> values) throws ExecutionException
      Description copied from interface: Service
      Reconfigures the service. [adaptation]
      Specified by:
      reconfigure in interface Service
      Parameters:
      values - the (service-specific) name-value mapping that shall lead to a reconfiguration of the service; values come either as primitive values or as JSON structures complying with the parameter descriptor. The service is responsible for correct JSON de-serialization according to the respective descriptor.
      Throws:
      ExecutionException - if reconfiguration fails
    • getId

      public String getId()
      Description copied from interface: ServiceBase
      Returns the unique id of the service. May be a single service id, a service id and a postfixed application id (after ServiceBase.APPLICATION_SEPARATOR) or a service id with application id and postfixed application instance id (after ServiceBase.APPLICATION_SEPARATOR)
      Specified by:
      getId in interface ServiceBase
      Returns:
      the unique id
    • getState

      public ServiceState getState()
      Description copied from interface: ServiceBase
      Returns the state the service is currently in. [R4c]
      Specified by:
      getState in interface ServiceBase
      Returns:
      the state
    • setState

      public void setState(ServiceState state) throws ExecutionException
      Description copied from interface: ServiceBase
      Changes the state. [R133c]
      Specified by:
      setState in interface ServiceBase
      Parameters:
      state - the new state
      Throws:
      ExecutionException - if changing the state fails for some reason
    • getService

      protected S getService()
      Returns the service the operations are delegated to.
      Returns:
      the service instance