1 / 27

Overview

Java for Mobile Devices and mod_perl Gunther Birznieks www.eXtropia.com O’Reilly Open Source Convention July 22-26, 2002. Overview. Open Discussion Feel Free to Ask Questions Anytime… Java for Mobile Devices Of course, we’re not here to hype it…

venus
Download Presentation

Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java for Mobile Devicesand mod_perlGunther Birzniekswww.eXtropia.comO’Reilly Open Source ConventionJuly 22-26, 2002

  2. Overview • Open Discussion • Feel Free to Ask Questions Anytime… • Java for Mobile Devices • Of course, we’re not here to hype it… • But to show how useful different technologies working together can be… • J2ME (Java Micro Edition) • J2MEHttpBridge vs JavaCGIBridge • Mod_perl (for middleware)

  3. Background Motivation • Mobile Phone apps for Asia-Pacific • Singapore • Financial Industry • Multiple data channels

  4. Java for Mobile Devices • J2ME (as opposed to J2EE) • State: bleeding edge… • But with a great deal of potential • Potential lies in 2 key items • Ability to display rich data • Ability to take advantage of rich data on servers (JavaCGIBridge) • MIDlets Definition

  5. J2MEHttpBridge • O’Reilly Conference - August 1997 • JavaCGIBridge • O’Reilly Conference – August 1999 • Perl in Financial Community • Example of JavaCGIBridge • Perl-based Equities Trading System (Barclays Capital)

  6. Problems with WAP/SMS Alone • WML Forms have a minimal interface • not interactive (WMLScript does not solve the whole problem) • cannot be extended natively • Hard to maintain state between forms • Redundant data frequently needs to be re-retrieved between WML forms-- need to create fresh interface each time

  7. Problems with MIDlets Alone • Bloated Midlet Problem • Placing all application code on the Midlet makes for a huge download • Time is of the essence for OTA Downloads • Space is an issue on mobile devices • J2ME can be difficult to code! • Browser/Phone incompatibilities

  8. Problems with MIDlets Alone • J2ME VM restricts what MIDlets can do. • cannot open sockets to non-originating server (RDBMS problem) • So we look at solution…

  9. J2ME with Application Back-end Java MIDlet GUI J2MEHttpBridge mod_perl CGI/Perl Servlet Flat File on Web Server Database Server

  10. J2MEHttpBridge Solution • Advantages to deferring logic to middleware (eg mod_perl) • Mod_perl/CGI/Servlets can provide database connectivity more easily • Application related “business-rules” are centrally maintained and executed in mod_perl/CGI/Servlet apps

  11. J2MEHttpBridge Solution • More advantages of deferring server-side access • Browsers that don’t support Java can still use the application (HTML and WML) • For CGI/Perl can more readily leverage existing “legacy” code • Many ISPs only allow CGI/Perl access (no daemons)

  12. J2MEHttpBridge Solution • Minimizing Java Front-end advantages • Java MIDlet becomes a truly thin client -- only requires GUI code and GUI logic (JavaCGIBridge class adds ~5k overhead) • Less need to learn browser specific issues if you have less code on the front-end • But how do we use it…

  13. Nuts and Bolts • Modify Server programs to return parsed data • Add J2MEHttpBridge class to Java MIDlet implementation

  14. Nuts and Bolts (Server Side) • Data to be returned should be identified • Top separator (<!--start of data-->) • Bottom Separator (<!--end of data-->) • Pipe delimited fields • (Optional) Set up form variable to tell script to send data using separators defined above (javacgibridge=on)

  15. Sample CGI/Perl Code • The code on the next slide shows how a CGI/Perl application would be modified to return sample data for the Java applet if the form variable “javacgibridge” is set to “on”.

  16. Sample CGI/Perl Code (Continued) # If j2mehttpbridge is “on”, send data specially formatted for # java midlet, otherwise send regular HTML data to the user’s browser If ($form_data{“javacgibridge”} eq “on”) { print “<!--start of data-->”; # Loop through data here while (@row_of_data = &getRowOfData()) { printf(“%s|%s|\n”,@row_of_data); } print “<!--end of data-->”; } else { print “<TABLE><TR><TH>Last Name</TH><TH>First Name</TH></TR>”; # Loop through data here while (@row_of_data = &getRowOfData()) { printf(“<TR><TD>%s</TD><TD>%s</TD></TR>\n”, @row_of_data); } print “</TABLE>”; }

  17. Nuts and Bolts (Java MIDlet) • Instantiate J2MEHttpBridge class • Set up form variable, form value pairs inside Hashtable • Set up URL by instantiating URL class • Get parsed data back using the URL and form variable Hashtable as a Vector of Vectors (otherwise known as an array of arrays in Perl) • NOTE: No ArrayList/Map in CDLC VM

  18. Sample Java Code • The code on the next slide calls Address Book search script setting “firstname” and “javacgibridge” HTML form variables. The records will be returned as a Vector containing all the fields in each record as a Vector of Strings. • Uses javax.microedition.lcdui package

  19. Sample Java Code (Continued) URL u = new URL("http://www.yourdomain.com/cgi-bin/address_query.cgi"); J2MEHttpBridge jhBridge = new J2MEHttpBridge(); // firstNameTextField is a text field on a Java MIDlet that the user fills // in to query. jhBridge.addFormValue(formVars,"firstname",firstNameTextField.getString()); jhBridge.addFormValue(formVars,"javacgibridge", "on"); Vector addressBookResults = jhBridge.getParsedData(u,formVars);

  20. J2ME Application Delivery • Primary problems to solve: • Virii/Malicious Code • Commercial Aspect – How many times has app been delivered • In case paying per app?

  21. Where mod_perl comes in… • Intelligent Proxy code • Check for registered apps • Run app through intermediate Java virus checker (eventually) • Check phone type for appropriate app and version delivery • Fast Back-ends • Application layer logic

  22. Intelligent Proxy Code • Over The Air (OTA) Delivery of apps • Usually through a gateway system • WAP-based • Obtain mobile phone • Verify delivery • Also track payments of each app

  23. Intelligent Proxy Source Code • Pseudo-code for Verification • Use MD5 Hash in database to see if download has been accomplished before • If so, Reverse Proxy the code • Source Code is on www.eXtropia.com • We’ll look at it here (show example)

  24. Mod_perl Fast Back-ends • Similarly, mod_perl applications can be used as fast back-ends to provide data • J2ME apps would mostly be straight request/response to get data

  25. Technology Summary • J2ME on front-end • Mod_perl back-ends • Not just apps, the power is in dynamic verification • More information can be found by going to http://www.eXtropia.com/ • Acknowledgements: Lim Swee Tat, Philippe Chiasson, Ning Jiang, Ray Hsieh

  26. Open Discussion Questions?

More Related