Class Transport.TransportInstance

java.lang.Object
de.iip_ecosphere.platform.transport.Transport.TransportInstance
Enclosing class:
Transport

public static class Transport.TransportInstance extends Object
An instance of the transport.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • TransportInstance

      public TransportInstance()
      Creates a transport instance without transport setup information (for deferred setup). Call setTransportSetup(Supplier) afterwards.
    • TransportInstance

      public TransportInstance(Supplier<TransportSetup> supplier)
      Creates a transport information instance and sets the transport information.
      Parameters:
      supplier - the transport supplier
      See Also:
  • Method Details

    • setTransportSetup

      public Supplier<TransportSetup> setTransportSetup(Supplier<TransportSetup> supplier)
      Sets up the transport information.
      Parameters:
      supplier - the transport supplier
      Returns:
      the supplier before this operation
    • sendServiceStatus

      public void sendServiceStatus(ActionType action, String serviceId, String... aliasIds)
      Sends a service status message. Uses Id.getDeviceId(). Calls createConnector() to obtain a connector instance on demand.
      Parameters:
      action - the action on the service
      serviceId - the service Id
      aliasIds - optional alias ids for the service
    • sendServiceStatusWithDescription

      public void sendServiceStatusWithDescription(ActionType action, String serviceId, String description, String... aliasIds)
      Sends a service status message. Uses Id.getDeviceId(). Calls createConnector() to obtain a connector instance on demand.
      Parameters:
      action - the action on the service
      serviceId - the service Id
      description - with description, usually the new service state
      aliasIds - optional alias ids for the service
    • sendServiceArtifactStatus

      public void sendServiceArtifactStatus(ActionType action, String artifactId, String... aliasIds)
      Sends a service artifact status message. Uses Id.getDeviceId(). Calls createConnector() to obtain a connector instance on demand.
      Parameters:
      action - the action on the artifact
      artifactId - the artifact Id
      aliasIds - optional alias ids for the artifact
    • sendContainerStatus

      public void sendContainerStatus(ActionType action, String containerId, String... aliasIds)
      Sends a container status message. Uses Id.getDeviceId(). Calls createConnector() to obtain a connector instance on demand.
      Parameters:
      action - the action on the container
      containerId - the container Id
      aliasIds - optional alias ids for the container
    • sendResourceStatus

      public void sendResourceStatus(ActionType action, String... aliasIds)
      Sends a resource status message for this resource. Calls createConnector() to obtain a connector instance on demand.
      Parameters:
      action - the action on the container
      aliasIds - optional alias ids for the resource
    • sendResourceStatus

      public void sendResourceStatus(ActionType action, String deviceId, String... aliasIds)
      Sends a resource status message. Calls createConnector() to obtain a connector instance on demand.
      Parameters:
      action - the action on the container
      deviceId - the device id, may be null then Id.getDeviceId() is used
      aliasIds - optional alias ids for the resource
    • send

      public void send(de.iip_ecosphere.platform.support.function.IOConsumer<TransportConnector> sender, String kind)
      Sends a message of a certain kind and cares for queuing.
      Parameters:
      sender - the sender including the message
      kind - the kind of the message for logging
    • setTraceFilter

      public void setTraceFilter(Predicate<TraceRecord> filter)
      Defines a trace filter.
      Parameters:
      filter - the filter, null for no filter
    • sendTraceRecord

      public void sendTraceRecord(TraceRecord record)
      Sends a trace record. Calls createConnector() to obtain a connector instance on demand. Caches messages if no connector is available.
      Parameters:
      record - the record to be sent
    • sendProcessStatus

      public void sendProcessStatus(String componentId, int step, int max, String description)
      Sends information about a processing status.
      Parameters:
      componentId - the component id
      step - the step [0; max]
      max - the maximum step
      description - the description of the task
    • sendProcessStatus

      public void sendProcessStatus(String componentId, int step, int max, String description, String subDescription)
      Sends information about a processing status. Attaches the actual task data if available.
      Parameters:
      componentId - the component id
      step - the step [0; max]
      max - the maximum step
      description - the description of the task
      subDescription - the description of an optional sub-task within the actual task, may be null or empty
    • sendProcessStatus

      public void sendProcessStatus(String componentId, ActionTypes type, Object result)
      Sends information about finalizing a task-based process. Attaches the actual task data if available.
      Parameters:
      componentId - the component id
      type - shall be ActionTypes.RESULT or ActionTypes.ERROR
      result - a serializable result, may be null
    • sendStatus

      public void sendStatus(StatusMessage msg)
      Sends a status message. Calls createConnector() to obtain a connector instance on demand. Caches messages if no connector is available.
      Parameters:
      msg - the message to be sent
    • sendAlert

      public void sendAlert(Alert alert)
      Sends an alert message. Calls createConnector() to obtain a connector instance on demand. Caches messages if no connector is available.
      Parameters:
      alert - the alert to be sent
    • createConnector

      public TransportConnector createConnector()
      Tries creating a connector. If successful, connector will be initialized for caching. The instance is cached. The transport information must be set up before setTransportSetup(Supplier). After successfully creating a connector, queued messages are sent and removed from the queue. However, there is no guarantee that a connector can be created.
      Returns:
      the (cached) connector, a non-functional dummy instance if no connector can be created
      See Also:
    • releaseConnector

      public void releaseConnector()
      Releases an existing connector and stays offline.
    • releaseConnector

      public void releaseConnector(boolean stayOff)
      Releases an existing connector.
      Parameters:
      stayOff - whether a call to createConnector() shall create a new connector or prevent sending further messages.
    • getConnector

      public TransportConnector getConnector()
      Returns the transport connector.
      Returns:
      the transport connector, may be null
      See Also: