Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

  • Be the first to comment

  • Be the first to like this


  1. 1. Getting Started with JXTA for J2ME Advisor : Dr. Ching-Long Yeh Report : DI.2, 洪泰昌 (89506005) Course: XML 文件管理
  2. 2. Abstract <ul><li>Ad hoc networks : a self-configuring network of mobile </li></ul><ul><ul><li>Self-organization ability: simplify management, robustness, flexible </li></ul></ul><ul><ul><li>Well suited to the vicissitudes of wireless </li></ul></ul><ul><ul><li>P2P model enables “mobile devices” to assemble quickly </li></ul></ul><ul><li>JXTA (&quot;juxtapose&quot;) , a set of protocols for P2P networking </li></ul><ul><li>In this report: </li></ul><ul><ul><li>How the JXTA protocols are extended to MIDP </li></ul></ul><ul><ul><li>How to install and run JXTA demonstration programs for MIDP </li></ul></ul>
  3. 3. Abstract <ul><li>JXTA demonstration programs for MIDP </li></ul><ul><ul><li>Chat MIDlet </li></ul></ul>JXME Proxy (Relay) DEMO
  4. 4. Agenda <ul><li>Abstract </li></ul><ul><li>JXTA </li></ul><ul><li>Java ME (J2ME) </li></ul><ul><li>JXME </li></ul><ul><li>Summary </li></ul><ul><li>Appendix </li></ul><ul><ul><li>Prerequisite for implementation </li></ul></ul><ul><ul><li>Implementation of J2ME Chat MIDlet </li></ul></ul><ul><ul><li>Implementation of JXME Proxy </li></ul></ul><ul><ul><li>References and Resources </li></ul></ul>
  5. 5. JXTA <ul><li>JXTA defines a set of open protocols for peer-to-peer networks </li></ul><ul><ul><li>JXTA (v2.0) Protocol Specification </li></ul></ul><ul><li>XML-based protocols </li></ul><ul><li>Functionalities </li></ul><ul><ul><li>peer discovery </li></ul></ul><ul><ul><li>endpoint routing </li></ul></ul><ul><ul><li>connection binding </li></ul></ul><ul><ul><li>basic query/response message exchange </li></ul></ul><ul><ul><li>network propagation through rendezvous peers </li></ul></ul>
  6. 6. Java ME <ul><li>Java ME: </li></ul><ul><ul><li>Java Platform , Micro Edition (Java ME) provides a environment for applications running on mobile and other embedded devices </li></ul></ul><ul><ul><ul><li>mobile phones, personal digital assistants (PDAs), TV set-top boxes, and printers </li></ul></ul></ul><ul><li>MIDP: Mobile Information Device Profile (v2.0) </li></ul><ul><ul><li>Implementation Specification </li></ul></ul><ul><ul><li>Subset of Java SE (JDK)  limited capacity </li></ul></ul>
  7. 7. Java ME <ul><li>MIDP: </li></ul><ul><ul><li>javax.microedition.rms </li></ul></ul><ul><ul><ul><li>Record Management System, persistence </li></ul></ul></ul><ul><ul><li>javax.microedition.midlet </li></ul></ul><ul><ul><ul><li>Environment, lifecycle </li></ul></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><ul><li>Network </li></ul></ul></ul><ul><ul><li>javax.microedition.lcdui </li></ul></ul><ul><ul><ul><li>UI ( User Interface ) </li></ul></ul></ul><ul><ul><li>Java.lang.* java.util.* </li></ul></ul><ul><li>MIDlet : application </li></ul><ul><ul><li>javax.microedition.midlet.MIDlet </li></ul></ul>
  8. 8. Java ME <ul><li>MIDlet: </li></ul><ul><ul><li>Managed by Application Management software (AMS) : Paused , Active , destroyed </li></ul></ul>
  9. 9. JXME <ul><li>JXME : </li></ul><ul><ul><li>JXTA Java Micro Edition (MIDP/CLDC/CDC) Project </li></ul></ul><ul><li>The goal of the JXME project is to bring JXTA functionality to MIDP devices </li></ul><ul><ul><li>A framework </li></ul></ul><ul><li>Why JXME ?  The constraints of Mobile Device </li></ul><ul><ul><li>XML parser  memory limits of MIDP devices? </li></ul></ul><ul><ul><li>The state of the network  needs to be cached  memory limits of MIDP devices? </li></ul></ul><ul><ul><li>MIDP mandates support for HTTP, but socket and datagram connections are optional </li></ul></ul><ul><li>JXTA protocols exceed the minimum requirements of MIDP  JXTA relay </li></ul>
  10. 10. JXME Architecture
  11. 11. Rendezvous/relays
  12. 12. Coordination between J2ME Edge Devices and JXTA Relays <ul><li>J2ME peer send HTTP request messages to a JXTA relay </li></ul><ul><li>JXTA relay parse each name-value pair in the HTTP request  XML messages (JXTA format)  relay the messages over the JXTA network </li></ul><ul><li>JXTA relay receives a message from the JXTA network  parse the XML format of the incoming message  author a corresponding HTTP response </li></ul><ul><li>Wait for the J2ME peer to send an HTTP poll request  send the HTTP response back to the J2ME peer </li></ul>1. 2. 3. 4. Response
  13. 13. JXME API <ul><li>Element : elements of JXTA Message </li></ul><ul><li>Message : JXTA Message, access methods </li></ul><ul><li>PeerNetwork : </li></ul><ul><ul><li>createInstance(): create PeerNetwork instance </li></ul></ul><ul><ul><li>connect(): connect to relay </li></ul></ul><ul><ul><li>create(): peer, group, pipe </li></ul></ul><ul><ul><li>search(): peer, group, pipe </li></ul></ul><ul><ul><li>poll() poll the information from relay server </li></ul></ul><ul><ul><li>listen() and close(): open and close pipe </li></ul></ul><ul><ul><li>send(): send the message to the pipe </li></ul></ul>
  14. 14. JXME Code Example <ul><li>Create pipe </li></ul>Create peer Connect to proxy create pipe
  15. 15. JXME Code Example <ul><li>Find the pipe which we created </li></ul>
  16. 16. JXME Code Example <ul><li>Send message through the pipe which we just find </li></ul>
  17. 17. JXME Code Example <ul><li>Receive message </li></ul>
  18. 18. Summary <ul><li>JXTA furnishes an XML-based, platform-independent set of protocols that enable P2P networking </li></ul><ul><li>JXME project brings JXTA functionality into the MIDP world </li></ul><ul><li>Vision: Ad hoc network  Every mobile device as “Server” </li></ul>
  19. 19. Summary <ul><li>Not popular ? Why ? </li></ul><ul><ul><li>Cost: GPRS, 3G …? </li></ul></ul><ul><ul><li>Mobile device: Power consumption, UI ? </li></ul></ul><ul><li>In the future </li></ul><ul><ul><li>WiMax  cost down </li></ul></ul><ul><ul><li>Wireless  Leased-line network  connected anytime </li></ul></ul><ul><ul><li>Google Android platform ?  XMPP protocol </li></ul></ul><ul><li>Trends: P2P network + XML based protocol </li></ul>
  20. 20. Appendix
  21. 21. Prerequisite for implementation <ul><li>Required libraries from </li></ul><ul><ul><li> </li></ul></ul><ul><ul><ul><li>JXTA core </li></ul></ul></ul><ul><ul><ul><li>JMEX Proxy libraries </li></ul></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><ul><li>JXME framework </li></ul></ul></ul><ul><ul><ul><li>Chat MIDlet code and libraries </li></ul></ul></ul><ul><li>Tools: </li></ul><ul><ul><li>NetBeans (6.0) + Mobility pack </li></ul></ul><ul><ul><li>http:// / </li></ul></ul>
  22. 22. Implementation of J2ME Chat MIDlet 1. New project  Mobile  mobile project from existing MIDP source
  23. 23. Implementation of J2ME Chat MIDlet 2. Specify the source and JAD file
  24. 24. Implementation of J2ME Chat MIDlet 3. Name and Location  name  chat
  25. 25. Implementation of J2ME Chat MIDlet 4. Default Platform Selection : use default
  26. 26. Implementation of J2ME Chat MIDlet 5. Add library : chat porject  right click  properties  add Jar/Zip  jxta-cldc.jar
  27. 27. Implementation of J2ME Chat MIDlet 6. Run : chat project  right click  run project
  28. 28. Implementation of J2ME Chat MIDlet <ul><li>Related files and locations </li></ul><ul><li>Chat source code </li></ul><ul><ul><li>jxme-2.1.3-binmidpdemochat </li></ul></ul><ul><li>JAD: </li></ul><ul><ul><li>jxme-2.1.3-binmidpdemochatinchat.jad </li></ul></ul><ul><li>Library: </li></ul><ul><ul><li>jxme-2.1.3-binmidpdemochatlibjxta-cldc.jar </li></ul></ul>
  29. 29. Implementation of JXME Proxy 1. New project  General project  Java Application
  30. 30. Implementation of JXME Proxy 2. name  proxy  finish
  31. 31. Implementation of JXME Proxy 3. New Java class  place the code which we provide
  32. 32. Implementation of JXME Proxy <ul><li>Code: </li></ul><ul><li>package tommy; </li></ul><ul><li>import; </li></ul><ul><li>import net.jxta.platform.NetworkManager; </li></ul><ul><li>public class StartJXME_Proxy { </li></ul><ul><li>private NetworkManager manager; </li></ul><ul><li>public StartJXME_Proxy() { </li></ul><ul><li>} </li></ul><ul><li>private void startProxy() { </li></ul><ul><li>try { </li></ul><ul><li>manager = new NetworkManager(NetworkManager.ConfigMode.PROXY, &quot;ProxyeServer&quot;, new File(new File(&quot;.cache&quot;), &quot;ProxyeServer&quot;).toURI()); </li></ul><ul><li>manager.startNetwork(); </li></ul><ul><li>} catch (Exception e) { </li></ul><ul><li>e.printStackTrace(); </li></ul><ul><li>System.exit(-1); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>public static void main(String[] args){ </li></ul><ul><li>StartJXME_Proxy startJXME_proxy = new StartJXME_Proxy(); </li></ul><ul><li>startJXME_proxy.startProxy(); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  33. 33. Implementation of JXME Proxy 4. Add libraries  Libraries  Add Jar/folder  jxse-lib-2.5*.jar
  34. 34. Implementation of JXME Proxy 5. Run  project  right click  run project
  35. 35. References and Resources <ul><li>Getting Started with JXTA for J2ME, </li></ul><ul><li>JXTA, </li></ul><ul><li>JXTA v2.0 Protocol Specification, </li></ul><ul><li>JXTA Community Forum, </li></ul><ul><li>JXTA JXSE Programmers Guide , </li></ul><ul><li>J2ME tutorials, http:// /mobility/learning/tutorial/ </li></ul><ul><li>Sun Java Wireless Toolkit , http:// </li></ul><ul><li>NetBeans, http:// / </li></ul>
  36. 36. References and Resources <ul><li>Code in Netbeans Project: </li></ul><ul><ul><li>網路硬碟二: share name  XML-JXME </li></ul></ul><ul><ul><li>Maybe you need to correct the location of libraries </li></ul></ul><ul><li>Public JXME proxy: </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul>