net.rim.pushsdk.acknowledgement
Class NotificationProcessorServiceImpl

java.lang.Object
  extended by net.rim.pushsdk.acknowledgement.NotificationProcessorServiceImpl
All Implemented Interfaces:
Runnable, NotificationProcessorService

public class NotificationProcessorServiceImpl
extends Object
implements NotificationProcessorService

Implementation of the NotificationProcessorService interface.

Dependencies that must be injected to properly initialize this object for use:
- pushRequestService
- pushRequestDetailService
- subscriptionService
- pushApplicationService
- pushSDKProperties
- pushCountService
- notificationListenerService

Author:
mdandrea

Constructor Summary
NotificationProcessorServiceImpl()
           
 
Method Summary
 void addNotification(Notification notification)
          Checks if the result notification queue is not full and places a Notification into it and starts the run thread.
 void destroy()
          Attempts to stop threads when the bean is destroyed.
 int getNotificationProcessorActiveThreadCount()
          Returns the number of threads actively processing notifications.
 int getNotificationProcessorQueueSize()
          Returns the size of the result notification queue.
 int getNotificationProcessorThreadPoolSize()
          Returns the number of threads currently in the thread pool (active and idle).
 int getNotificationProcessorWorkQueueSize()
          Returns the size of the work queue which holds tasks (Runnables) waiting to be picked up and processed using an active thread.
 boolean isResultNotificationQueueFull()
          Determines whether or not the processing queue is already full.
 void processNotifications(List<Notification> notifications)
          Note that this method is used internally by the SDK and should not normally be externally invoked or overridden.
 void reconcile(List<Notification> notifications)
          Note that this method is used internally by the SDK and should not normally be externally invoked or overridden.
 void run()
          Makes a call to the getBatchOfNotifications method that batches the result notification messages.
 void setNotificationListenerService(NotificationListenerService notificationListenerService)
          Support for dependency injection.
 void setPushApplicationService(PushApplicationService pushApplicationService)
          Support for dependency injection.
 void setPushCountService(PushCountService pushCountService)
          Support for dependency injection.
 void setPushRequestDetailService(PushRequestDetailService pushRequestDetailService)
          Support for dependency injection.
 void setPushRequestService(PushRequestService pushRequestService)
          Support for dependency injection.
 void setPushSDKProperties(PushSDKProperties properties)
          Support for dependency injection.
 void setSubscriptionService(SubscriptionService subscriptionService)
          Support for dependency injection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotificationProcessorServiceImpl

public NotificationProcessorServiceImpl()
Method Detail

setPushSDKProperties

public void setPushSDKProperties(PushSDKProperties properties)
Description copied from interface: NotificationProcessorService
Support for dependency injection. Inject an implementation of a PushSDKProperties collaborating object - this is used to read global configuration properties.

Specified by:
setPushSDKProperties in interface NotificationProcessorService
Parameters:
properties - an instance of a PushSDKProperties implementation (must be thread safe)

setPushApplicationService

public void setPushApplicationService(PushApplicationService pushApplicationService)
Description copied from interface: NotificationProcessorService
Support for dependency injection. Inject an implementation of a PushApplicationService collaborating object - this is used to interface with the business service that manages push applications.

Specified by:
setPushApplicationService in interface NotificationProcessorService
Parameters:
pushApplicationService - an instance of a PushApplicationService implementation (must be thread safe)

setPushCountService

public void setPushCountService(PushCountService pushCountService)
Description copied from interface: NotificationProcessorService
Support for dependency injection. Inject an implementation of a PushCountService collaborating object - this is used to interface with the business service that manages tracking pushes that are complete.

Specified by:
setPushCountService in interface NotificationProcessorService
Parameters:
pushCountService - an instance of a PushCountService implementation (must be thread safe)

setPushRequestDetailService

public void setPushRequestDetailService(PushRequestDetailService pushRequestDetailService)
Description copied from interface: NotificationProcessorService
Support for dependency injection. Inject an implementation of a PushRequestDetailService collaborating object - this is used to interface with the business service that manages push request details.

Specified by:
setPushRequestDetailService in interface NotificationProcessorService
Parameters:
pushRequestDetailService - an instance of a PushRequestDetailService implementation (must be thread safe)

setSubscriptionService

public void setSubscriptionService(SubscriptionService subscriptionService)
Description copied from interface: NotificationProcessorService
Support for dependency injection. Inject an implementation of a SubscriptionService collaborating object - this is used to interface with the business service that manages subscribers.

Specified by:
setSubscriptionService in interface NotificationProcessorService
Parameters:
subscriptionService - an instance of a SubscriptionService implementation (must be thread safe)

setPushRequestService

public void setPushRequestService(PushRequestService pushRequestService)
Description copied from interface: NotificationProcessorService
Support for dependency injection. Inject an implementation of a PushRequestService collaborating object - this is used to interface with the business service that manages push requests.

