|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Ryan Shoemaker's Blog
Developing MEP Client Applications - Part 1Posted by ryan_shoemaker on August 20, 2008 at 08:25 AM | Permalink | Comments (0)In my previous post, we took a closer look at the MCBO API and all of its features. Now it is time to show how to use the APIs to develop an MEP client application. In Part 1, we will focus on the fundamentals of the API: creating a SyncManager, initiating a sync, and examining the sync results. In part 2, we will study the security features provided in the client API.
MusicDB Sample AppWe'll be examining the MCBO API within the context of the "MusicDB" sample app that ships with MEP v1.0. This sample client is able to synchronize basic music album data with a JDBC back-end. For more information about how the MEP connector was developed for this sample app, please follow Santiago's blog about using the ECBO API to develop MEP connectors. The source code for the MusicDB client application is available for download in the MEP client bundle.
Data ModelOne of MEP's strongest features is that it is completely agnostic about your data model. As long as you can figure out how to serialize your BusinessObjects, MEP will be able to sync the data with the MEP gateway server. In the case of the MusicDB sample app, we are sending some very basic album data back and forth to the JDBC back-end: album name, artist name, date, and rating. Let's take a look at how to implement a BusinessObject to manage this data model.
Implementing A BusinessObjectThere are only a few steps required to implement your business object:
The class definition and bean properties look like this:
Each business object must have a unique name which is stored in the 'name' field of the BusinessObject base-class. Since the business objects are stored on the mobile device's filesystem, there is a restriction that the name must be a unique identifier that can be used as a file name. In order to differentiate between different kinds of business objects, you must also assign a unique extension. For the "Album" business object type, we've choosen ".alb" by implementing the getExtension() method like this:
The combination of the unique name of each instance of Album and the extension will determine the name of the object stored on the mobile device's filesystem. Implementing the getters and setters for the bean properties is as simple as:
The business object's name field is immutable - once you set the object's name, you can not change it. All business objects must provide the ability to serialize and deserialized to a byte array. The actual format used for serialization is open ended, but must be part of the contract between the connector and the mobile client application. For music albums, serialization is implemented using DataOutputStream and DataInputStream:
You can see that there is a special token 'DEFAULT_VALUE' which is used to determine when Album fields are not set. There is also some helper code for parsing the date format. Reading and Writing Business ObjectsIn order to store and retrieve instances of your business objects on the mobile device, you must use the BusinessObjectStorage class. It provides some high-level APIs to read, write, enumerate, and delete business object instances.In the MusicDB sample, business objects are read like this: and written like this:
SyncManagerSyncManager is responsible for mangining the synchronization of a particular class of business objects with the MEP gateway server. There is a 1:1 relationship between instances of SyncManager and classes of business objects. In the case of MusicDB, we only have one kind of business object - Album (*.alb). To create the SyncManager, you simply construct it and specify the business object extension. SyncManager also serves as a factory for BusinessObjectStorage and it also manages the MEP gateway server address and sync credentials:
Performing a SynchronizationWhen you're ready to perform a synchronization, all you have to do is call the sync method on SyncManager and tell it which kind of synchronization to perform. The different kinds of sync types are available in an enum called SyncType. Initiating a fast sync would look like this:
Looking at the SyncResultsAssuming the call to sync returns without throwing an exception, you can now examine the sync results which are contained in an instance of SyncResults and draw them on the UI:That wraps up all of the basic functionality provided in the MCBO API. In the next entry, we will take a closer look at all of the security features available in the API. Stay tuned... A Closer Look at the MCBO APIPosted by ryan_shoemaker on July 24, 2008 at 10:39 AM | Permalink | Comments (0)I briefly introduced the MEP client architecture in my previous post. In this post, we will take a closer look at the client architecture and use it as a foundation for the next few blog entries that will focus on the details of the programming model. 30,000ft ViewThe MEP client SDK, also known as the "Mobile Client Business Object API" or MCBO, is simply a Java ME library that enables bi-directional synchronization of arbitrary data types with the MEP gateway server. The client and gateway perform these synchronizations using the industry standard OMA DS (SyncML) protocol. Application developers can add MCBO to their mobile applications to enable synchronizations with corporate back-end EIS systems (such as Siebel, SAP, or JDBC accessible databases). The following diagram shows an overview of the entire MEP architecture. The top left area shows the main components on the mobile client. The MCBO API is responsible for managing enterprise data stored locally on the device's filesystem (via JSR-75 FileConnection) as well as performing synchronizations with the MEP gateway server (Santiago will be covering the MEP gateway server architecture in more detail).
Device AgnosticIn order to support as many Java enabled mobile devices as possible, MCBO has very minimal requirements: MIDP 2.0 / CLDC 1.1 or CDC 1.1.2. The only other requirement is JSR-75 support for access to the device's filesystem which enables MCBO to provide off-line access to enterprise data stored on the device. That's it! MCBO can take advantage of JSR-120 enabled devices to provide server initiated features via WMA (to be discussed in future blog entries). The following architecture stack shows the relationship between the application code, MCBO, and the underlying Java ME requirements.
SecurityMCBO was designed with security in mind and provides a number of first-class features. Application developers can choose any, all, or none of these features to tune their application with the necessary levels of security:
A Closer Look at the MCBO APIAs I stated earlier, the MCBO api is simply a Java ME library that allows bi-directional synchronizations of arbitrary (user-defined) data types with corporate back-end systems. There are four core concepts behind the MCBO API: BusinessObject, BusinessObjectStorage, SyncManager, and SecurityManager. I'm only going to provide an overview of these classes for now - we will be examining each of these in great detail in subsequent postings. BusinessObject - the "BO" in MCBOA business object is just a POJO that defines the data model and serialized form of the corporate data being synchronized. It will typically be derived from the schema of the back-end data store. The serialized form is used to read and write the data to the device's local filesystem. It can be as simple or sophisticated as you like - CSV, XML, etc. BusinessObjectStorageThis class manages the local cache of business objects stored on the mobile device. It provides the application layer methods to read, write, delete, and enumerate business objects using the serialization methods provided by your business object. You can think of it as a simple data store. SyncManagerThe SyncManager is responsible for authenticating with the MEP gateway server and controlling the actual synchronization process. There are six different kinds of synchronizations that can be performed which are defined in an enum type named SyncType. It also provides access to coarse-grained stats about the last synchronization. SecurityManagerThe SecurityManager is responsible for providing all of the security features described above. MCBO ships with a default implementation based on 3DES, but you can use your own security manager based on whatever security standards you like. Client Application DevelopmentApplication developers are free to choose whatever development environment they like, but I will be using NetBeans 6.1 to develop the sample app in subsequent postings. NetBeans has a Mobility Pack that fully integrates with the Java ME Wireless Toolkit. Using these two platforms together makes it very easy to quickly build deploy and test mobile apps. Since MCBO is just a synchronization library, developers can use their favorite UI toolkit: LCDUI, LWUIT, SVG, etc. Light Weight - 150kThe raw unoptimized MCBO API jar is about 1.6M. The encryption library bundled with MCBO accounts for over 1M of the 1.6M, but once the library is optimized and obfuscated, MCBO is only about 150k !!!!! The size of complete applications will vary depending on the size and quantity of resources such as graphics and images, but a very basic LCDUI based MIDP 2.0 app with all security features enabled will typically fall into the 190k size range after optimization and obfuscation. DocumentationYou can find much more detailed information in the MEP 1.0 Developer Guide for Client Applications.
JavaOne 08 MEP Slides AvailablePosted by ryan_shoemaker on July 17, 2008 at 06:26 AM | Permalink | Comments (0)The JavaOne 2008 MEP slides provide a very good technical overview of the platform and its many features - Take a look! Unfortunately, the session wasn't recorded, so there's no audio or video to accompany the slides. The presentation covers the platform's features and overall architecture including the client and connector programming models, security model, provisioning, and much more. During the presentation, we had a live demo on stage of a secure client (running on a BlackBerry 8830 and a Palm Treo 700P) that performed synchronizations through our mobile carrier's network, over the internet, and through Sun's firewall to a MySQL database running in Colorado. Sun Java System Mobile Enterprise Platform 1.0 is Available!Posted by ryan_shoemaker on July 15, 2008 at 12:08 PM | Permalink | Comments (5)I've spent the last year working on a new product at Sun called the Mobile Enterprise Platform (MEP), which enables mobile access to enterprise data. Using MEP, you can easily develop mobile applications capable of synchronizing data between Java enabled mobile devices and corporate back-end EIS systems such as Siebel and SAP or traditional relational JDBC databases. The platform is built upon proven open standards such as OMA DS (SyncML), Java ME (MIDP 2.0 / CLDC 1.1 / CDC 1.1.2), and Java EE and runs on Sun's GlassFish Open Source Application Server. We announced our beta at JavaOne 08 and I'm pleased to say that the 1.0 release is now available! Please take a minute to read our official MEP product announcement - it contains a very nice overview of the platform and all of its features. You can also jump directly to the MEP product page and download it now! We are just beginning a series of blogs covering all of the features of MEP in great detail. Since Santiago has already provided some detail about the powerful deployment options of MEP, I'll give you a taste of what the mobile client SDK looks like. The Java ME client SDK is a 100% Java library that allows bi-directional synchronization of data with the MEP gateway. It is based on MIDP 2.0, CLDC 1.1, CDC 1.1.2, OMA DS 1.1.2/1.2 and has many attractive features including: a pure Java OMA DS implementation, on-device data encryption, authentication, lock-out, data destruction, data fading, and many more. All of these features are exposed to the mobile application developer through an easy-to-use API called the Mobile Client Business Object API (MCBO). A "Business Object" is simply an abstraction of the enterprise data you're dealing with - it might be a Customer, PurchaseOrder, or Product. The following stack diagram shows the architecture of a typical MEP client application.
The MEP team will be posting a series of blogs focusing on specific features of the platform. You can expect to see technical deep-dives on mobile client application development, connector development, installation, administration, provisioning, security, etc. These posts will be aggregated on the Sun Enterprise Mobility Blog, so subscribe now! |
August 2008
Search this blog:CategoriesCommunity: GlassfishCommunity: Java Enterprise Community: Java Web Services and XML Archives
August 2008 Recent EntriesDeveloping MEP Client Applications - Part 1 JavaOne 08 MEP Slides Available | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
|