net.rim.pushsdk.push.stats
Class PushStatsServiceImpl

java.lang.Object
  extended by net.rim.pushsdk.push.stats.PushStatsServiceImpl
All Implemented Interfaces:
PushStatsService

public class PushStatsServiceImpl
extends Object
implements PushStatsService

Implementation of the PushStatsService interface.

Dependencies that must be injected to properly initialize this object for use:
- pushStatsDAO
- pushApplicationService
- pushStatsBatchUpdaterService

Author:
dstrelbytsky

Constructor Summary
PushStatsServiceImpl()
           
 
Method Summary
 long getRemainingQuota(String pushApplicationId, boolean preferUseCache)
          Gets the remaining quota (in number of pushes) for the specified push application.
 long getRunningContentSum(String pushApplicationId)
          Gets the total bytes of content pushed to the specified push application.
 long getRunningPushCount(String pushApplicationId)
          Gets a running count of pushes for the specified push application.
 void incrementPushStats(String pushApplicationId, long pushCount, long contentSum)
          Increments the push statistics for a push application by the given push count and total content sum.
 void resetRunningContentSum(String pushApplicationId)
          Resets the running content sum pushed to the specified push application.
 void resetRunningPushCount(String pushApplicationId)
          Resets the running push count for the specified push application.
 void setPushApplicationService(PushApplicationService pushApplicationService)
          Support for dependency injection.
 void setPushStatsBatchUpdaterService(PushStatsBatchUpdaterService pushStatsBatchUpdaterService)
          Support for dependency injection.
 void setPushStatsDAO(PushStatsDAO pushStatsDAO)
          Support for dependency injection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushStatsServiceImpl

public PushStatsServiceImpl()
Method Detail

setPushStatsDAO

public void setPushStatsDAO(PushStatsDAO pushStatsDAO)
Description copied from interface: PushStatsService
Support for dependency injection. Sets the PushStatsDAO to use.

Specified by:
setPushStatsDAO in interface PushStatsService
Parameters:
pushStatsDAO - a Push Stats Data Access Object

setPushApplicationService

public void setPushApplicationService(PushApplicationService pushApplicationService)
Description copied from interface: PushStatsService
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 PushStatsService
Parameters:
pushApplicationService - an instance of a PushApplicationService implementation (must be thread safe)

setPushStatsBatchUpdaterService

public void setPushStatsBatchUpdaterService(PushStatsBatchUpdaterService pushStatsBatchUpdaterService)
Description copied from interface: PushStatsService
Support for dependency injection. Sets the PushStatsBatchUpdaterService to use.

Specified by:
setPushStatsBatchUpdaterService in interface PushStatsService
Parameters:
pushStatsBatchUpdaterService - the Push Stats Batch Updater Service

incrementPushStats

public void incrementPushStats(String pushApplicationId,
                               long pushCount,
                               long contentSum)
                        throws PushSDKException
Description copied from interface: PushStatsService
Increments the push statistics for a push application by the given push count and total content sum. If there are no push statistics for this push application, a new entry will be created in storage and will be used as a basis for future increments.

Specified by:
incrementPushStats in interface PushStatsService
Parameters:
pushApplicationId - id of the push application that the push statistics correspond to
pushCount - the number of addresses being pushed to in a push request. If one push contains N addresses, the pushCount will be equal to N.
contentSum - the content size of the push multiplied by the number of addresses being pushed to in the push request. If J bytes of content was sent to N devices, the contentSum will be equal to J * N.
Throws:
PushSDKException - if any errors occur

getRunningPushCount

public long getRunningPushCount(String pushApplicationId)
                         throws PushSDKException
Description copied from interface: PushStatsService
Gets a running count of pushes for the specified push application.

Specified by:
getRunningPushCount in interface PushStatsService
Parameters:
pushApplicationId - id of the push application that the push statistics correspond to
Returns:
the number of pushes since this value was reset for the push application
Throws:
PushSDKException - if any errors occur

getRunningContentSum

public long getRunningContentSum(String pushApplicationId)
                          throws PushSDKException
Description copied from interface: PushStatsService
Gets the total bytes of content pushed to the specified push application.

Specified by:
getRunningContentSum in interface PushStatsService
Parameters:
pushApplicationId - id of the push application that the push statistics correspond to
Returns:
the total volume of content pushed since this value was reset for the push application
Throws:
PushSDKException - if any errors occur

getRemainingQuota

public long getRemainingQuota(String pushApplicationId,
                              boolean preferUseCache)
                       throws PushSDKException
Description copied from interface: PushStatsService
Gets the remaining quota (in number of pushes) for the specified push application.

Specified by:
getRemainingQuota in interface PushStatsService
Parameters:
pushApplicationId - id of the push application that the push statistics correspond to
preferUseCache - specifies whether the cached value of the remaining quota is preferable or not. In the first case ( preferUseCache is equal to true), the method will try to retrieve the remaining quota from the cache first. If there is no cached value found, a look up in the persistent store will be done. If preferUseCache is equal to false, the remaining quota will always be retrieved from the persistent store. Using the cache will generally be a faster operation. Note: Retrieving the remaining quota from the persistent store can be somewhat inaccurate. Updates to the push statistics in storage are batched and persisted at a regular interval and so the stats might be slightly off within that interval.
Returns:
the remaining daily quota in number of pushes
Throws:
PushSDKException - if any errors occur

resetRunningPushCount

public void resetRunningPushCount(String pushApplicationId)
                           throws PushSDKException
Description copied from interface: PushStatsService
Resets the running push count for the specified push application.

Specified by:
resetRunningPushCount in interface PushStatsService
Parameters:
pushApplicationId - id of the push application that the push statistics correspond to
Throws:
PushSDKException - if any errors occur

resetRunningContentSum

public void resetRunningContentSum(String pushApplicationId)
                            throws PushSDKException
Description copied from interface: PushStatsService
Resets the running content sum pushed to the specified push application.

Specified by:
resetRunningContentSum in interface PushStatsService
Parameters:
pushApplicationId - id of the push application that the push statistics correspond to
Throws:
PushSDKException - if any errors occur


Copyright © 2011 Research In Motion. All Rights Reserved.