oracle.panama.messaging.push
Class Push

java.lang.Object
  |
  +--oracle.panama.messaging.push.Push

public class Push
extends java.lang.Object

A client of Push Server, which sends out messages to Push Server and queries delivery status from Push Server.
Push Server may be configured in two ways:
1. Public Push gateway: Push gateway provides messaging services to Internet/intranet users. The communication between Push client and Push gateway is powered by SOAP technology. Push client must have the URL of Push gateway. It must provide a valid username/password combination to get services, if the gateway asks so.
For example: Push myPushClient = new Push("http://messenger.oracle.com/push/webservices", "user","passwd");
2. Private Local Push Server: Push client and Push server are running on the same machine. Push client calls Push server class through java methods call directly without using SOAP or RPC. No SOAP gateway or authentication is needed for local installation. Push Server provides services to that Push client only. When constructing Push client for local Push server, pass 'null' as Push messaging gateway URL in the constructor. Access to Push Server is granted to local Push client automatically. It's a good idea to provide a user name for logging and reporting purpose, though it's not required.
For example: Push myPushClient = new Push(null, "user",null);
All APIs are identical for local and SOAP Push gateway. The following example sends out 'hello world' message to two email recipients and one SMS recipient.

     // Email recipients
   	AddressData emailRecipients[] = new AddressData[2];
   	emailRecipients[0] = new EmailAddressData("john@company.com","to");
   	emailRecipients[1] = new EmailAddressData("mary@company.com","cc");

   	// SMS recipient
   	AddressData smsRecipients[] = new AddressData[1];
   	smsRecipients[0] = new PhoneAddressData("1-333-5551234");
   	// Packet object
   	Packet pkt = new Packet();

   	AddressData emailSender = new EmailAddressData("sender@company.com");
   	AddressData smsSender = new PhoneAddressData("1-222-1234567");

   	pkt.setFrom(TransportType.EMAIL, emailSender);
   	pkt.setFrom(TransportType.SMS, smsSender);

   	pkt.addRecipients(TransportType.EMAIL, emailRecipients);
   	pkt.addRecipients(TransportType.SMS, smsRecipients);

   	Message msg = new Message();
   	msg.setContent("Hello World!");   // message body
   	msg.setContentType("text/plain");
   	msg.setSubject("Hello");    // subject

   	pkt.setMessage(msg);

  	String gatewayURL = "http://messenger.oracle.com/push/webservices";

     // create a push client instance
   	Push push = null;
   	try{
   	  push = new Push(gatewayURL,"user name","password");
   	}
   	catch(PushException e) { e.printStackTrace();}

  	WorkOrder wo[] = null;
  	try
  	{
      // send message packet to the server
   		wo = push.send(pkt);
  	}
  	catch(PushException e)
  	{
    		System.out.println("**** PushException caught ");
    		e.printStackTrace();
  	}

  	if(wo != null)
  	{
     		for(int i=0;i< wo.length;i++)
      		System.out.println(wo[i]);

        // get sending statuses
     		Status status[] = null;
     		try {
     		  status = push.getStatus(wo);
     		} catch(PushException e) { e.printStackTrace(); }

    		if(status != null)
    		{
      		for(int i=0;i< status.length;i++)
        			System.out.println(status[i]);
    		}
  	}
  

Note:
Failover is not implemented in this release.

See Also:
PushLite

Constructor Summary
Push(java.lang.String messagingGatewayURL, java.lang.String username, java.lang.String password)
          Construct a new Push client instance for an OracleMobile SOAP Messaging push gateway or local Push Server.
 
Method Summary
TypeMethod
 Status getStatus(WorkOrder workOrder)
          Get current status of a work order.
 Status[] getStatus(WorkOrder[] workOrders)
          Get current status of a set of work orders.
 java.lang.String[] getSupportedTransports()
          Get names of available transport types from Push server.
 java.lang.String getVersion()
          Get version of Push API.
 void removeStatusListener()
          Unregister the status listener if any is registered.
 WorkOrder[] send(Packet pkt)
          Send out message.
 void setProxy(java.lang.String host, int port)
          If Push client machine is inside firewall and Push Server is outside firewall, user may need to tell Push client his/her HTTP proxy settings.
 void setStatusListener(StatusListener listener)
          Set status listener of this Push.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Push

public Push(java.lang.String messagingGatewayURL,
            java.lang.String username,
            java.lang.String password)
     throws PushException
Construct a new Push client instance for an OracleMobile SOAP Messaging push gateway or local Push Server.
Parameters:
messagingGatewayURL - Complete URL of OracleMobile Push messaging gateway(SOAP). For example: "http://messenger.oracle.com/push/webservices"
null for local Push server.
username - username of OracleMobile messaging gateway or local Push Server. null if no username is needed.
password - password of OracleMobile messaging gateway. null if no password is needed.
Method Detail

setProxy

public void setProxy(java.lang.String host,
                     int port)
If Push client machine is inside firewall and Push Server is outside firewall, user may need to tell Push client his/her HTTP proxy settings.
DO NOT set proxy if:
- Push server is on Internet and Push client machine connects to internet directly
- they both on the same intranet
- local installation
Parameters:
host - host name of proxy For example: proxy.company.com
port - port number of the proxy. For example: 80

send

public WorkOrder[] send(Packet pkt)
                 throws PushException
Send out message.
Parameters:
pkt - The message packet to be delivered.
Returns:
a set of WorkOrders will be returned after Push server accepts the request. One WorkOrder for each instance of recipient's address. The order of WorkOrders may be NOT the same as the order of recipients being added into the Packet by calling Packet.addRecipients().

getSupportedTransports

public java.lang.String[] getSupportedTransports()
                                          throws PushException
Get names of available transport types from Push server. Use this method to get transport types the Push server supports currently. For example: if the return values are: "SMS","email". You may only send out SMS and email messages through this gateway.

getStatus

public Status getStatus(WorkOrder workOrder)
                 throws PushException
Get current status of a work order. One work order has one address and the message ID of that address.

getStatus

public Status[] getStatus(WorkOrder[] workOrders)
                   throws PushException
Get current status of a set of work orders.

getVersion

public java.lang.String getVersion()
Get version of Push API.

setStatusListener

public void setStatusListener(StatusListener listener)
Set status listener of this Push.
(This feature is not implemented in this release.)
Parameters:
listener - the status listener.

removeStatusListener

public void removeStatusListener()
Unregister the status listener if any is registered.
(This feature is not implemented in this release.)