net.rim.pushsdk.subscription.sync
Interface SubSyncByAddressDAO

All Known Implementing Classes:
SubSyncByAddressMemoryDAOImpl, SubSyncByAddressRDBMSDAOImpl

public interface SubSyncByAddressDAO

Interface defining data access methods for use during the syncing of subscriber statuses by address. Since there may be a large number of subscribers this DAO is used as an open cursor to a ResultSet where the caller of the API can request row by row instead of loading all the results into system memory.

This DAO is not to be used as a singleton spring bean as it is not stateless. It maintains state.

This DAO should be used with calls of the following form:

 SubSyncByAddressDAO subSyncByAddressDAO = createSubSyncByAddressDAO(); 
 try { 
     subSyncByAddressDAO.prepareFindByAppIdAndStatus(..., ...); 
 
     SubscriberPartial subPartial = null; 
     while((subPartial = subSyncByAddressDAO.getNextResult()) != null) { 
         // Perform some processing 
     } 
 } catch(SQLException e) {
     log.error("SQLException caught: ", e);
     throw new PushSDKException(e);
 } finally { 
     subSyncByAddressDAO.close(); 
 } 
 
 

Author:
mdandrea

Method Summary
 void close()
          Closes the result set and releases the database connection.
 SubscriberPartial getNextResult()
          Gets the next result from the result set (after performing a query for subscribers).
 void prepareFindByAppIdAndStatus(String pushApplicationId, SubscriberStatus status, int startIndex, int endIndex)
          Performs a query for subscribers based on the given app id, status, and start and end indexes.
 void prepareFindByAppIdAndStatusAndType(String pushApplicationId, SubscriberStatus status, SubscriberType type, int startIndex, int endIndex)
          Performs a query for subscribers based on the given app id, status, type, and start and end indexes.
 

Method Detail

prepareFindByAppIdAndStatus

void prepareFindByAppIdAndStatus(String pushApplicationId,
                                 SubscriberStatus status,
                                 int startIndex,
                                 int endIndex)
                                 throws SQLException
Performs a query for subscribers based on the given app id, status, and start and end indexes.

Note: When a status of INACTIVE is specified, it will only retrieve inactive subscribers for which there is not an active or suspended subscriber for that application currently using the same address (e.g. PIN).

Note: This method does not have a return value because the result set is kept alive as an instance variable. The results are accessed through the getNextResult() method. When use of the result set is done, the close() method should be called.

Note: This method uses the same result set instance variable as the prepareFindByAppIdAndStatusAndType() method and so, for a given object of this class, only one of the two methods should be called at any given time.

Parameters:
pushApplicationId - the push application id
status - the status of a subscriber
startIndex - the start index to query from
endIndex - the end index to stop querying at
Throws:
SQLException - if any errors occur executing the query

prepareFindByAppIdAndStatusAndType

void prepareFindByAppIdAndStatusAndType(String pushApplicationId,
                                        SubscriberStatus status,
                                        SubscriberType type,
                                        int startIndex,
                                        int endIndex)
                                        throws SQLException
Performs a query for subscribers based on the given app id, status, type, and start and end indexes.

Note: When a status of INACTIVE is specified, it will only retrieve inactive subscribers for which there is not an active or suspended subscriber for that application currently using the same address (e.g. PIN).

Note: This method does not have a return value because the result set is kept alive as an instance variable. The results are accessed through the getNextResult() method. When use of the result set is done, the close() method should be called.

Note: This method uses the same result set instance variable as the prepareFindByAppIdAndStatus() method and so, for a given object of this class, only one of the two methods should be called at any given time.

Parameters:
pushApplicationId - the push application id
status - the status of a subscriber
type - the type of a subscriber
startIndex - the start index to query from
endIndex - the end index to stop querying at
Throws:
SQLException - if any errors occur executing the query

getNextResult

SubscriberPartial getNextResult()
                                throws SQLException
Gets the next result from the result set (after performing a query for subscribers).

Note: This method can only be called after a call to the prepareFindByAppIdAndStatus(appid, status) method or the prepareFindByAppIdAndStatusAndType(appid, status, type) method.

Returns:
the next subscriber result
Throws:
SQLException - if any errors occur retrieving the next result from the result set

close

void close()
Closes the result set and releases the database connection.

Note: This method should only be called after first calling the prepareFindByAppIdAndStatus(appid, status) method or the prepareFindByAppIdAndStatusAndType(appid, status, type) method and getting the results of the query back by repeated calls to the getNextResult() method.

This method should be called in a finally block.



Send feedback

Copyright © 2013 BlackBerry. All rights reserved.