Upload
jade-conley
View
244
Download
0
Embed Size (px)
Citation preview
Getting Started with JXTA for J2ME
Advisor : Dr. Ching-Long Yeh
Report : DI.2, 洪泰昌 (89506005)
Course: XML 文件管理
Abstract Ad hoc networks : a self-configuring network of
mobile Self-organization ability: simplify management, robust
ness, flexible Well suited to the vicissitudes of wireless P2P model enables “mobile devices” to assemble qui
ckly JXTA ("juxtapose") , a set of protocols for P2P n
etworking In this report:
How the JXTA protocols are extended to MIDP How to install and run JXTA demonstration programs
for MIDP
Abstract
JXME Proxy(Relay)
DEMO
JXTA demonstration programs for MIDP Chat MIDlet
Agenda Abstract JXTA Java ME (J2ME) JXME Summary Appendix
Prerequisite for implementation Implementation of J2ME Chat MIDlet Implementation of JXME Proxy References and Resources
JXTA JXTA defines a set of open protocols for
peer-to-peer networks JXTA (v2.0) Protocol Specification
XML-based protocols Functionalities
peer discovery endpoint routing connection binding basic query/response message exchange network propagation through rendezvous peers
Java ME
Java ME: Java Platform, Micro Edition (Java ME) provides a
environment for applications running on mobile and other embedded devices mobile phones, personal digital assistants (PDAs), TV set-
top boxes, and printers
MIDP: Mobile Information Device Profile (v2.0) Implementation Specification Subset of Java SE (JDK) limited capacity
Java ME MIDP:
javax.microedition.rms Record Management System, persistence
javax.microedition.midlet Environment, lifecycle
javax.microedition.io Network
javax.microedition.lcdui UI ( User Interface )
Java.lang.* java.util.* MIDlet : application
javax.microedition.midlet.MIDlet
Java ME MIDlet:
Managed by Application Management software (AMS) : Paused , Active , destroyed
JXME JXME :
JXTA Java Micro Edition (MIDP/CLDC/CDC) Project
The goal of the JXME project is to bring JXTA functionality to MIDP devices A framework
Why JXME ? The constraints of Mobile Device XML parser memory limits of MIDP devices? The state of the network needs to be cached memory
limits of MIDP devices? MIDP mandates support for HTTP, but socket and
datagram connections are optional JXTA protocols exceed the minimum requirements
of MIDP JXTA relay
JXME Architecture
Rendezvous/relays
Coordination between J2ME Edge Devices and JXTA Relays1. J2ME peer send HTTP request messages to a JXTA relay
2. JXTA relay parse each name-value pair in the HTTP request XML messages (JXTA format) relay the messages over the JXTA network
3. JXTA relay receives a message from the JXTA network parse the XML format of the incoming message author a corresponding HTTP response
4. Wait for the J2ME peer to send an HTTP poll request send the HTTP response back to the J2ME peer
1. 2.
3.4.
Response
JXME API
Element: elements of JXTA Message Message: JXTA Message, access methods PeerNetwork:
createInstance(): create PeerNetwork instance connect(): connect to relay create(): peer, group, pipe search(): peer, group, pipe poll() poll the information from relay server listen() and close(): open and close pipe send(): send the message to the pipe
JXME Code Example
Create pipeCreate peer
Connect to proxy
create pipe
JXME Code Example Find the pipe which we created
JXME Code Example
Send message through the pipe which we just find
JXME Code Example
Receive message
Summary
JXTA furnishes an XML-based, platform-independent set of protocols that enable P2P networking
JXME project brings JXTA functionality into the MIDP world
Vision: Ad hoc network Every mobile device as “Server”
Summary
Not popular ? Why ? Cost: GPRS, 3G …? Mobile device: Power consumption, UI ?
In the future WiMax cost down Wireless Leased-line network connected an
ytime Google Android platform ? XMPP protocol
Trends: P2P network + XML based protocol
Appendix
Prerequisite for implementation Required libraries from
http://download.java.net/jxta/ jxse-lib-2.5.zip
JXTA core JMEX Proxy libraries
jxme-2.1.3-bin.zip JXME framework Chat MIDlet code and libraries
Tools: NetBeans (6.0) + Mobility pack http://www.netbeans.org/
Implementation of J2ME Chat MIDlet1. New project Mobile mobile project from existing MIDP source
Implementation of J2ME Chat MIDlet2. Specify the source and JAD file
Implementation of J2ME Chat MIDlet3. Name and Location name chat
Implementation of J2ME Chat MIDlet4. Default Platform Selection : use default
Implementation of J2ME Chat MIDlet5. Add library : chat porject right click properties add Jar/Zip jxta-cl
dc.jar
Implementation of J2ME Chat MIDlet6. Run : chat project right click run project
Implementation of J2ME Chat MIDletRelated files and locations Chat source code
\jxme-2.1.3-bin\midp\demo\chat JAD:
\jxme-2.1.3-bin\midp\demo\chat\bin\chat.jad Library:
\jxme-2.1.3-bin\midp\demo\chat\lib\jxta-cldc.jar
Implementation of JXME Proxy1. New project General project Java Application
Implementation of JXME Proxy2. name proxy finish
Implementation of JXME Proxy3. New Java class place the code which we provide
Implementation of JXME Proxy Code: package tommy;import java.io.File;import net.jxta.platform.NetworkManager;public class StartJXME_Proxy { private NetworkManager manager;public StartJXME_Proxy() { }private void startProxy() { try { manager = new NetworkManager(NetworkManager.ConfigMode.PROXY, "ProxyeS
erver", new File(new File(".cache"), "ProxyeServer").toURI()); manager.startNetwork(); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } } public static void main(String[] args){ StartJXME_Proxy startJXME_proxy = new StartJXME_Proxy(); startJXME_proxy.startProxy(); }}
Implementation of JXME Proxy4. Add libraries Libraries Add Jar/folder\jxse-lib-2.5\*.jar
Implementation of JXME Proxy5. Run project right click run project
References and Resources Getting Started with JXTA for J2ME, http://developers.sun.com
/mobility/midp/articles/jxme/index.html JXTA, https://jxta.dev.java.net/ JXTA v2.0 Protocol Specification, https://jxta-spec.dev.java.net
/ JXTA Community Forum, http://forums.java.net/jive/forum.jspa?
forumID=50&start=0 JXTA JXSE Programmers Guide, https://jxta-guide.dev.java.net
/ J2ME tutorials, http://developers.sun.com/mobility/learning/tutori
al/ Sun Java Wireless Toolkit , http://java.sun.com/products/sjwtoo
lkit/download.html NetBeans, http://www.netbeans.org/
References and Resources Code in Netbeans Project:
網路硬碟二: share name XML-JXME Maybe you need to correct the location of libraries
Public JXME proxy: http://rdv.jxtahosts.net/cgi-bin/relays.cgi?2 http://192.18.37.36:9700 http://192.18.37.37:9700 http://192.18.37.38:9700 http://192.18.37.39:9700