PushRegistry
Article Metadata
The push registry enables MIDlets to set themselves up to be launched automatically, by setting an alarm or by sending data over the network. The push registry manages network- and timer-initiated MIDlet activation; that is, it enables an inbound network connection or a timer-based alarm to wake a MIDlet up. For example, you can write a workgroup application that employs network activation to wake up and process newly received email, or new appointments that have been scheduled. Or you can use timer-based activation to schedule your MIDlet to synchronize with a server every so often then go to sleep.
This is a general property of MIDP2.0 specification.But different vendors have implemented it differently. For eg; in Nokia & Sonyericsson phones there a permission message is displayed whether you want to activate the push registered application. Where as in Siemens phones only a star sign will be displayed.
Contents |
The PushRegistry class exposes the following methods:
- getFilter(), to return the <AllowedSender> value for the connection (this can be
a server IP address, a comma-delimited list of IP addresses, or an * to allow any connection).
- getMidlet(), to return the MIDlet name registered for the specified connection.
- listConnections(), to return a list of push connections registered for the specified
MIDlet suite.
- registerAlarm(), to register a timer-based trigger to launch the MIDlet, or to
disable an existing alarm for the MIDlet if the argument supplied is zero.
- registerConnection(), which registers a connection for the MIDlet.
- unregisterConnection(), which likewise unregisters a connection.
Exceptions
The following exceptions should be caught:
- ClassNotFoundException
- ConnectionNotFoundException
- IllegalArgumentException
- IOException
- SecurityException
Using SMS Connections
It is useful to note that a MIDlet can initiate a socket or HTTP connection after it has been awakened by an incoming message, if further exchange of data is required.
The port specified can be from the full range 1 to 65535, however the following ports are reserved and must not be used:
- 2805 WAP WTA secure connectionless session service
- 2923 WAP WTA secure session service
- 2948 WAP Push connectionless session service (client side)
- 2949 WAP Push secure connectionless session service (client side)
- 5502 Service Card Reader
- 5503 Internet access configuration reader
- 5508 Dynamic Menu Control Protocol
- 5511 Message Access Protocol
- 5512 Simple e-mail Notification
- 9200 WAP connectionless session service
- 9201 WAP session service
- 9202 WAP secure connectionless session service
- 9203 WAP secure session service
- 9207 WAP vCal Secure
- 49996 SyncML OTA configuration
- 49999 WAP OTA configuration
Registration
Push Registry can handle requests to register connections in two ways:
- dynamically at run time,
- statically through entries in the JAD file
Dynamic Registration
Dynamic registration is a MIDlet notifying the AMS at run time that it wants to be activated by an incoming network connection or alarm event should the MIDlet be exited prior to that event occurring.
For a connection the registerConnection method is used:
and
this.getClass().getName()
can be used to specify the current MIDlet.
Some of the examples for Dynamic Registration :
registerConnection(“sms://:” + portNumber);
registerConnection(“datagram://:” + portNumber);
Static Registration
If a connections sender and connection type are known when the MIDlet is installed, the registration request can be made at installation, and is therefore regarded as static. Static requests are defined in the JAD file using the Midlet-Push-<n> attribute:
MIDlet-Push-<n>: <ConnectionURL>, <MIDletClassName>,
<AllowedSender>
where n is a sequence number allowing more than one connection to be declared, ConnectionURL is the URL to monitor for an incoming connection, MIDletClassName is the MIDlet to start, and AllowedSender is the filter: a list of IP addresses or * for any.
An example for SMS connection :
MIDlet-Push-1: sms://:10000, TestMIDlet, *
Unregistering the connections
Dynamic registrations can be removed by using unregisterConnection specifying the connection only:
unregisterConnection(“sms://:10000”)
To determine if the MIDlet was invoked by an incoming message:
In startApp():
String connectsFound[];
connectsFound = PushRegistry.listConnections(true);
This returns the list of registered connections.
if connectsFound == null || connectsFound.length == 0)
{
~ started by user, code to exit or bypass push-related activity ~
}
else
~ started by inbound connection so code for push registry initiation ~
}
Sun Resourece:
http://developers.sun.com/mobility/midp/articles/pushreg/
java world resoure: http://www.javaworld.com/javaworld/jw-04-2006/jw-0417-push.html
Sonyericsson resource: http://developer.sonyericsson.com/wportal/devworld/page-not-found?cc=gb&lc=en


29 Sep
2009
This article show very detailed information on Push Registry.Specific details on different vendor approach on push registry is explained well.It explains different methods like exceptions,SMS connections,registration static and dynamic,how to unregister a connection etc is given in detail with Example code on every method.
All the code examples given runs fine without any bugs. The Push Registry subject itself is very unknown to everyone so after reading this article any one get a detail idea on what is push registry and how to use that in application.
30 Sep
2009
This article discussed the Push Registry, an interesting mechanism which Java ME provides for automatically starting midlets. The article explains how the Push Registry can be used to automatically start midlets either by setting an alarm, or by receiving a message or data over the network. The article demonstrates two ways in which midlets can register to be started automatically, namely dynamically and statically. Dynamic registration is done through code, using the registerConnection method of the Push Registry class. The programmer merely has to specific a type of connection (e.g. sms and then a port number). Alternatively, static registration involves a property which is placed in the JAD file of a midlet. The article also shows how to determine whether a MIDlet was started via an incoming message.
This is a useful article on a useful method that Java ME provides for starting midlets automatically. Personally, I made use of the Push Registry previously to start a midlet automatically from a Symbian C++ application, and it worked very nicely. The article does a good job of explaining the relevant concepts. The examples used are relevant and help to explain the concepts nicely. One thing not mentioned in this article is that NetBeans provides a nice facility for adding Push Registry connection registrations in the JAD file. A well written and useful article.