net.rim.pushsdk.subscription.match
Class SubStatusMatchManager

java.lang.Object
  extended by net.rim.pushsdk.subscription.match.SubStatusMatchManager
All Implemented Interfaces:
Callable<Set<String>>

public class SubStatusMatchManager
extends Object
implements Callable<Set<String>>

Performs threaded subscription matching to retrieve a list of subscriber ids for a push application that have a certain status (e.g. ACTIVE) and were found in a given list of subscriber ids.

The algorithm used here is:
For each request that comes in through a call to the matchSubscriptions method,

  1. Get a list of subscribers from storage with the given app id, status, from index, and to index through a call to the findByAppIdAndStatus method from the SubscriptionService interface.
  2. Compare the list of subscribers that were obtained from the last step with the list of subscriber ids provided in the request. The new list of subscriber ids should be the ones that are found in both lists.
After all the requests have been processed, the list of subscriber ids back from processing each request are combined and can be obtained by calling the getSubscriptionMatchResults method.

Author:
mdandrea

Constructor Summary
SubStatusMatchManager()
           
 
Method Summary
 Set<String> call()
          Pulls a match request off the queue and performs the subscription matching for that one request.
 Set<String> getSubscriptionMatchResults()
          This method must be called after all matchSubscriptions() method calls have been made with requests.
 void matchSubscriptions(String pushAppId, Set<String> subscriberIds, SubscriberStatus status, int fromIndex, int toIndex)
          Initiates the process to match the subscriptions from storage with the ones from the given subscriber ids set.
 void setPushSDKProperties(PushSDKProperties pushSDKProperties)
          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

SubStatusMatchManager

public SubStatusMatchManager()
Method Detail

setPushSDKProperties

public void setPushSDKProperties(PushSDKProperties pushSDKProperties)
Support for dependency injection. This will override the default PushSDKProperties implementation.

Parameters:
pushSDKProperties -

setSubscriptionService

public void setSubscriptionService(SubscriptionService subscriptionService)
Support for dependency injection. Inject an implementation of a SubscriptionService collaborating object.

Parameters:
subscriptionService - an instance of a SubscriptionService implementation (must be thread safe)

matchSubscriptions

public void matchSubscriptions(String pushAppId,
                               Set<String> subscriberIds,
                               SubscriberStatus status,
                               int fromIndex,
                               int toIndex)
Initiates the process to match the subscriptions from storage with the ones from the given subscriber ids set.

Parameters:
pushAppId - the id of a push application
subscriberIds - the subscriber ids to match
status - the status of the subscribers to look for in storage
fromIndex - the row/entry number in storage to start looking for subscribers at
toIndex - the row/entry number in storage to stop looking for subscribers at

getSubscriptionMatchResults

public Set<String> getSubscriptionMatchResults()
                                        throws ExecutionException,
                                               InterruptedException
This method must be called after all matchSubscriptions() method calls have been made with requests.

Returns:
a combined list of subscriber results from all the match requests
Throws:
ExecutionException - if the computation threw an exception
InterruptedException - if the computation was interrupted while processing

call

public Set<String> call()
Pulls a match request off the queue and performs the subscription matching for that one request.

Specified by:
call in interface Callable<Set<String>>
Returns:
a list of matching subscriber ids from the request


Copyright © 2011 Research In Motion. All Rights Reserved.