Class ReplyEvent

java.lang.Object
java.util.EventObject
cl.netswitch.lib.server.ReplyEvent
All Implemented Interfaces:
Serializable

public final class ReplyEvent extends EventObject
ReplyEvent is used to notify that a reply message has arrived.
See Also:
  • Constructor Details

    • ReplyEvent

      public ReplyEvent(RequestEvent request, Message message)
      Constructs a new ReplyEvent instance.
      Parameters:
      request - the request sending the async subrequest.
      message - the reply message of this event (null if timeout).
      Throws:
      NullPointerException - if request is null.
  • Method Details

    • getServerChannel

      public ServerChannel getServerChannel()
      Returns the server channel of this ReplyEvent.
      Returns:
      the server channel of this ReplyEvent.
    • getRequest

      public RequestEvent getRequest()
      Returns the request event of this ReplyEvent.
      Returns:
      the request event of this ReplyEvent.
    • getMessage

      public Message getMessage()
      Returns the reply message or null if the reply timeout.
      Returns:
      the reply message or null if the reply timeout.
    • getSuccessMessage

      public Message getSuccessMessage()
      Returns the reply message with a SUCCESS status. It throws a ServiceException if the status of the message is an ERROR. The ServiceException includes the status, text and userMessage of the reply message. It throws a ReplyTimeoutException if the reply timeout.
      Returns:
      the success reply message of this event.
      Throws:
      ReplyTimeoutException - if the reply timeout.
      ServiceException - if the reply message has an error status.
    • getObject

      public <T extends Serializable> T getObject(Class<T> type)
      Returns the object contained in the success message of this ReplyEvent.

      Warning: to reduce memory consumption, this method returns a reference to (not a copy of) the mutable object stored in the reply message. If the returned object is later modified, the reply message object will be modified.

      Type Parameters:
      T - the type of the returned object.
      Parameters:
      type - the class of the returned object.
      Returns:
      a typed object or null if not defined.
      Throws:
      NullPointerException - if type is null.
      ReplyTimeoutException - if the reply timeout.
      ServiceException - if the reply message has an error status.
      ClassCastException - if object is not an instance of type.
      See Also:
    • isLoggable

      public boolean isLoggable(Level level)
      Returns true if the given message level is being logged.
      Parameters:
      level - a message logging level.
      Returns:
      true if the given message level is being logged.
      Throws:
      NullPointerException - if level is null.
    • fine

      public void fine(String message, Object... args)
      Logs a fine message with supplied format and arguments.
      Parameters:
      message - the text of the message or format.
      args - an array of optional format arguments.
    • info

      public void info(String message, Object... args)
      Logs an information message with supplied format and arguments.
      Parameters:
      message - the text of the message or format.
      args - an array of optional format arguments.
    • warning

      public void warning(String message, Object... args)
      Logs a warning message with supplied format and arguments.
      Parameters:
      message - the text of the message or format.
      args - an array of optional format arguments.
    • severe

      public void severe(String message, Object... args)
      Logs a severe message with supplied format and arguments.
      Parameters:
      message - the text of the message or format.
      args - an array of optional format arguments.
    • severe

      public void severe(Throwable thrown, String message, Object... args)
      Logs a severe message with supplied throwable, format and arguments.
      Parameters:
      thrown - the associatted throwable instance.
      message - the text of the message or format.
      args - an array of optional format arguments.