Nitido Inc.

com.nitido.nimx.services.notification
Class StatusTicketCache

java.lang.Object
  extended by com.nitido.nimx.services.notification.StatusTicketCache
All Implemented Interfaces:
NotificationConstants

public class StatusTicketCache
extends java.lang.Object
implements NotificationConstants

This class manages the cached status objects for the notification messages. It is only accessible through the service so that there is exactly one cache in the system and the delivery channels do not have to implement their own versions. The delivery channels place and retrieve status objects, while the cache manages the cleanup process for expired status objects.


Field Summary
 
Fields inherited from interface com.nitido.nimx.services.notification.NotificationConstants
CONF_KEY_CACHE_EXPIRE_TIME, CONF_KEY_CACHE_MAX_TIME, CONF_KEY_CACHE_PREFIX, CONF_KEY_CACHE_REMOVE_FINAL, CONF_KEY_CACHE_SLEEP_TIME, CONF_KEY_DELIVERY_CHANNEL_LIST_PREFIX, CONF_KEY_DELIVERY_CHANNELS_PREFIX, KEY_TRANSACTION_PREFIX, LEN_PREFIX_TOKEN, LEN_PREFIX_USER_SPACE, PREFIX_TOKEN, PREFIX_USER_SPACE, PROTOCOL_ADDRESS_SEPARATOR, TICKET_SEPARATOR
 
Constructor Summary
protected StatusTicketCache(ConfigurationService confService, NotificationService notifyService)
          Protected constructor to only allow the service to instantiate the cache.
 
Method Summary
 java.lang.String addStatus(java.lang.String deliveryChanelId, IndividualStatus status)
          Add a new status object to the cache.
 java.lang.String addTransaction(java.util.List<java.lang.String> ticketList)
          Create a new transaction record for the provided list of status IDs.
static java.lang.String constructTicket(java.lang.String dc, java.lang.String ticket, java.lang.String recipient)
          Creates a status ticket based on the delivery channel's ID, some ticket value provided by the delivery channel and the recipient.
protected  java.util.Set<java.lang.String> getAllTransactions()
          Returns a set of all the transaction IDs currently in the cache.
static java.lang.String getDeliveryChannelId(java.lang.String ticket)
          Returns the delivery channel ID from the ticket string.
 IndividualStatus getStatus(java.lang.String ticket)
          Get a status object from the cache.
static java.lang.String getTicketId(java.lang.String ticket)
          Returns the ticket's content from the complete ticket string.
static java.lang.String getTicketRecipient(java.lang.String ticket)
          Returns the recipient info encoded in the ticket.
 java.util.List<java.lang.String> getTransaction(java.lang.String transTicket)
          Get the list of individual status IDs that make up the transaction specified by the provided transaction ID.
 void removeTransaction(java.lang.String transTicket)
          Remove the transaction and all the status objects cached for the individual tickets that are part of this transaction.
protected  void signalShutdown()
          Server is shutting down so we need to make sure that the clean up thread(s) are shut down.
 void updateStatus(java.lang.String ticket, IndividualStatus status)
          Update the status object stored in the cache for a given ticket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatusTicketCache

protected StatusTicketCache(ConfigurationService confService,
                            NotificationService notifyService)
Protected constructor to only allow the service to instantiate the cache.

Method Detail

addTransaction

public java.lang.String addTransaction(java.util.List<java.lang.String> ticketList)
Create a new transaction record for the provided list of status IDs.

Parameters:
ticketList - the list of individual status tickets which make up this transaction
Returns:
the unique ID of this newly created transaction

getTransaction

public java.util.List<java.lang.String> getTransaction(java.lang.String transTicket)
                                                throws StatusNotFoundException
Get the list of individual status IDs that make up the transaction specified by the provided transaction ID.

Parameters:
transTicket - the ID of the transaction
Returns:
the list of individual status IDs that make up the transaction
Throws:
StatusNotFoundException - if the transaction with the provided ID could not be found in the cache

removeTransaction

public void removeTransaction(java.lang.String transTicket)
                       throws StatusNotFoundException
Remove the transaction and all the status objects cached for the individual tickets that are part of this transaction.

Parameters:
transTicket - the ticket for the transaction
Throws:
StatusNotFoundException - thrown if the transaction ticket was not found in the cache

addStatus

public java.lang.String addStatus(java.lang.String deliveryChanelId,
                                  IndividualStatus status)
Add a new status object to the cache.

Parameters:
deliveryChanelId - the delivery channel's ID
status - the status object to store in the cache
Returns:
the ticket ID which can be used to retrieve the status object

updateStatus

public void updateStatus(java.lang.String ticket,
                         IndividualStatus status)
                  throws StatusNotFoundException
Update the status object stored in the cache for a given ticket.

Parameters:
ticket - the ticket for which the object needs to be updated
status - the new status object to store in the cache
Throws:
StatusNotFoundException - thrown if there is nothing stored in the cache for the provided ticket

getStatus

public IndividualStatus getStatus(java.lang.String ticket)
                           throws StatusNotFoundException
Get a status object from the cache.

Parameters:
ticket - the ticket for which the status object is to be returned
Returns:
the status object that corresponds to the provided ticket
Throws:
StatusNotFoundException - thrown if there is nothing stored in the cache for the provided ticket

constructTicket

public static java.lang.String constructTicket(java.lang.String dc,
                                               java.lang.String ticket,
                                               java.lang.String recipient)
Creates a status ticket based on the delivery channel's ID, some ticket value provided by the delivery channel and the recipient. This is to be used by the delivery channels to generate status tickets for standard outcomes in order to avoid storing the status object in the cache.

Parameters:
dc - delivery channel's ID
ticket - the delivery channel's internal ticket/code
recipient - the recipient's address (including the protocol prefix)
Returns:
a String which combines the provided information in a standard way that will be parseable by NotificationService.getStatus()

getDeliveryChannelId

public static java.lang.String getDeliveryChannelId(java.lang.String ticket)
Returns the delivery channel ID from the ticket string.

Parameters:
ticket - complete ticket string
Returns:
delivery channel that is part of the ticket

getTicketId

public static java.lang.String getTicketId(java.lang.String ticket)
Returns the ticket's content from the complete ticket string. This is the part that the delivery channel will use.

Parameters:
ticket - complete ticket string
Returns:
ticket's content from the complete ticket string

getTicketRecipient

public static java.lang.String getTicketRecipient(java.lang.String ticket)
Returns the recipient info encoded in the ticket.

Parameters:
ticket - the complete ticket string
Returns:
recipient information if any was encoded in the ticket

getAllTransactions

protected java.util.Set<java.lang.String> getAllTransactions()
Returns a set of all the transaction IDs currently in the cache.

Returns:
transaction IDs currently in the cache

signalShutdown

protected void signalShutdown()
Server is shutting down so we need to make sure that the clean up thread(s) are shut down.


Nitido NiM 2.5 Java API

These JavaDoc pages are generated for release/nim_2_5-2.5.44

Copyright © 1999-2009 Nitido Inc.    Proprietary and Confidential.    All Rights Reserved.