下載

36
Getting Started with JXTA for J2ME Advisor : Dr. Ching-Long Yeh Report : DI.2, 洪洪洪 (89506005) Course: XML 洪洪洪洪

description

 

Transcript of 下載

Page 1: 下載

Getting Started with JXTA for J2ME

Advisor : Dr. Ching-Long Yeh

Report : DI.2, 洪泰昌 (89506005)

Course: XML 文件管理

Page 2: 下載

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

Page 3: 下載

Abstract

JXME Proxy(Relay)

DEMO

JXTA demonstration programs for MIDP Chat MIDlet

Page 4: 下載

Agenda Abstract JXTA Java ME (J2ME) JXME Summary Appendix

Prerequisite for implementation Implementation of J2ME Chat MIDlet Implementation of JXME Proxy References and Resources

Page 5: 下載

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

Page 6: 下載

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

Page 7: 下載

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

Page 8: 下載

Java ME MIDlet:

Managed by Application Management software (AMS) : Paused , Active , destroyed

Page 9: 下載

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

Page 10: 下載

JXME Architecture

Page 11: 下載

Rendezvous/relays

Page 12: 下載

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

Page 13: 下載

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

Page 14: 下載

JXME Code Example

Create pipeCreate peer

Connect to proxy

create pipe

Page 15: 下載

JXME Code Example Find the pipe which we created

Page 16: 下載

JXME Code Example

Send message through the pipe which we just find

Page 17: 下載

JXME Code Example

Receive message

Page 18: 下載

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”

Page 19: 下載

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

Page 20: 下載

Appendix

Page 21: 下載

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/

Page 22: 下載

Implementation of J2ME Chat MIDlet1. New project Mobile mobile project from existing MIDP source

Page 23: 下載

Implementation of J2ME Chat MIDlet2. Specify the source and JAD file

Page 24: 下載

Implementation of J2ME Chat MIDlet3. Name and Location name chat

Page 25: 下載

Implementation of J2ME Chat MIDlet4. Default Platform Selection : use default

Page 26: 下載

Implementation of J2ME Chat MIDlet5. Add library : chat porject right click properties add Jar/Zip jxta-cl

dc.jar

Page 27: 下載

Implementation of J2ME Chat MIDlet6. Run : chat project right click run project

Page 28: 下載

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

Page 29: 下載

Implementation of JXME Proxy1. New project General project Java Application

Page 30: 下載

Implementation of JXME Proxy2. name proxy finish

Page 31: 下載

Implementation of JXME Proxy3. New Java class place the code which we provide

Page 32: 下載

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(); }}

Page 33: 下載

Implementation of JXME Proxy4. Add libraries Libraries Add Jar/folder\jxse-lib-2.5\*.jar

Page 34: 下載

Implementation of JXME Proxy5. Run project right click run project

Page 35: 下載

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/

Page 36: 下載

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