Skip to main content

Getting started with JME - Part III / III

Posted by netomarin on July 24, 2007 at 10:06 AM PDT

Hi all ... I´m back !!! ;-)

Let´s finish this post series with the last (but not less important) element that´s I think is essential on a quality JME application development: Connectivity !

To be or not to be CONNECTED ?!?!

Because today, be connected is more than a simple feature of a mobile application, it´s a requirement! Since from a simple search until the data synchronization with some service available at the big Net. And why not integration with other systems using SOA and webservices ?
And the way to do all this on JME is using the Generic Connection Framework, or simply, GCF. He is the responsible of this magic! Let´s understand how it´s works.

Presenting, GCF !

When I used the connectivity recourse by the first time, I didn´t believe that´s how should be too easy! I just called the same method for any kind of connection, and so start using some specific protocol like HTTP. How can GCF do this ???

First, let´s analyze the follow image to understand GCF structure:

How we can observe, all and ever kind of connection extends Connection, and so it´s easier to Java manipulate the connection. And, if we think about the net structure, we really realize that´s all connections has the same basic operation mode.

The Connector class

By the static calling of the method open() from Connector class, a new connection is opened. The calling is ever the same, and something like this:

...
try {
   Connector.open("protocol:address;parameters");
} catch (ConnectionNotFoundExeption e) {
   // no handler available for socket connections
}
...

And, if the desired protocol it´s already known, it´s just do the cast to your connection type and so use as you want. You can find practical examples of the usage at API:

Low-level Networking Programming

But, if you´ve created your own application protocol or have to do some special data manipulation you can use advanced stuffs like SocketConnection, ServerSocketConnection or UDPDatagramConnection, and so do as you want to.
To better explanation and discuss you should visit the article J2ME Low-Level Network Programming with MIDP 2.0 at http://developers.sun.com/mobility/midp/articles/midp2network/.

What about Bluetooth ?!?!

The Bluetooth usage is increasing day-by-day, including by the mobile phones manufacturer that´s making it available in a large number of models. And, what´s already means a high-level mobile phone status, now is a important "accessory" and have been used in a different kind of applications, like: As a remote control, to replace wires, multi-player games and little (or provisional) WLANs.

But, if we think about the net aspect, we are (yet) inside the GCF. But, why make it complex if we can simplify ? ;-) On this way, the Marge Project comes to help (and a lot) the usage of this (important) technology. It´s a framework to make easy all Bluetooth programming process: since the device and service discovery until the data exchange properly.
It´s a open-source project that you can (and should if it´s possible for you) collaborate, incubated at Mobile and Embedded Community. To examples, downloads, discussion and collaborations visit: https://marge.dev.java.net/

JME surfing on SOA and Webservice wave!

The availablement of services at Internet using the Webservice paradigm and the increased usage of this to system´s integration with SOA, brings to JME the necessity to talk with this technologies.

But... What is SOA and Webservice ?

Well, to don´t loss the focus now, if you have any doubt about the real uses of these technologies, visit:

How to consume Webservices and SOA integration

As the name tells, Webservice is a service available at the Web. So, we could think in use directly a HTTP Connection to access the information, correct?
The problem in this case is all the parse that we will have to do, because SOAP uses XML to data encapsulation. And, if we maybe have to to this on all Webservice communication, why not create a Framework ?!? To this, I´d like to introduce you kSOAP and kXML. The first to integrate with SOA and the second to do the XML parse.
To downloads, documentation and examples, visit:

Finalizing

With this post, it´s the end of "Getting Started with JME" trilogy (with a little late) and now I´m feel that I can go ahead with many subjects that were introduced here and because some feedbacks that´s I´ve received by e-mail.

And, to the end of this week you can wait for a complete post about the usage of Webservices and SOA integration, including some examples and tips that will be present at my session at JustJava 2007 (October, São Paulo-Brazil) !!

Thanks all,
Cya... because, JAVA is everywhere!! ;-)

Neto Marin

Related Topics >>