Cloud is a shift from the focus on underlying technology implementation to leveraging existing implementations and further building upon them. Cloud orchestration or a network of clouds is the wave of the future where these clouds can operate with elasticity, scalability, and efficiency. Effective service management is an important aspect of managing such networks. The transition to the cloud will enable the further aggregation of composite web services and enhanced business-to-business capabili...| By Jason R Briggs | Article Rating: |
|
| September 1, 2001 12:00 AM EDT | Reads: |
16,206 |
In Parts 1 and 2 of this series, we covered the basic features of the various MIDP APIs. We looked at creating and packaging a MIDlet, creating a user interface, and some basic graphics operations. We also discovered how to store data with the record management system and how to communicate over the network.
This time around, we're going to talk about MIDP in the enterprise sense (which has nothing to do with "Star Trek"), and put together a basic example that shows how a MIDlet fits into the big picture.
As mentioned before, and it bears repeating, a J2ME developer will undoubtedly not be spending all of his or her time developing on the client side. J2ME applications, particularly MIDlets, will involve a degree of interaction with the server - and unless you're working on an exceptionally large system with a very big team, it seems likely you'll be the developer with "fingers in many pies."
What does that mean exactly? To put it in the simplest terms possible: if you've been neglecting your J2EE and J2SE education in favor of Micro Edition, now's the time to dig out those dusty textbooks and old copies of JDJ and do some serious reading.
Client to Server Communications
In standard Java, there are a number of ways a client-side application can communicate with another machine. We have everything from raw socket connections where you have to pretty much write your own communications protocols yourself, up to Remote Method Invocation (RMI) from one VM to another, on the same or a different host. On MIDP, however, we're reduced to the basics of network communications (for an introduction to networking in MIDP, see my previous article, in JDJ (Vol. 6, issue 8) - where HTTP will probably be the most common methodology.
Typically we'll see the following configurations for basic enterprise MIDP applications: a servlet talking directly to the database (as shown in Figure 1)or a servlet talking to an application server that talks to the database (or in some cases, with no database at all) as seen in Figure 2.
Configurations aside, there should be a layer between the MIDlet and the enterprise data, however it's held, to preserve a level of abstraction. For example, an HTML-based interface may view hundreds of rows of data at any one time, whereas a MIDlet may want to view only 10 or 20. Assuming that the enterprise layer has already been written, there may be no real point in adding yet another method to an EJB, just to retrieve 10 rows at a time from the database for a new MIDlet application - rather than retrieving the entire data set. Instead, write a servlet "interface" to the EJB that loads the data into the client's session and then the MIDlet may call the servlet any number of times to get subsets of required data.
The Example So Far
As it stands, last month's example MIDlet - the PhoneBook application - is fairly simple. You can list the contents of the phone book and add or remove contacts. If you remove the MIDlet suite from the phone, however, the contents of your phone book are lost.
To fix this problem, we need a repository - somewhere to put the data. One possibility here is to store the data in a directory server and access it directly in a servlet, which can expose simple methods for the MIDlet (or any other interface) to access the data. Another option is a database, with an EJB to handle data access. Again a servlet becomes a middleman between MIDlet and EJB/Database.
Rather than go through the rigmarole of setting up a database, the EJB used in this month's example writes its state out to a text file, and I've used the Java 2 Enterprise Edition SDK as the EJB container. Please note, to use the EJB, you'll have to set File-Write permissions in the policy file for the AppServer (server.policy, located in the j2sdkee/ lib/security directory), which is a quick and dirty cludge I've used in this case, but wouldn't recommend in an actual system.
Note: Look for default permissions in the policy file and change the line:
permission java.io.FilePermission "*", "read";to
permission java.io.FilePermission "*", "read,write";Listing 1 shows the "guts" of the PhoneEJB (a stateful session bean). There are five implemented methods: ejbCreate, ejbRemove, add, remove and getPhoneBook.
- ejbCreate: Called when the EJB is created, and takes one parameter - user. It loads names and phone numbers from a data file of the same name (if it exists), and stores the information in a map.
- ejbRemove: Called at the end of the EJB life cycle, at which point the bean can be garbage collected. In this case, the method writes the data out into a data file using the user details.
- Add: Takes a name and phone number as string parameters and saves these into the map.
- Remove: Takes a name as a string parameter and removes the matching record from the map.
- getPhoneBook: Returns the map to the caller.
Lines 1-6 instantiate an instance of the Phone EJB.
Line 8 retrieves the "action" parameter from the servlet request.
If no action has been specified, we assume that the caller wants to retrieve the data, so lines 9-21 call the getPhoneBook method on the EJB, to return the map and then iterate through the keys in the map, writing the name and phone number to the servlet output stream, with one record per line.
If "add" has been specified as the action, lines 22-32 get the name and phone number parameters from the servlet request, check to make sure they're not null, and then call the add method on the EJB.
If "remove" has been specified as the action, lines 33-42 get the name parameter from the request, check that it's not null, and then call the remove method on the EJB to remove the associated record.
In both cases, the servlet writes out an empty line if it succeeds, or an error message beginning with "%ERROR" if an unrecognized action is sent.
(Note: For my testing purposes I've used Apache's Tomcat servlet container.)
MIDlet Revisited
We now need to add functionality to the PhoneBook MIDlet to access the servlet. Listing 3 shows the first of the new functionality - the initRecordStore method. This method calls the servlet using the URL:
http://localhost:8080/servlet/TestPhoneServletYou'll recall from the servlet code, if you pass no parameters in this manner, then a list of records is returned by the servlet. If no errors occurred (a return of "%ERROR" from the servlet indicates something went awry), then the current contents of the record store are deleted and replaced with this list.
To add each record to the store, the initRecordStore method calls save (implemented in last month's installment). Note that the save method has also been modified to take a Boolean parameter (sendToServer), which indicates whether the data should be saved to the server in addition to the record store. As we're initializing the record store, we don't want to save it to the server.
Listing 4 shows the changes to the save and erase methods. The main difference in these is that the send-to-server functionality has been implemented to ensure that any changes made at the client level are mirrored on the server.
Missing from This Version
Apart from a few more supporting methods and some minor changes, the MIDlet is essentially the same. Of course, the example is hardly what you would call an "enterprise application." It does demonstrate that adding this sort of capability to a MIDP application is fairly straightforward. If we were to extend this MIDlet into part of an enterprise Personal Information Manager suite (for example), then we might want to add more validation and include more data in the phone book (mobile number, fax number, e-mail address, etc).
One "buglet" in the current app is that duplicates are allowable in the client, but in the EJB they'll be overwritten (since the data is stored in a map and keyed on name, the phone number is overwritten in the case of a duplicate). Either we could store the information differently in the EJB, or disallow duplicates in the MIDlet.
Where to Go from Here?
Even if you're a seasoned embedded/mobile systems developer, J2ME (or in this case, MIDP) introduces new variables into what may have been, up until now, a fairly straightforward equation. Java's strong networking support means your enterprise application may be split across multiple platforms (client and multiple server tiers), in a way it might not have been with traditional development methods and languages.
Parts 1-3 introduced ways you might go about using the various MIDP packages. Of course, this doesn't help when you're actually trying to decide how your application should be distributed across your architecture. In the end, there's no substitute for good old hands-on experience - trying out small projects for yourself. Good luck, and let the MIDP production line roll!
Published September 1, 2001 Reads 16,206
Copyright © 2001 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Jason R Briggs
As well as being a contributing editor for Java Developers Journal, Jason R Briggs is a Java programmer and Development Manager for a wireless technology company, based in Auckland, New Zealand.
Cloud is a shift from the focus on underlying technology implementation to leveraging existing implementations and further building upon them. Cloud orchestration or a network of clouds is the wave of the future where these clouds can operate with elasticity, scalability, and efficiency. Effective service management is an important aspect of managing such networks. The transition to the cloud will enable the further aggregation of composite web services and enhanced business-to-business capabili...Feb. 18, 2012 11:00 AM EST Reads: 537 |
By Pat Romanski The focus of Java EE 7 is on the cloud, and specifically it aims to bring Platform-as-a-Service providers and application developers together so that portable applications can be deployed on any cloud infrastructure and reap all its benefits in terms of scalability, elasticity, multitenancy, etc. The existing specifications in the platform such as JPA, Servlets, EJB, and others will be updated to meet these requirements.
Java EE 7 continues the ease of development push that characterized prior ...Feb. 18, 2012 10:45 AM EST Reads: 2,257 |
By Jeremy Geelan With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
We have technical and strategy sessions for you every day from June 11 through June 14 dealing with every nook and cranny of Cloud Computing and Big Data, but what of those who are presenting? Who are they, where do they work, what else h...Feb. 18, 2012 08:30 AM EST Reads: 592 |
By Liz McMillan Wide and cheap availability of cloud-based media services is upon us. With the transformations these services are already bringing to the consumption of music, video and interactive media, change has likewise come to professional workflows. Documents in 2012 are read, written, collaborated on, and distributed anywhere an Internet-enabled device can reach – which is to say, everywhere.
In his session at the 10th International Cloud Expo, Christopher Kenneally, Director of Business Development a...Feb. 17, 2012 02:00 PM EST Reads: 538 |
By Kevin Jackson From the NRO Press Release: "Considered one of the top women leaders in Federal IT, Ms. Singer was recognized for her innova... Feb. 17, 2012 07:00 AM EST Reads: 528 |
By Brian McCallion I've been working on Enterprise Cloud Strategy and in the course of this work identified some interesting and non-obvious opportunities in the Cloud.
One solution I’ve examined is the well-crafted solution that is enStratus. enStratus has built a SaaS Cloud Management / Governance product focused on providing critical management, monitoring, governance capabilities tailored to the needs of the Global 2000 market, rather than the startup market. As I have worked with a current Fortune 500 clie...Feb. 17, 2012 07:00 AM EST Reads: 3,679 |
By Jeremy Geelan With Cloud Expo 2012 New York (10th Cloud Expo) now under four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
We have technical and strategy sessions for you every day from June 11 through June 14 dealing with every nook and cranny of Cloud Computing and Big Data, but what of those who are presenting? Who are they, where do they work, what e...Feb. 16, 2012 07:30 AM EST Reads: 936 |
By Pat Romanski 2011 was a year of rapid adoption for public and private cloud services. Instant and on-demand server provisioning was the driving force behind the massive growth. On top, cloud server templates and script automation simplified application installation for simple and pre-defined application stacks, but have not targeted more complex enterprise application environments.
In his session at the 10th International Cloud Expo, John Yung, CEO of Appcara, will discuss how 2012 will be the year for app...Feb. 16, 2012 06:30 AM EST Reads: 2,044 |
By Jeremy Geelan "Having been in the IT field for many years, I believe the cloud computing chapter in the industry is an exciting one and I am proud to be a part of it," said National Reconaissance Office (NRO) Chief Information Officer Jill T. Singer Tuesday, as it was announced that she was one of 10 winners of the 2012 CloudNOW "Top Ten Women in Cloud" Awards.Feb. 16, 2012 06:30 AM EST Reads: 609 |
By Liz McMillan As more enterprises are adopting clouds, the nature of cloud computing is changing. Previously, clouds were used to test applications or for non-mission critical applications. Today, enterprises are using clouds for cost-saving advantages and launching more mission critical applications that have defined performance needs.
In his session at the 10th International Cloud Expo, Eric Shepcaro, CEO and Chairman of the Board of Telx, will discuss how distributed computing has many advantages. It wou...Feb. 16, 2012 05:45 AM EST Reads: 1,851 |
- How Are You Building Your Cloud?
- Cloud Expo New York Speaker Profile: Dave Asprey – Trend Micro
- Big Data in Telecom: The Need for Analytics
- Big Data Gold Mine in Cloud Governance and Automation
- Drool, Britannia? Is the UK Failing the Cloud?
- Cloud Expo New York Speaker Profile: Mårten Mickos – Eucalyptus Systems
- Thoughts on Big Data and Data Virtualization
- Cloud Expo New York Speaker Profile: Bernard Golden – HyperStratus
- What Motivates Open Standards in the Cloud?
- What to Expect in 2012: Cloud Computing and Open Source Software
- Will PaaS Finally Bring Open Source Love to the Enterprise?
- Australia's Lunatic NBN OK for Cloud (Update)
- The Future of Cloud Computing: Industry Predictions for 2012
- HP Puts Activist Shareholder on Board
- Gartner Hype Cycle for Emerging Technologies 2011
- How Are You Building Your Cloud?
- Cloud Expo New York Speaker Profile: Dave Asprey – Trend Micro
- Big Data in Telecom: The Need for Analytics
- i-Technology in 2012: Five Industry Predictions
- Big Data Gold Mine in Cloud Governance and Automation
- 9th International Cloud Expo | Cloud Expo Silicon Valley – Photo Album
- Drool, Britannia? Is the UK Failing the Cloud?
- Microsoft Tries Hadoop on Azure
- Cloud Expo New York Speaker Profile: Mårten Mickos – Eucalyptus Systems
- What is Cloud Computing?
- The Top 150 Players in Cloud Computing
- Six Benefits of Cloud Computing
- Virtualization Conference Keynote Webcast Live on SYS-CON.TV
- What's the Difference Between Cloud Computing and SaaS?
- GDS International: Global Warming Scam?
- Twenty-One Experts Define Cloud Computing
- The Future of Cloud Computing
- The Top 250 Players in the Cloud Computing Ecosystem
- SOA 2 Point Oh No!
- Cloud Expo Europe 2009 in Prague: Themes & Topics
- A Brief History of Cloud Computing: Is the Cloud There Yet?








The focus of Java EE 7 is on the cloud, and specifically it aims to bring Platform-as-a-Service providers and application developers together so that portable applications can be deployed on any cloud infrastructure and reap all its benefits in terms of scalability, elasticity, multitenancy, etc. The existing specifications in the platform such as JPA, Servlets, EJB, and others will be updated to meet these requirements.
Java EE 7 continues the ease of development push that characterized prior ...
With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
We have technical and strategy sessions for you every day from June 11 through June 14 dealing with every nook and cranny of Cloud Computing and Big Data, but what of those who are presenting? Who are they, where do they work, what else h...
Wide and cheap availability of cloud-based media services is upon us. With the transformations these services are already bringing to the consumption of music, video and interactive media, change has likewise come to professional workflows. Documents in 2012 are read, written, collaborated on, and distributed anywhere an Internet-enabled device can reach – which is to say, everywhere.
In his session at the 10th International Cloud Expo, Christopher Kenneally, Director of Business Development a...
I've been working on Enterprise Cloud Strategy and in the course of this work identified some interesting and non-obvious opportunities in the Cloud.
One solution I’ve examined is the well-crafted solution that is enStratus. enStratus has built a SaaS Cloud Management / Governance product focused on providing critical management, monitoring, governance capabilities tailored to the needs of the Global 2000 market, rather than the startup market. As I have worked with a current Fortune 500 clie...
With Cloud Expo 2012 New York (10th Cloud Expo) now under four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference...
We have technical and strategy sessions for you every day from June 11 through June 14 dealing with every nook and cranny of Cloud Computing and Big Data, but what of those who are presenting? Who are they, where do they work, what e...
2011 was a year of rapid adoption for public and private cloud services. Instant and on-demand server provisioning was the driving force behind the massive growth. On top, cloud server templates and script automation simplified application installation for simple and pre-defined application stacks, but have not targeted more complex enterprise application environments.
In his session at the 10th International Cloud Expo, John Yung, CEO of Appcara, will discuss how 2012 will be the year for app...
"Having been in the IT field for many years, I believe the cloud computing chapter in the industry is an exciting one and I am proud to be a part of it," said National Reconaissance Office (NRO) Chief Information Officer Jill T. Singer Tuesday, as it was announced that she was one of 10 winners of the 2012 CloudNOW "Top Ten Women in Cloud" Awards.
As more enterprises are adopting clouds, the nature of cloud computing is changing. Previously, clouds were used to test applications or for non-mission critical applications. Today, enterprises are using clouds for cost-saving advantages and launching more mission critical applications that have defined performance needs.
In his session at the 10th International Cloud Expo, Eric Shepcaro, CEO and Chairman of the Board of Telx, will discuss how distributed computing has many advantages. It wou...
Is Big Data destined for only the top 3,000 companies worldwide? What about medium or small companies who are equally as data-driven? Is there a place for Big Data in SMB markets? When I talk to SMB companies about their use of public cloud services, it’s a no-brainer. Pay as you go, lower costs up...
Last summer a CIO for a high profile ecommerce company told me that the smartest way to play the cloud was to rent the spike. I just read the same thing from Zynga’s Infrastructure CTO Allan Leinwand in Inside Zynga’s Big Move To Private Cloud by InformationWeek’s Charles Babcock.
We have previously provided a Quickstart guide to standing up Rackspace cloud servers (and have one for Amazon servers as well). These are very low cost ways of building reliable, production ready capabilities for enterprise use (commercial and government).
Israel-based startup Porticor launches this week with technology aimed at giving enterprises a way to encrypt data held in cloud computing services, including those from Amazon and Rackspace.
Porticor Virtual Private Data is focused on protecting data at rest in cloud-based computing centers where ...
If you are running the BIG-IP Edge Client on your iPhone, iPod or iPad, you may have gotten an AppStore alert for an update. If not, I just wanted to let you know that version 1.0.3 of the iOS Edge Client is available at the AppStore.
The main updates in v1.0.3:
URI scheme enhancement allows passi...
Statistics matter, not only in business, but increasingly also in our social life - well, at least in our social media life. Some of the statistics I noticed this week were round numbers, like 1000. With 1000 representing both the number now showing under "followers" in Twitter and the revenue numbe...
Let's face it right now the cloud is pretty immature. The level of automation and management of these environments are analogous to the early assembly lines, but it won't be this way long. This is not the industrial revolution and it moves at a wicked fast pace. Before we know it the next generation...
In previous posts such as Cloud Computing: Hype, Vision or Reality?, Hyped Cloud Technologies, PAAS is not Mainstream yet, SaaS is going Mainstream, Future applications: SaaS or traditional? I discussed Cloud Computing.
Recently I read Joe McKendrick's interesting article titled:Cloud Computing Mar...
Having covered Cloud Foundry, Force.com, Google App Engine and Red Hat OpenShift, we now take a look at Microsoft’s PaaS offering, Windows Azure.
Microsoft Windows Azure Platform is a Platform as a Service offering from Microsoft. It was announced in 2008 and became available in 2010. Since then Mi...










