com.bea.netuix.servlets.manager.notifications
Class NotificationContext

java.lang.Object
  extended by com.bea.netuix.servlets.manager.notifications.NotificationContext

public abstract class NotificationContext
extends Object

The NotificationContext object serves as a cache and accessor for notifications and ties in to the portal framework rendering lifecycle to allow notifications to be marked for consumption after the render lifecycle has completed, thus allowing equal access to notifications across multiple portlets on a page.

See Also
INotificationManager for administrative needs.

Constructor Summary
NotificationContext()
           
 
Method Summary
static NotificationContext getNotificationContext(javax.servlet.http.HttpServletRequest request)
          A convenience method for returning the NotificationContext object associated with the specified Request.
abstract  Collection<Notification> getNotifications()
          Gets all the notifications appropriate for this NotificationContext (sent to the user authenticated in the request object, either globally targeted or targeted to the webapp for this request).
 Collection<Notification> getNotifications(Collection<String> namespaces)
          Gets all the notifications appropriate for this NotificationContext (sent to the user authenticated in the request object, either globally targeted or targeted to the webapp for this request) that match the specified namespaces.
 Collection<Notification> getNotifications(String namespace, String name)
          Gets all the notifications appropriate for this NotificationContext (sent to the user authenticated in the request object, either globally targeted or targeted to the webapp for this request) that match the specified namespace and name.
abstract  boolean isMarkedForConsumption(Notification notification)
          Determines if the specified notification has been marked for consumption at the end of this render lifecycle.
abstract  boolean isNotificationDeliveryActive()
          Determines if notification delivery through the inter-portlet eventing mechanisms is turned on for this webapp.
abstract  void markForConsumption(Notification notification)
          Marks the specified notification for consumption, so that it will be consumed after the current page render cycle has completed.
 void markForConsumption(NotificationId notificationId)
          Marks the specified notification for consumption, so that it will be consumed after the current page render cycle has completed.
abstract  void notifyUser(String username, NotificationPayloadInfo payload)
          Used to send a notification to a single user.
abstract  void notifyUsers(INotificationUserEnumerator userEnumerator, NotificationPayloadInfo payload)
          Used to send a notification to multiple users in an asynchronous manner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotificationContext

public NotificationContext()
Method Detail

getNotificationContext

public static NotificationContext getNotificationContext(javax.servlet.http.HttpServletRequest request)
A convenience method for returning the NotificationContext object associated with the specified Request. The NotificationContext is always available, even if no user is logged in.

Parameters
request - the HttpServletRequest.
Returns
the NotificationContext object associated with the request.

getNotifications

public abstract Collection<Notification> getNotifications()
Gets all the notifications appropriate for this NotificationContext (sent to the user authenticated in the request object, either globally targeted or targeted to the webapp for this request). If no user is authenticated, or if no appropriate notifications exist, an empty collection is returned.


getNotifications

public Collection<Notification> getNotifications(String namespace,
                                                 String name)
Gets all the notifications appropriate for this NotificationContext (sent to the user authenticated in the request object, either globally targeted or targeted to the webapp for this request) that match the specified namespace and name. If no user is authenticated, or if no appropriate notifications matching the specified namespace and name exist, an empty collection is returned.

Parameters
namespace - the namespace notifications must match to be included in the results. If null, notifcations with any namespace are included.
name - the name notifications must match to be included in the results. If null, notifcations with any name are included.

getNotifications

public Collection<Notification> getNotifications(Collection<String> namespaces)
Gets all the notifications appropriate for this NotificationContext (sent to the user authenticated in the request object, either globally targeted or targeted to the webapp for this request) that match the specified namespaces. If no user is authenticated, or if no appropriate notifications matching the specified namespaces, an empty collection is returned.

Parameters
namespaces - A collection of valid namespaces notifications must match to be included in the results.

markForConsumption

public void markForConsumption(NotificationId notificationId)
                        throws NotEntitledException
Marks the specified notification for consumption, so that it will be consumed after the current page render cycle has completed. This allows all participants in a page render cycle equal access to notifications. If the specified notification ID does not belong to the current set of accessible notifications for this NotificationContext, nothing is done.

Parameters
notificationId - the ID of the notification to mark for later consumption.
Throws
NotEntitledException - if the specified notification does not belong to the currently authenticated principal.

markForConsumption

public abstract void markForConsumption(Notification notification)
                                 throws NotEntitledException
Marks the specified notification for consumption, so that it will be consumed after the current page render cycle has completed. This allows all participants in a page render cycle equal access to notifications.

Parameters
notification - the notification to mark for later consumption.
Throws
NotEntitledException - if the specified notification does not belong to the currently authenticated principal.

isMarkedForConsumption

public abstract boolean isMarkedForConsumption(Notification notification)
Determines if the specified notification has been marked for consumption at the end of this render lifecycle.

Parameters
notification - the notification to determine if marked for later consumption.
Returns
true if the specified notification has been marked for later consumption.

notifyUser

public abstract void notifyUser(String username,
                                NotificationPayloadInfo payload)
                         throws IllegalArgumentException,
                                RemoteException
Used to send a notification to a single user. If sending the same notification to multiple users, the notifyUsers() method should be used instead. This method is synchronous- it will return after sending the notification.

Parameters
username - the user to send the notification to.
payload - the payload of the notification to send.
Throws
IllegalArgumentException - if any of the fields in the NotificationPayloadInfo object are invalid.
RemoteException

notifyUsers

public abstract void notifyUsers(INotificationUserEnumerator userEnumerator,
                                 NotificationPayloadInfo payload)
                          throws IllegalArgumentException,
                                 RemoteException
Used to send a notification to multiple users in an asynchronous manner. This method kicks off an asynchronous mechanism for sending notifications, so it returns before the notification has actually been sent. This is beneficial and recommended if a large number of users are being targetted to receive a notification.

Parameters
userEnumerator - an object which can be used to enumerate the set of users to send the notification to. It is important that this method is never called twice with the same instance of a userEnumerator object, as there is no guarantee that the requests will not be processed in parallel and the enumeration is not thread-safe.
payload - the payload of the notification to send.
Throws
IllegalArgumentException - if any of the fields in the NotificationPayloadInfo object are invalid.
RemoteException

isNotificationDeliveryActive

public abstract boolean isNotificationDeliveryActive()
Determines if notification delivery through the inter-portlet eventing mechanisms is turned on for this webapp. This is a configuration parameter specified in netuix-config.xml.

Returns
true if notification delivery is active for the webapp.


Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.