|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ThreadGroup
javapns.notification.transmission.NotificationThreads
public class NotificationThreads
The list of devices is spread evenly into multiple NotificationThread
s.
Usage: once a NotificationThreads is created, invoke start()
to start all NotificationThread
threads.
You can provide a NotificationProgressListener
to receive events about the work being done.
NotificationThread.MODE
,
NotificationThread
Constructor Summary | |
---|---|
NotificationThreads(AppleNotificationServer server,
int numberOfThreads)
Create a pool of notification threads in QUEUE mode. |
|
NotificationThreads(AppleNotificationServer server,
List<PayloadPerDevice> messages,
int numberOfThreads)
Create the specified number of notification threads and spread the messages evenly between the threads. |
|
NotificationThreads(AppleNotificationServer server,
Payload payload,
List<Device> devices,
int numberOfThreads)
Create the specified number of notification threads and spread the devices evenly between the threads. |
|
NotificationThreads(AppleNotificationServer server,
Payload payload,
List<Device> devices,
List<NotificationThread> threads)
Spread the devices evenly between the provided threads. |
|
NotificationThreads(AppleNotificationServer server,
Payload payload,
List<NotificationThread> threads)
Use the provided threads which should already each have their group of devices to work with. |
|
NotificationThreads(Object keystore,
String password,
boolean production,
Payload payload,
List<Device> devices,
int numberOfThreads)
Create the specified number of notification threads and spread the devices evenly between the threads. |
|
NotificationThreads(Object keystore,
String password,
boolean production,
Payload payload,
List<Device> devices,
List<NotificationThread> threads)
Spread the devices evenly between the provided threads. |
|
NotificationThreads(Object keystore,
String password,
boolean production,
Payload payload,
List<NotificationThread> threads)
Use the provided threads which should already each have their group of devices to work with. |
Method Summary | |
---|---|
PushQueue |
add(Payload payload,
Device device)
Queue a message for delivery. |
PushQueue |
add(PayloadPerDevice message)
Queue a message for delivery. |
PushQueue |
add(Payload payload,
String token)
Queue a message for delivery. |
void |
clearPushedNotifications()
Deprecated. Not thead-safe. use getPushedNotifications(true) instead. |
List<Exception> |
getCriticalExceptions()
Get a list of critical exceptions that threads experienced. |
long |
getDelayBetweenThreads()
Get the amount of time that the library will wait after starting a thread and before starting the next one. |
PushedNotifications |
getFailedNotifications()
Deprecated. Not thead-safe. use getPushedNotifications(true).getFailedNotifications() instead. |
NotificationProgressListener |
getListener()
Get the progress listener, if any is attached. |
PushedNotifications |
getPushedNotifications(boolean clearLists)
Get a list of all notifications pushed by all threads. |
PushedNotifications |
getSuccessfulNotifications()
Deprecated. Not thead-safe. use getPushedNotifications(true).getSuccessfulNotifications() instead. |
List<NotificationThread> |
getThreads()
Get a list of threads created to push notifications. |
void |
setDelayBetweenThreads(long delayBetweenThreads)
Set the amount of time that the library will wait after starting a thread and before starting the next one. |
void |
setListener(NotificationProgressListener listener)
Attach an event listener to this object as well as all linked threads. |
void |
setMaxNotificationsPerConnection(int notifications)
Configure in all threads the maximum number of notifications per connection. |
void |
setSleepBetweenNotifications(long milliseconds)
Configure in all threads the number of milliseconds that threads should wait between each notification. |
NotificationThreads |
start()
Start all notification threads. |
void |
stopQueue()
Invoke stopQueue on all threads working for the queue. |
void |
waitForAllThreads()
Wait for all threads to complete their work. |
void |
waitForAllThreads(boolean throwCriticalExceptions)
Wait for all threads to complete their work, but throw any critical exception that occurs in a thread. |
Methods inherited from class java.lang.ThreadGroup |
---|
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString, uncaughtException |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NotificationThreads(AppleNotificationServer server, Payload payload, List<Device> devices, int numberOfThreads)
server
- the server to push topayload
- the payload to pushdevices
- a very large list of devicesnumberOfThreads
- the number of threads to create to share the workpublic NotificationThreads(AppleNotificationServer server, List<PayloadPerDevice> messages, int numberOfThreads)
server
- the server to push tomessages
- a very large list of payload/device pairsnumberOfThreads
- the number of threads to create to share the workpublic NotificationThreads(Object keystore, String password, boolean production, Payload payload, List<Device> devices, int numberOfThreads) throws Exception
keystore
- the keystore to use (can be a File, an InputStream, a String for a file path, or a byte[] array)password
- the keystore's passwordproduction
- true to use Apple's production servers, false to use the sandboxpayload
- the payload to pushdevices
- a very large list of devicesnumberOfThreads
- the number of threads to create to share the work
Exception
public NotificationThreads(AppleNotificationServer server, Payload payload, List<Device> devices, List<NotificationThread> threads)
server
- the server to push topayload
- the payload to pushdevices
- a very large list of devicesthreads
- a list of pre-built threadspublic NotificationThreads(Object keystore, String password, boolean production, Payload payload, List<Device> devices, List<NotificationThread> threads) throws Exception
keystore
- the keystore to use (can be a File, an InputStream, a String for a file path, or a byte[] array)password
- the keystore's passwordproduction
- true to use Apple's production servers, false to use the sandboxpayload
- the payload to pushdevices
- a very large list of devicesthreads
- a list of pre-built threads
Exception
public NotificationThreads(AppleNotificationServer server, Payload payload, List<NotificationThread> threads)
server
- the server to push topayload
- the payload to pushthreads
- a list of pre-built threadspublic NotificationThreads(Object keystore, String password, boolean production, Payload payload, List<NotificationThread> threads) throws Exception
keystore
- the keystore to use (can be a File, an InputStream, a String for a file path, or a byte[] array)password
- the keystore's passwordproduction
- true to use Apple's production servers, false to use the sandboxpayload
- the payload to pushthreads
- a list of pre-built threads
Exception
public NotificationThreads(AppleNotificationServer server, int numberOfThreads)
server
- the server to push tonumberOfThreads
- the number of threads to create in the poolMethod Detail |
---|
public PushQueue add(Payload payload, String token) throws InvalidDeviceTokenFormatException
PushQueue
add
in interface PushQueue
payload
- a payloadtoken
- a device token
InvalidDeviceTokenFormatException
public PushQueue add(Payload payload, Device device)
PushQueue
add
in interface PushQueue
payload
- a payloaddevice
- a device
public PushQueue add(PayloadPerDevice message)
PushQueue
add
in interface PushQueue
message
- a payload/device pair
public NotificationThreads start()
start
in interface PushQueue
public void setMaxNotificationsPerConnection(int notifications)
notifications
- the maximum number of notifications that threads will push in a single connection (default is 200)public void setSleepBetweenNotifications(long milliseconds)
milliseconds
- the number of milliseconds threads should sleep between individual notifications (default is 0)public void stopQueue()
PushQueue
stopQueue
in interface PushQueue
public List<NotificationThread> getThreads()
public NotificationProgressListener getListener()
public void setListener(NotificationProgressListener listener)
listener
- public void waitForAllThreads() throws InterruptedException
InterruptedException
public void waitForAllThreads(boolean throwCriticalExceptions) throws Exception
throwCriticalExceptions
- If true, this method will throw the first critical exception that occured in a thread (if any). If false, critical exceptions will not be checked.
Exception
- if throwCriticalExceptions is true and a critical exception did occur in a threadpublic PushedNotifications getPushedNotifications(boolean clearLists)
getPushedNotifications
in interface PushQueue
@Deprecated public void clearPushedNotifications()
clearPushedNotifications
in interface PushQueue
@Deprecated public PushedNotifications getFailedNotifications()
@Deprecated public PushedNotifications getSuccessfulNotifications()
public List<Exception> getCriticalExceptions()
getCriticalExceptions
in interface PushQueue
public void setDelayBetweenThreads(long delayBetweenThreads)
delayBetweenThreads
- a number of millisecondspublic long getDelayBetweenThreads()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |