com.notnoop.mpns.internal
Class AbstractMpnsService

java.lang.Object
  extended by com.notnoop.mpns.internal.AbstractMpnsService
All Implemented Interfaces:
MpnsService
Direct Known Subclasses:
MpnsPooledService, MpnsQueuedService, MpnsServiceImpl

public abstract class AbstractMpnsService
extends Object
implements MpnsService


Constructor Summary
AbstractMpnsService()
           
 
Method Summary
protected  String getSubscriptionUri(org.apache.http.client.methods.HttpPost request)
           
protected  org.apache.http.client.methods.HttpPost postMessage(String subscriptionUri, byte[] requestBody, Collection<? extends Map.Entry<String,String>> headers)
           
protected abstract  void push(org.apache.http.client.methods.HttpPost request, MpnsNotification message)
           
 void push(String subscriptionUri, MpnsNotification message)
          Sends the provided notification message to the desired destination.
 void push(String subscriptionUri, String payload, Collection<? extends Map.Entry<String,String>> headers)
          Sends a push notification with the provided payload to the iPhone of deviceToken.
 void start()
          Starts the service.
 void stop()
          Stops the service and frees any allocated resources it created for this service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMpnsService

public AbstractMpnsService()
Method Detail

postMessage

protected org.apache.http.client.methods.HttpPost postMessage(String subscriptionUri,
                                                              byte[] requestBody,
                                                              Collection<? extends Map.Entry<String,String>> headers)

push

protected abstract void push(org.apache.http.client.methods.HttpPost request,
                             MpnsNotification message)

push

public void push(String subscriptionUri,
                 String payload,
                 Collection<? extends Map.Entry<String,String>> headers)
          throws NetworkIOException
Description copied from interface: MpnsService
Sends a push notification with the provided payload to the iPhone of deviceToken. The payload needs to be a valid JSON object, otherwise it may fail silently. It is recommended to use PayloadBuilder to create one.

Specified by:
push in interface MpnsService
payload - The payload message
Throws:
NetworkIOException - if a network error occured while attempting to send the message

push

public void push(String subscriptionUri,
                 MpnsNotification message)
          throws NetworkIOException
Description copied from interface: MpnsService
Sends the provided notification message to the desired destination.

Specified by:
push in interface MpnsService
Throws:
NetworkIOException - if a network error occured while attempting to send the message

getSubscriptionUri

protected String getSubscriptionUri(org.apache.http.client.methods.HttpPost request)

start

public void start()
Description copied from interface: MpnsService
Starts the service. The underlying implementation may prepare its connections or datastructures to be able to send the messages. This method is a blocking call, even if the service represents a Non-blocking push service. Once the service is returned, it is ready to accept push requests.

Specified by:
start in interface MpnsService

stop

public void stop()
Description copied from interface: MpnsService
Stops the service and frees any allocated resources it created for this service. The underlying implementation should close all connections it created, and possibly stop any threads as well.

Specified by:
stop in interface MpnsService


Copyright © 2015. All Rights Reserved.