|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.notnoop.apns.ApnsServiceBuilder
public class ApnsServiceBuilder
The class is used to create instances of ApnsService.
Note that this class is not synchronized. If multiple threads access a
ApnsServiceBuilder instance concurrently, and at least on of the
threads modifies one of the attributes structurally, it must be
synchronized externally.
Starting a new ApnsService is easy:
ApnsService = APNS.newService()
.withCert("/path/to/certificate.p12", "MyCertPassword")
.withSandboxDestination()
.build()
| Constructor Summary | |
|---|---|
ApnsServiceBuilder()
Constructs a new instance of ApnsServiceBuilder |
|
| Method Summary | |
|---|---|
ApnsServiceBuilder |
asBatched()
Construct service which will process notification requests in batch. |
ApnsServiceBuilder |
asBatched(int waitTimeInSec,
int maxWaitTimeInSec)
Construct service which will process notification requests in batch. |
ApnsServiceBuilder |
asBatched(int waitTimeInSec,
int maxWaitTimeInSec,
ThreadFactory threadFactory)
Construct service which will process notification requests in batch. |
ApnsServiceBuilder |
asPool(ExecutorService executor,
int maxConnections)
Constructs a pool of connections to the notification servers. |
ApnsServiceBuilder |
asPool(int maxConnections)
Constructs a pool of connections to the notification servers. |
ApnsServiceBuilder |
asQueued()
Constructs a new thread with a processing queue to process notification requests. |
ApnsService |
build()
Returns a fully initialized instance of ApnsService,
according to the requested settings. |
ApnsServiceBuilder |
withAppleDestination(boolean isProduction)
Specify to use Apple servers as iPhone gateway and feedback servers. |
ApnsServiceBuilder |
withAutoAdjustCacheLength(boolean autoAdjustCacheLength)
Specify if the notification cache should auto adjust. |
ApnsServiceBuilder |
withCacheLength(int cacheLength)
Specity the number of notifications to cache for error purposes. |
ApnsServiceBuilder |
withCert(InputStream stream,
String password)
Specify the certificate used to connect to Apple APNS servers. |
ApnsServiceBuilder |
withCert(KeyStore keyStore,
String password)
Specify the certificate used to connect to Apple APNS servers. |
ApnsServiceBuilder |
withCert(String fileName,
String password)
Specify the certificate used to connect to Apple APNS servers. |
ApnsServiceBuilder |
withDelegate(ApnsDelegate delegate)
Sets the delegate of the service, that gets notified of the status of message delivery. |
ApnsServiceBuilder |
withFeedbackDestination(String host,
int port)
Specify the Feedback for getting failed devices from Apple iPhone Push servers. |
ApnsServiceBuilder |
withGatewayDestination(String host,
int port)
Specify the gateway server for sending Apple iPhone notifications. |
ApnsServiceBuilder |
withNoErrorDetection()
Disables the enhanced error detection, enabled by the enhanced push notification interface. |
ApnsServiceBuilder |
withProductionDestination()
Specify to use the Apple Production servers as iPhone gateway and feedback servers. |
ApnsServiceBuilder |
withProxy(Proxy proxy)
Specify the proxy to be used to establish the connections to Apple Servers Read the Java Networking and Proxies guide to understand the proxies complexity. |
ApnsServiceBuilder |
withProxySocket(Socket proxySocket)
Deprecated. use withProxy(Proxy) instead |
ApnsServiceBuilder |
withReconnectPolicy(ReconnectPolicy.Provided rp)
Specify the reconnection policy for the socket connection. |
ApnsServiceBuilder |
withReconnectPolicy(ReconnectPolicy rp)
Specify the reconnection policy for the socket connection. |
ApnsServiceBuilder |
withSandboxDestination()
Specify to use the Apple sandbox servers as iPhone gateway and feedback servers. |
ApnsServiceBuilder |
withSocksProxy(String host,
int port)
Specify the address of the SOCKS proxy the connection should use. |
ApnsServiceBuilder |
withSSLContext(SSLContext sslContext)
Specify the SSLContext that should be used to initiate the connection to Apple Server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ApnsServiceBuilder()
ApnsServiceBuilder
| Method Detail |
|---|
public ApnsServiceBuilder withCert(String fileName,
String password)
throws RuntimeIOException,
InvalidSSLConfig
fileName - the path to the certificatepassword - the password of the keystore
RuntimeIOException - if it fileName cannot be
found or read
InvalidSSLConfig - if fileName is invalid Keystore
or the password is invalid
public ApnsServiceBuilder withCert(InputStream stream,
String password)
throws InvalidSSLConfig
stream - the keystore represented as input streampassword - the password of the keystore
InvalidSSLConfig - if stream is invalid Keystore
or the password is invalid
public ApnsServiceBuilder withCert(KeyStore keyStore,
String password)
throws InvalidSSLConfig
stream - the keystorepassword - the password of the keystore
InvalidSSLConfig - if stream is invalid Keystore
or the password is invalidpublic ApnsServiceBuilder withSSLContext(SSLContext sslContext)
withCert(InputStream, String)
or withCert(String, String) instead. But some
clients may need to represent the Keystore in a different
format than supported.
sslContext - Context to be used to create secure connections
public ApnsServiceBuilder withGatewayDestination(String host,
int port)
withSandboxDestination()
or withProductionDestination(). Clients may use
this method to connect to mocking tests and such.
host - hostname the notification gateway of Appleport - port of the notification gateway of Apple
public ApnsServiceBuilder withFeedbackDestination(String host,
int port)
withSandboxDestination()
or withProductionDestination(). Clients may use
this method to connect to mocking tests and such.
host - hostname of the feedback server of Appleport - port of the feedback server of Apple
public ApnsServiceBuilder withAppleDestination(boolean isProduction)
isProduction is true, then it connects to the
production servers, otherwise, it connects to the sandbox servers
isProduction - determines which Apple servers should be used:
production or sandbox
public ApnsServiceBuilder withSandboxDestination()
public ApnsServiceBuilder withProductionDestination()
public ApnsServiceBuilder withReconnectPolicy(ReconnectPolicy rp)
public ApnsServiceBuilder withAutoAdjustCacheLength(boolean autoAdjustCacheLength)
autoAdjustCacheLength -
public ApnsServiceBuilder withReconnectPolicy(ReconnectPolicy.Provided rp)
public ApnsServiceBuilder withSocksProxy(String host,
int port)
Read the Java Networking and Proxies guide to understand the proxies complexity.
Be aware that this method only handles SOCKS proxies, not
HTTPS proxies. Use withProxy(Proxy) instead.
host - the hostname of the SOCKS proxyport - the port of the SOCKS proxy server
public ApnsServiceBuilder withProxy(Proxy proxy)
Read the Java Networking and Proxies guide to understand the proxies complexity.
proxy - the proxy object to be used to create connections
public ApnsServiceBuilder withCacheLength(int cacheLength)
cacheLength - Number of notifications to cache for error purposes
@Deprecated public ApnsServiceBuilder withProxySocket(Socket proxySocket)
withProxy(Proxy) instead
proxySocket - the underlying socket for connections
public ApnsServiceBuilder asPool(int maxConnections)
public ApnsServiceBuilder asPool(ExecutorService executor,
int maxConnections)
public ApnsServiceBuilder asQueued()
public ApnsServiceBuilder asBatched()
waitTimeInSec (set as 5sec) for more request to come
before executing but not more than maxWaitTimeInSec (set as 10sec)
Note: It is not recommended to use pooled connection
public ApnsServiceBuilder asBatched(int waitTimeInSec,
int maxWaitTimeInSec)
waitTimeInSec for more request to come
before executing but not more than maxWaitTimeInSec
Note: It is not recommended to use pooled connection
waitTimeInSec - time to wait for more notification request before executing
batchmaxWaitTimeInSec - maximum wait time for batch before executing
public ApnsServiceBuilder asBatched(int waitTimeInSec,
int maxWaitTimeInSec,
ThreadFactory threadFactory)
waitTimeInSec for more request to come
before executing but not more than maxWaitTimeInSec>
Each batch creates new connection and close it after finished.
In case reconnect policy is specified it will be applied by batch processing.
E.g.: ReconnectPolicy.Provided.EVERY_HALF_HOUR will reconnect the connection in case batch is running for more than half an hour
Note: It is not recommended to use pooled connection
waitTimeInSec - time to wait for more notification request before executing
batchmaxWaitTimeInSec - maximum wait time for batch before executingthreadFactory - thread factory to use for batch processingpublic ApnsServiceBuilder withDelegate(ApnsDelegate delegate)
public ApnsServiceBuilder withNoErrorDetection()
public ApnsService build()
ApnsService,
according to the requested settings.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||