Enterprise J2ME Developing Mobile Java Applications [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Enterprise J2ME Developing Mobile Java Applications [Electronic resources] - نسخه متنی

Michael Juntao Yuan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



8.6 Corporate Portal Servers


Although smart clients can access email and PIM information directly, clientside solutions have their limitations. Many enterprise systems have sophisticated security policies and filters that limit the direct access or synchronization to their servers. As we had discussed in Chapter 7, Section 7.1.4, corporate portals are necessary for mobile devices to access those restricted environments. Corporate portal products for smart mobile clients, especially for J2ME clients, are still rare. In this section, we introduce the BlackBerry Enterprise Server from Research In Motion (RIM), which allows BlackBerry handheld devices to access corporate Microsoft Exchange and IBM Lotus Domino environments. The BlackBerry Enterprise Server also supports additional logic on mobile management policies and filters. However, we have to note that BlackBerry handheld devices are required to access the enterprise server. We will not discuss details of the server configuration and setup here. Instead, we focus on the BlackBerry proprietary J2ME API (v3.6) on mobile devices.

Note

Sybase iAnywhere's Mail Anywhere Studio is an email and PIM portal for native mobile clients. It provides access to Microsoft Exchange and IBM Lotus Domino environments to Palm OS, PocketPC, and Symbian OS native email and PIM clients.


8.6.1 BlackBerry Email


BlackBerry devices access email through the proprietary BlackBerry Java Development Environment (JDE) MIDP extension API. The BlackBerry server pushes email messages to the device. If the message is big, the server partitions it to multiple parts, each 2KB in size, and pushes only the first part to the device. The BlackBerry MIDP API allows the device to maintain multiple email folders, listen for changes of each folder, send messages, download complete multipart messages, and handle MIME attachments. Listing 8.8 shows the basic usage of the API.

Listing 8.8. The use of the BlackBerry mail API



import net.rim.blackberry.api.mail.*
public class MailDemo implements FolderListener, StoreListener {
private Folder inbox;
public MailDemo () {
Store store = Session.waitForDefaultSession().getStore();
store.addStoreListener(this);
Folder[] folders = store.list(Folder.INBOX);
inbox = folders[0];
inbox.addFolderListener(this);
}
// FolderListener: Called when a new message is pushed in
void messagesAdded(FolderEvent e) {
// process the added messages
}
// FolderListener: called when a message is removed from the folder
void messagesRemoved(FolderEvent e) {
// process the removed message
}
// StoreListener: Called when messages are added and moved
// in batch operation (e.g. during synchronization)
void batchOperation(StoreEvent e) {
// Do something
}
// Receive message number "index" from the inbox
public void receive (int index) throws Exception {
Message[] msgs = inbox.getMessages();
Message msg = msgs[index];
Address[] recipients = msg.getRecipients(Message.RecipientType.TO);
Date sent = msg.getSentDate();
Address from = msg.getFrom();
String subject = msg.getSubject();
Object o = msg.getContent();
if ( o instanceof String ) {
// The message is a simple string
String body = (String)o;
// Do something with the message
} else {
// The message contains a Multipart object
// Download other BodyParts using Transport.more()
// Do something with the message
}
}
public void send () throws Exception {
Message msg = new Message(inbox);
// To address
Address toList[] = new Address[1];
toList[0]= new Address("juntao@enterprisej2me.com", "Michael Yuan");
msg.addRecipients(Message.RecipientType.TO, toList);
Address from = new Address("me@enterprisej2me.com", "Myself");
msg.setFrom(from);
//add the subject
msg.setSubject("Hello world");
//add the body
msg.setContent("This is a test.");
//send the message
Transport.send(msg);
}
}


8.6.2 BlackBerry PIM


The BlackBerry JDE's PIM API is very similar to the J2ME PDA OP's PIM API. It mainly consists of PIMItem and PIMList interfaces (see Table 8.2).

For more information and code examples, please refer to the BlackBerry Web site.

Table 8.2. The BlackBerry PIM API

Interface

Description

PIMItem

It represents an abstract PIM item. Interfaces Contact, Event, and ToDo are derived from the PIMItem interface to represent specific PIM items.

PIMList

It represents a collection of PIMItems. Specific lists are represented by ContactList, EventList, and ToDoList. All of them are derived from the PIMList object.

PIMListListener

Each PIMList can have an associated PIMListListener object. The listener interface provides callback hooks for events like adding, removing, or updating items.

PIM

It is the main factory class for obtaining PIMList instances.

RepeatRule

It represents repeat rules for repeatable Events. We can use the Event.setRepeat() method to set the rules.


/ 204