org.licas.server.esb

## Class MonitorServer

- java.lang.Object
- - org.licas.server.esb.MonitorServer

-     public class MonitorServer
      extends java.lang.Object

  This class can be used to perform some resource allocation over the message queue that is built from the http requests.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.HashMap<java.lang.String,java.lang.Integer>` | `failCount` Number of times a message is not processed.
    `protected MessageMediator` | `mediator` Parent message mediator
    `protected MessageQueue` | `messageQueue` The queue of messages to process
    `protected PasswordHandler` | `passwordHandler` To retrieve some passwords for service types
    `protected java.util.ArrayList<java.lang.String>` | `servicesInvoked` List of services currently invoked through a message

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MonitorServer(PasswordHandler thePasswordHandler, MessageMediator theMediator)` Create a new instance of MonitorServer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancelMessage(java.lang.String ticket)` Remove the message with the specified ticket number from the queue.
    `boolean` | `hasMessages()` Return true if there are messages waiting to be processed.
    `boolean` | `messageToBus(MessageInfo ro)` Add the message to the message bus, with the following rules:
    `void` | `processNextMessage()` Process the queue of messages and return the next one determined by resource allocation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### messageQueue

          protected final MessageQueue messageQueue

      The queue of messages to process

    - #### servicesInvoked

          protected java.util.ArrayList<java.lang.String> servicesInvoked

      List of services currently invoked through a message

    - #### passwordHandler

          protected PasswordHandler passwordHandler

      To retrieve some passwords for service types

    - #### mediator

          protected MessageMediator mediator

      Parent message mediator

    - #### failCount

          protected java.util.HashMap<java.lang.String,java.lang.Integer> failCount

      Number of times a message is not processed. Key is the unique commID and value is a count of number of times.

  - ### Constructor Detail

    - #### MonitorServer

          public MonitorServer(PasswordHandler thePasswordHandler,
                               MessageMediator theMediator)

      Create a new instance of MonitorServer.
      Parameters:
        `thePasswordHandler` - the server password handler.
        `theMediator` - the parent message mediator.

  - ### Method Detail

    - #### hasMessages

          public boolean hasMessages()

      Return true if there are messages waiting to be processed.
      Returns:
        true if size of the message queue is `> 0`.

    - #### messageToBus

          public boolean messageToBus(MessageInfo ro)

      Add the message to the message bus, with the following rules:
      Parameters:
        `ro` - message with full `ServerHandler` handler details in a `BusEntity`.
      Returns:
        true if added, false if there was an error.

    - #### processNextMessage

          public void processNextMessage()
                                  throws java.lang.Exception

      Process the queue of messages and return the next one determined by resource allocation.
      Throws:
        `java.lang.Exception` - any error.

    - #### cancelMessage

          public void cancelMessage(java.lang.String ticket)

      Remove the message with the specified ticket number from the queue.
      Parameters:
        `ticket` - unique ticket number, equivalent to the communication ID.