com.notnoop.mpns
Class MpnsServiceBuilder

java.lang.Object
  extended by com.notnoop.mpns.MpnsServiceBuilder

public class MpnsServiceBuilder
extends Object

The class is used to create instances of MpnsService. Note that this class is not synchronized. If multiple threads access a MpnsServiceBuilder instance concurrently, and at least on of the threads modifies one of the attributes structurally, it must be synchronized externally. Starting a new MpnsService is easy:

   MpnsService service = MPNS.newService()
                  .build()
 


Nested Class Summary
static class MpnsServiceBuilder.SecurityInfo
           
 
Constructor Summary
MpnsServiceBuilder()
          Constructs a new instance of MpnsServiceBuilder
 
Method Summary
 MpnsServiceBuilder asAuthenticated(MpnsServiceBuilder.SecurityInfo securityInfo)
          Authenticated
 MpnsServiceBuilder asPool(ExecutorService executor, int maxConnections)
          Constructs a pool of connections to the notification servers.
 MpnsServiceBuilder asPool(int maxConnections)
          Constructs a pool of connections to the notification servers.
 MpnsServiceBuilder asQueued()
          Constructs a new thread with a processing queue to process notification requests.
 MpnsService build()
          Returns a fully initialized instance of MpnsService, according to the requested settings.
 MpnsServiceBuilder delegate(MpnsDelegate delegate)
           
 MpnsServiceBuilder timeout(int timeout)
          Sets the timeout for the connection
 MpnsServiceBuilder withHttpClient(org.apache.http.client.HttpClient httpClient)
          Sets the HttpClient instance along with any configuration NOTE: This is an advanced option that should be probably be used as a last resort.
 MpnsServiceBuilder withHttpProxy(String host, int port)
          Specify the address of the HTTP proxy the connection should use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MpnsServiceBuilder

public MpnsServiceBuilder()
Constructs a new instance of MpnsServiceBuilder

Method Detail

withHttpProxy

public MpnsServiceBuilder withHttpProxy(String host,
                                        int port)
Specify the address of the HTTP proxy the connection should use.

Read the Java Networking and Proxies guide to understand the proxies complexity.

Parameters:
host - the hostname of the HTTP proxy
port - the port of the HTTP proxy server
Returns:
this

withHttpClient

public MpnsServiceBuilder withHttpClient(org.apache.http.client.HttpClient httpClient)
Sets the HttpClient instance along with any configuration NOTE: This is an advanced option that should be probably be used as a last resort.

Parameters:
httpClient - the httpClient to be used
Returns:
this

asPool

public MpnsServiceBuilder asPool(int maxConnections)
Constructs a pool of connections to the notification servers.


asPool

public MpnsServiceBuilder asPool(ExecutorService executor,
                                 int maxConnections)
Constructs a pool of connections to the notification servers. Note: The maxConnections here is used as a hint to how many connections get created.


asQueued

public MpnsServiceBuilder asQueued()
Constructs a new thread with a processing queue to process notification requests.

Returns:
this

asAuthenticated

public MpnsServiceBuilder asAuthenticated(MpnsServiceBuilder.SecurityInfo securityInfo)
Authenticated


timeout

public MpnsServiceBuilder timeout(int timeout)
Sets the timeout for the connection

Parameters:
timeout - the time out period in millis
Returns:
this

delegate

public MpnsServiceBuilder delegate(MpnsDelegate delegate)

build

public MpnsService build()
Returns a fully initialized instance of MpnsService, according to the requested settings.

Returns:
a new instance of MpnsService


Copyright © 2015. All Rights Reserved.