Class NotificationSuite

java.lang.Object
com.groiss.notification.NotificationSuite

public class NotificationSuite extends Object
A facade to the Notification framework. The primary entry point to send messages to clients.
  • Method Details

    • disableNotification

      public static void disableNotification()
      Disables sending of notification for this transaction Default is enabled. After commit or rollback, it is enabled again. The state is checked only at commit time. This means that the last disable or enable operation is the relevant one. You cannot disable or enable single notifications within one transaction.
    • enableNotification

      public static void enableNotification()
      Enables sending of notification for this transaction. Default is enabled. After commit or rollback, it is enabled again. The state is checked only at commit time. This means that the last disable or enable operation is the relevant one. You cannot disable or enable single notifications within one transaction.
    • isNotificationEnabled

      public static boolean isNotificationEnabled()
      Determine if Notifications are enabled for this transaction.
      Returns:
      true, if Notifications are enabled for this transactions, false otherwise.
    • createEvent

      public static NotificationEvent createEvent(NotificationItem ni, short type, Agent a)
      Create a NotificationEvent from a NotificationItem. Usually, its not needed to explicitly create the event since NotificationItems can be published too.
      Parameters:
      ni - the item to be contained in the event object
      type - the event type Names
      a - the agent for which the event is destined
      Returns:
    • publish

      public static void publish(NotificationItem ni, short type)
      Publish a NotificationItem. The item is published after the current transaction commits (and suppressed if the transaction is rolled back). The agent to publish to is determined by NotificationItem.getAgent()
      Parameters:
      ni - the item to publish
      type - the event type Names
    • publish

      public static void publish(NotificationItem ni, short type, Agent a)
      Publish a NotificationItem. The item is published after the current transaction commits (and suppressed if the transaction is rolled back).
      Parameters:
      ni - the item to publish
      type - the event type Names
      a - the agent to sent the event to.
    • publish

      public static void publish(NotificationEvent e)
      Publish an event. Events are only needed in special cases. Usually, NotificationItems should be published. The event is published after the current transaction commits (and suppressed if the transaction is rolled back).
      Parameters:
      e -
    • publishImmediate

      public static void publishImmediate(NotificationEvent e) throws Exception
      Publish an event immediately. Events are only needed in special cases. Usually, NotificationItems should be published. The event is published instantaneously.
      Parameters:
      e -
      Throws:
      Exception
    • publishImmediate

      public static void publishImmediate(NotificationItem ni, short type) throws Exception
      Publish a NotificationItem immediately. The item is published instantaneously. The agent to publish to is determined by NotificationItem.getAgent()
      Parameters:
      ni - the item to publish
      type - the event type Names
      Throws:
      Exception
    • publishImmediate

      public static void publishImmediate(NotificationItem ni, short type, Agent a) throws Exception
      Publish a NotificationItem immediately. The item is published instantaneously.
      Parameters:
      ni - the item to publish
      type - the event type Names
      a - the agent to sent the event to.
      Throws:
      Exception
    • setMeToo

      public static void setMeToo(boolean meToo)
      Send notifications also to originating session. Normally, the originating CometD session does not receive the events via notification but rather synchronously via the initiating thread.

      This behavior can be changed (for all events in the current transaction), by setting meToo to true.

      N.B.: meToo is ignored, when avoidAutoNotification is set. meToo is automatically set to true if the changing function has not been called from the main window.

      Parameters:
      meToo - true when notifications should also be send to the originating session.
    • setAvoidAutoNotification

      public static void setAvoidAutoNotification(boolean avoidAutoNotification)
      Avoid sending of notifications to originating session. Normally, the originating CometD session does receive the events from itself if the the changing function has not been called from the main window.

      This behavior can be avoided (for all events in the current transaction), by setting avoidAutoNotification to true. Then,

      N.B.: avoidAutoNotification is stronger than meToo.

      Parameters:
      avoidAutoNotification - true when sending to current session should be avoided.
    • notifyUser

      public static void notifyUser(User user, String messageTopic, Map<String,?> payload) throws Exception
      Send a message to smartclients. Sends a JSONObject in a CometD message to all sessions of the specified user instantly. At the client, the JSONObject is accessible under the key "payload".
      Parameters:
      user - the user to notify
      messageTopic - the topic of the message
      payload - a map that will be used to create the JSONObject. Elements must be Serializable.
      Throws:
      Exception
    • notifySession

      public static void notifySession(HttpSession session, String topic, Map<String,?> payload) throws Exception
      Send a message to smartclients. Sends a JSONObject in a CometD message to a specific HttpSession instantly. At the client, the JSONObject is accessible under the key "payload". The session must be properly authenticated.
      Parameters:
      session - the session (on this node)
      topic - the topic of the message
      payload - a map that will be used to create the JSONObject. Elements must be Serializable.
      Throws:
      Exception