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

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

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

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

Michael Juntao Yuan

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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

 

9.3 WMA Reference Implementation


To run the WMATester, we have to implement the WMA. An SMS wireless messaging client depends on the underlying device and mobile network infrastructure to send and receive messages. Thus, each implementation of the WMA is device- and network-dependent. Sun has come up with a WMA RI for PC emulators so that you can develop WMA applications independent of any actual phone or live network. Currently, the WMA RI works with the MIDP emulator. MIDP is a J2ME platform that targets mobile phone devices. WMA implementations for other J2ME platforms (such as PersonalJava, CDC) will come soon.


9.3.1 Runtime Properties


The RI provides a transport mechanism that emulates SMS over the host PC''s TCP/IP ports. All SMS messages are routed as datagram messages to host ports specified by the RI''s runtime properties. The properties can be specified in an internal config file or from the command line. Listing 9.5 illustrates the use of the command-line properties in the WMATester sample.

Listing 9.5. The reference implementation''s runtime properties



emulator -classpath MyApp.jar -Xdescriptor:MyApp.jad -Dcom.sun.midp.io.
enable_extra_protocols=true -Dcom.sun.midp.io.j2me.sms.Impl=
com.sun.midp.io.j2me.sms.DatagramImpl -Dcom.sun.midp.io.j2me.sms
.DatagramHost=localhost -Dcom
.sun.midp.io.j2me.sms.DatagramPortIn=54321 -Dcom.sun.midp.io.j2me
.sms.DatagramPortOut=12345 -Dcom
.sun.midp.io.j2me.sms.permission.receive=true -Dcom.sun.midp.io.j2me
.sms.permission.send=true -Dcom.sun.midp
.io.j2me.cbs.permission.receive=true -Djavax.microedition.io.Connector
.sms=true -Djavax.microedition.io.Connector
.cbs=true -Dcom.sun.midp.io.j2me.sms.CBSPort=24680 -Dwireless.messaging
.sms.smsc=+17815511212

Of course, the command in Listing 9.5 assumes that the WMA RI classes are already pre-verified and packed in MyApp.jar. Let''s examine each parameter in the listing in detail:

Property com.sun.midp.io.enable_extra_protocols enables the datagram protocol. It is needed for the MIDP 1.0 RI, which by default allows only HTTP GCF connections.

Property com.sun.midp.io.j2me.sms.Impl designates a class that supplies the low-level network transport for SMS messages in the WMA RI.

The com.sun.midp.io.j2me.sms.Datagram* properties specify the host and datagram ports to emulate SMS. In Listing 9.5, all outgoing SMS messages, regardless of destination phone numbers, are sent to local-host''s 12345 datagram port. All messages received from port 54321 will be captured by the WMA RI as incoming SMS messages. In the WMATester sample, the input and output datagram ports of the peer 1 are mapped to the output and input ports of the peer 2 respectively. This way, each of them captures all messages sent out by the other.

The com.sun.midp.io.j2me.sms.permission.* and javax.microedition.io. Connector.* properties specify the default permission to access SMS and CBS resources. Those properties are used by the MIDP 2.0 security manager.

Property com.sun.midp.io.j2me.sms.CBSPort specifies the SMS port on which to receive CBS messages.

Property wireless.messaging.sms.smsc specifies an SMS service center phone number. In the PC emulator, this property is irrelevant.


9.3.2 WMA Console in J2ME WTK v2.0


Sun''s J2ME Wireless ToolKit (J2ME WTK) v2.0 provides a GUI-based console to configure WMA settings for each emulated phone (Figure 9.3).


Figure 9.3. The WMA console in J2ME WTK v2.0.



9.3.3 Architecture


The WMA RI sports a multiple-layer architecture, illustrated in Resources").


Figure 9.4. WMA Reference Implementation architecture.


 

/ 204