Java Reference
In-Depth Information
CLDC in general or on Symbian OS specifically. JNI is indeed a powerful
Java SE mechanism that enables desktop applications to jump out of the
Java run-time environment and execute native code but, due to the nature
of mobile platforms, CLDC does not include JNI. (CDC-based platforms
do have JNI support but CDC is out of the scope of this topic.)
You may need to invoke native Symbian OS APIs where the required
functionality is not available on the Java ME platform (e.g., when an MIDP
application requires an SQL database) or the Java API does not have
sufficiently fine-grained control (e.g., extremely fine-grained multimedia
capabilities are not found in JSR-234 AMMS but are available in the native
Multimedia Framework of Symbian OS). It may also be desirable for a
MIDlet to communicate with an application (another MIDlet, a native
Symbian C++ application or an application hosted by another run-time
environment, such as Flash, Python, or Ruby) running in another process.
Symbian OS is a multitasking open platform in which native appli-
cations can be installed and multiple applications can run concurrently.
Therefore, an inter-process communication (IPC) mechanism can be a
solution, if required; for example, you may want to develop a hybrid
mobile application that uses Java ME APIs for the back end and Flash Lite
for the front end.
A possible solution could utilize a very simple concept (see Figure
3.22). Just as MIDlets can communicate over a network protocol with
a remote server or a remote peer, they can communicate with another
application running on the same host using the localhost address.
Both sides then need to agree a common protocol to be used for requests
and responses. Here we present a simple and generic reference design in
order to demonstrate how the concept could be implemented.
Process b oundary
IPC
Clie nt
IPC / TCP
IPC
Cli ent
IPC
Server
Access to native
Symbian OS APIs
Java runtime
Symbian OS
Figure 3.22 Inter-process communication over TCP localhost
First we start with possible code for an IPC client:
private static final int MY_NATIVE_SERVER_PORT = 9876;
private IpcCommand cmd = new IpcCommand(...);
private IpcResponse res = null;
Search WWH ::




Custom Search