Specified by:
setPushRequestService in interface NotificationProcessorService
Parameters:
pushRequestService - an instance of a PushRequestService implementation (must be thread safe)

setNotificationListenerService

public void setNotificationListenerService(NotificationListenerService notificationListenerService)
Description copied from interface: NotificationProcessorService
Support for dependency injection. Inject an implementation of a NotificationListenerService collaborating object - this is used to interface with the business service that manages notifying the acknowledgement listeners.

Specified by:
setNotificationListenerService in interface NotificationProcessorService
Parameters:
notificationListenerService - an instance of a NotificationListenerService implementation (must be thread safe)

destroy

public void destroy()
Description copied from interface: NotificationProcessorService
Attempts to stop threads when the bean is destroyed.

Specified by:
destroy in interface NotificationProcessorService

getNotificationProcessorQueueSize

public int getNotificationProcessorQueueSize()
Description copied from interface: NotificationProcessorService
Returns the size of the result notification queue.

Specified by:
getNotificationProcessorQueueSize in interface NotificationProcessorService
Returns:
the size of the result notification queue

getNotificationProcessorActiveThreadCount

public int getNotificationProcessorActiveThreadCount()
Description copied from interface: NotificationProcessorService
Returns the number of threads actively processing notifications.

Specified by:
getNotificationProcessorActiveThreadCount in interface NotificationProcessorService
Returns:
the number of active processing threads

getNotificationProcessorThreadPoolSize

public int getNotificationProcessorThreadPoolSize()
Description copied from interface: NotificationProcessorService
Returns the number of threads currently in the thread pool (active and idle).

Specified by:
getNotificationProcessorThreadPoolSize in interface NotificationProcessorService
Returns:
the number of threads in the thread pool

getNotificationProcessorWorkQueueSize

public int getNotificationProcessorWorkQueueSize()
Description copied from interface: NotificationProcessorService
Returns the size of the work queue which holds tasks (Runnables) waiting to be picked up and processed using an active thread.

Specified by:
getNotificationProcessorWorkQueueSize in interface NotificationProcessorService
Returns:
the size of the work queue

isResultNotificationQueueFull

public boolean isResultNotificationQueueFull()
Description copied from interface: NotificationProcessorService
Determines whether or not the processing queue is already full.

Specified by:
isResultNotificationQueueFull in interface NotificationProcessorService
Returns:
true if the queue is full; otherwise, false

addNotification

public void addNotification(Notification notification)
                     throws PushSDKException
Checks if the result notification queue is not full and places a Notification into it and starts the run thread. If the queue is full, the method throws a PushSDKException that is wrapped around a FullNotificationQueueException.

Specified by:
addNotification in interface NotificationProcessorService
Parameters:
notification - the notification to add to the queue
Throws:
PushSDKException - if the notification could not be added to the queue because the queue is full

run

public void run()
Makes a call to the getBatchOfNotifications method that batches the result notification messages.

Specified by:
run in interface Runnable
Specified by:
run in interface NotificationProcessorService

processNotifications

public void processNotifications(List<Notification> notifications)
                          throws PushSDKException
Description copied from interface: NotificationProcessorService
Note that this method is used internally by the SDK and should not normally be externally invoked or overridden. Processes result notifications. It includes the following:
- reconciliation, if the original push was made to the push application with storePushRequest set to true; This includes updating the status of the push request details in the repository - if the original push was made to the push application with autoDeleteRequests set to true; the push request and it's details will be permanently removed from the persistent store
- subscription management (except in the bypassSubscription case): automatically unsubscribe a user when the result notification indicates that the specified address was not recognized by the PPG (i.e. 2002 status code)
- notification of registered listeners (including tracking of the last notification for a given push)

Note: As of version 1.1 of the SDK subscriptions will no longer but automatically unsubscribed on a StatusCode.PORT_CLOSED. In addition it will no longer keep track of the number of consecutive failed push attempts for a given subscriber. This logic will be implemented by version 1.1 of the public/BIS PPG. For enterprise/BES applications it is recommended push initiator's implement this logic in their own applications if required by subclassing the FailureNotificationListener from the acknowledgement component.

Specified by:
processNotifications in interface NotificationProcessorService
Parameters:
notifications - list of value objects that represent notifications
Throws:
PushSDKException - if the result notifications cannot be processed for various reasons

reconcile

public void reconcile(List<Notification> notifications)
               throws PushSDKException
Description copied from interface: NotificationProcessorService
Note that this method is used internally by the SDK and should not normally be externally invoked or overridden. Reconciles the result notifications in the back end system.

Specified by:
reconcile in interface NotificationProcessorService
Parameters:
notifications - list of value objects that represent notifications
Throws:
PushSDKException - if the result notifications cannot be processed for various reasons


Copyright © 2011 Research In Motion. All Rights Reserved.