org.licas.def

## Interface PublishSubscribeDef

- All Known Implementing Classes:
    ESB, MessageMediator, PublishSubscribe

      public interface PublishSubscribeDef

  Interface for a publish-subscribe operation for the ESB server.
  Author:
    Kieran Greer

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `publish(WorkInfo workInfo)` Publish to do work.
    `boolean` | `subscribe(WorkInfo workInfo)` Subscribe for a service.
    `void` | `unpublish(KeywordInfo keyInfo, org.licas_xml.abs.Element clientURI)` Un-publish to do work.
    `void` | `unsubscribe(KeywordInfo keyInfo, org.licas_xml.abs.Element clientURI)` Un-subscribe for a service.

- - ### Method Detail

    - #### subscribe

          boolean subscribe(WorkInfo workInfo)
                     throws java.lang.Exception

      Subscribe for a service. Each time a service publishes a matching work description any subscriber is sent the `WorkInfo` details. An immediate check is done to determine if matching work is available.
      Parameters:
        `workInfo` - new client details. It must include the keyword list and the method to reply with.
        1. A list of descriptive keywords and topic to match with.
        2. Details of the client method to reply with if a service work matches with the keywords request.
        The details method must comply with some specific formatting as follows:
        1. It must include the client URI, as this is what identifies the request. If `getClientURI()` is empty, then the request is ignored.
        2. It must contain a parameter list of size 1, that is either an `Object` or a `WorkInfo` object, as that is what will be sent as a reply.
        3. The return type must be `void` (asynchronous call).
      Returns:
        true if added as a new request, or false if service request is already registered, via keyword or topic overlap, for example.
      Throws:
        `java.lang.Exception` - any error.

    - #### unsubscribe

          void unsubscribe(KeywordInfo keyInfo,
                           org.licas_xml.abs.Element clientURI)
                    throws java.lang.Exception

      Un-subscribe for a service.
      Parameters:
        `keyInfo` - list of descriptive keywords to uniquely identify the service.
        `clientURI` - the client URI defines the request client.
      Throws:
        `java.lang.Exception` - any error.

    - #### publish

          boolean publish(WorkInfo workInfo)
                   throws java.lang.Exception

      Publish to do work. This triggers a message to all subscribed services each time and any publishing service may publish the same work request any number of times. Only the first published request is saved however and then then sent out each time.
      Parameters:
        `workInfo` - full work details, including an optional contract. The method description must include the client URI as this is what identifies the request. If `getClientURI()` is empty, then the request is ignored.
      Returns:
        true if added as a new request, or false if work request is already registered, via keyword or topic overlap, for example.
      Throws:
        `java.lang.Exception` - any error.

    - #### unpublish

          void unpublish(KeywordInfo keyInfo,
                         org.licas_xml.abs.Element clientURI)
                  throws java.lang.Exception

      Un-publish to do work.
      Parameters:
        `keyInfo` - list of descriptive keywords to uniquely identify the work.
        `clientURI` - the client URI defines the request service.
      Throws:
        `java.lang.Exception` - any error.