Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
from Yongwoo’s Park XML in the J2METM September 29, 2002 from Yongwoo’s Park 2 Acknowledgements from Yongwoo’s Park JavaTM Technology and XML Programming for Wireless Devices - A Primer, TS-1137, JavaOne 2002 Srikanth Raju Raghavan "Rags" Srinivas Technology Evangelists Sun Microsystems, Inc. Parsing XML in the JavaTM 2 Platform, Micro Edition (J2METM) - XML in a MIDP Environment, Session 2716, JavaOne 2002 Jonathan Knudsen Technical Writer Sun Microsystems, Inc. from Yongwoo’s Park JavaTM Technology and XML Programming for Wireless Devices – A Primer TS-1137, JavaOne 2002 Srikanth Raju Raghavan “Rags” Srinivas from Yongwoo’s Park The J2ME Platform, CLDC and MIDP Overview 5 Java 2 Platform from Yongwoo’s Park 6 J2ME Configuration from Yongwoo’s Park A configuration for the J2ME platform ("J2ME configuration") defines a minimum Java platform for: Broad range of devices in different areas Similar requirements of memory size and processing capabilities A configuration defines Minimum Java technology libraries Virtual machine capabilities Platform Security Model Defined through the Java Community ProcessSM (JCP) program Subject to compatibility tests 7 CLDC (Connected, Limited Device Configuration) from Yongwoo’s Park Targeted at devices with 160KB to 512KB total memory available for Java technology Limited power (often battery) Limited, perhaps intermittent connectivity to a network (often wireless) Extremely constrained UIs, small screens 8 (MIDP) Mobile information Device Profile from Yongwoo’s Park Targets mobile two-way devices implementing "J2ME CLDC" (CLDC for the J2ME platform) Profile addresses Display toolkit, User input methods Persistent data storage using simple record-oriented database model HTTP 1.1-based networking using CLDC Generic Connection framework MIDP 1.0.3 spec and implementation available for download now MIDP Next Generation in progress via the JCP program 9 Example: J2ME Platform-based Wireless Device Stack from Yongwoo’s Park 10 CLDC Networking and I/O from Yongwoo’s Park Standard networking for the J2SE platform, I/O, and storage libraries: Are too large for CLDC devices Assume TCP/IP is available CLDC specifies a Generic Connection framework, which enables: Consistent way of supporting various protocols Improved portability of applications Smaller footprint Usage General form: Connector.open("<protocol>://<address>:<parameters>"); 11 Scope of the MIDP Specification from Yongwoo’s Park Application model (lifecycle, packaging) javax.microedition.midlet.MIDlet Persistent storage javax.microedition.rms Networking Implements CLDC Generic Connections javax.microedition.io User interface support javax.microedition.lcdui 12 MIDP Networking from Yongwoo’s Park MIDP devices must implement client portion of HTTP 1.1 protocol May or may not use IP-based transport underneath 13 MIDP UI Design Principles from Yongwoo’s Park Must be usable in all devices One handed, two handed, stylus operation Small screens (tens of pixels by tens of pixels) Not all devices have a pointing device Must constantly think of end users Mobile Information Devices are consumer products, not desktop computers MIDP applications should use simple traversing and selection metaphors MIDP applications and native apps should look and behave consistently on any given device 14 MIDP UI: A Tale of Two Layers from Yongwoo’s Park Use the MIDP High-level UI APIs for portability Apps run in all MIDP compliant devices No direct access to native device features High-level UI screens are based upon javax.microedition.lcdui.Screen Low-level APIs ("Game" APIs) Provide access to native drawing primitives, device key events, native input devices, etc. Allow developers to choose to compromise portability for user experience, if required Handle low level events and drive graphics via javax.microedition.lcdui.Canvas from Yongwoo’s Park XML Overview 16 Java 2 Platform and the Web Services Model from Yongwoo’s Park 17 SAX: Simple API for XML from Yongwoo’s Park 18 DOM: Document Object Model from Yongwoo’s Park 19 XML Transformations from Yongwoo’s Park XML separates content from presentation Transformations can be used to convert from XML to some other format including a new XML file Transformations can be used to style XML documents Example of XML transformation: 20 XSLT Processor from Yongwoo’s Park from Yongwoo’s Park Using XML in Enterprise Applications for the java platform (“Enterprise Java Application”) 22 Using Applets With XML from Yongwoo’s Park Applets can provide client-side processing of documents Applets can use DOM to create XML documents and send them to a server All validation, parsing and transformation can be handled by the client Any XSL stylesheets or DTDs would also have to be delivered along with classes Use a jar file for packaging Apache Xalan can be used from within an applet 23 Using “Servlets” With XML from Yongwoo’s Park Java Servlet API-based components ("Servlets")could provide server-side processing of documents A client could send data via a form that could then be used to construct an XML document Servlets eliminate the need for clients to be XML-aware Clients would just see transformed and styled output (like HTML) Apache Xalan can be used within a servlet 24 Using JSP(JavaServer Pages) Technology With XML from Yongwoo’s Park The JSP specification-based page ("JSP page") can handle the task of presentation (the view) A JavaBeans specification-based component ("JavaBeans component") can be used from the JSP page to handle client interaction (the controller) Business methods of the component can manipulate XML documents (the model) By ensuring the use of JavaBeans components, a cleaner separation of view from controller/model is possible Use the jsp:useBean tag or custom tags to manipulate XML documents 25 The JMS(Java Message Service) API and XML from Yongwoo’s Park The JMS API is a Java technology API to a message service The JMS API supports both publish/subscribe and point-to-point TransportMessage in the JMS API is designed for XML By utilizing XML, the data is as transparent as the messaging system 26 Using XML With Databases from Yongwoo’s Park XML is a great fit for representing database content Tables map directly to an XML element tree Complex joins could be represented with element nesting or attributes The XML tree could be a logical representation of the data Each database query could be an XML document Each database result could become an XML document 27 MIDlet Development Steps from Yongwoo’s Park Here are the steps to follow to create and execute your MIDlet Write the "Java code" (Java programming language-based code) Compile it Preverify the class Create a Manifest file Package it into a Jar file Create the MIDlet Descriptor file Run the MIDlet on the emulator 28 Compiling the Source from Yongwoo’s Park 29 Preverifying the Class from Yongwoo’s Park 30 Jar Up the Preverified Class from Yongwoo’s Park 31 Create the MIDlet Descriptor File from Yongwoo’s Park 32 Running the MIDlet from Yongwoo’s Park 33 The J2ME Wireless Toolkit from Yongwoo’s Park Provides two GUI-based development environments with a choice of emulators Ktoolbar The Forte For Java IDE URL http://java.sun.com/products/j2mewtoolkit kToolBar IDE in the J2ME Wireless Toolkit Use kToolBar to compile, build, and execute a MIDlet with the Emulator Use your own editor Simple to use 34 kToolBar (in the J2ME Wireless Toolkit, v.1.0.4) from Yongwoo’s Park from Yongwoo’s Park Parsing XML in the JavaTM 2 Platform, Micro Edition (J2METM) - XML in a MIDP Environment Session 2716, JavaOne 2002 Jonathan Knudsen from Yongwoo’s Park Multi-tier System Architecture 37 3-tier System Architecture from Yongwoo’s Park 38 Everything Is Small in MIDP from Yongwoo’s Park Network setup is slow Data rates are slow Processor is slow Memory is scarce 39 MIDP Clients Need Server Support from Yongwoo’s Park No HTML browsers here No complex protocols: no JNDI, no RMI Server steps up to the plate Mashes data into formats the client understands Handles complex protocols for the client 40 Three Tiers With MIDP from Yongwoo’s Park from Yongwoo’s Park Parser Roundup 42 Don't Supersize Me from Yongwoo’s Park Code size is constrained JAR size maximum is about 50 kB (varies by carrier, manufacturer) Available memory is generally small Open Source is attractive Customizable in size and features Fixable 43 Parser Types from Yongwoo’s Park Model Creates an object representation of a document in memory (e.g., DOM) Push Parses through an entire document, spitting out events to registered listeners (e.g., SAX) Pull Parses a little at a time, returning a single element or tag 44 The Small Parser Lineup from Yongwoo’s Park 45 Links from Yongwoo’s Park 46 Near Misses from Yongwoo’s Park NanoXML 2.2 Lite 6 kB http://nanoxml.sourceforge.net/ XMLtp 1.7 25 kB http://members.tripod.de/xmltp/ 47 Porting Techniques from Yongwoo’s Park Remove features you don…t need Supply missing classes java.* naming is questionable Dummy classes or real implementations Rewrite unavailable functionality from Yongwoo’s Park Performance Consideration 49 Overview from Yongwoo’s Park Not specific to XML applications An XML parser may push you to the wall Runtime performance Connection setup: number of documents Connection speed: document size User perception Deployment Code size 50 Document Design from Yongwoo’s Park Connection setup time is long Make each document count Perhaps aggregate documents on the server Connection speed is slow Only send essential information Make documents as short as possible 51 Threading from Yongwoo’s Park Network activity has to go in a separate thread Don't lock up the application's interface Ideally, allow the user to do other work while network activity occurs in the background Parsing should likely occur in a separate thread Depends on your parser Depends on your document 52 Code Size from Yongwoo’s Park Carriers or devices may impose restrictions on code size Nextel/Motorola: 50 kB (soft) Devices don't have much storage space Wireless bandwidth is small Code size refers to the size of the MIDlet suite JAR .class files Resource files (images, icons, others) Use an obfuscator to reduce class file size 53 What Does an Obfuscator Do? from Yongwoo’s Park Depends on the product: read the documentation Original purpose was to render code impervious to decompilation Some possibilities: Removes unused classes Removes unused methods and variables Renames classes, packages and variables Adds illegal stuff that confuses decompilers 54 Using an Obfuscator from Yongwoo’s Park The obfuscator may not play nicely with your development environment Build without obfuscation: Compile Preverify JAR Build with obfuscation: Compile Obfuscate Preverify JAR Another possibility: Compile Preverify JAR4Obfuscate Preverify JAR 55 Some Free Stuff from Yongwoo’s Park JAX http://www.alphaworks.ibm.com/tech/JAX/ Removes unused classes and interfaces Prunes unused methods and variables Shortens internal method and field names Retroguard http://www.retrologic.com/retroguard-main.html Renames class, method, and field names from Yongwoo’s Park DEMO An Example: Parsing RSS 57 An example of the output from Meerkat from Yongwoo’s Park 58 RSSPaser.java and RSSListener.java from Yongwoo’s Park 59 RSSMIDlet.java from Yongwoo’s Park from Yongwoo’s Park DEMO Sample XML Midlet: Interaction with the Middle-tier 61 MIDP and XML-Issues to Be Aware of from Yongwoo’s Park MIDP networking allows access to data formats such as XML, WML, etc. XML Parsing == Heavy String Manipulation; Adding XML parser adds to footprint; MIDP_NG proposal calls for an XML parser Of course, as always think about alternatives Example XML parsing on the Server instead of the MIDP Client 62 ServletXML.java from Yongwoo’s Park 63 ServletXML.java from Yongwoo’s Park 64 ServletXML.java from Yongwoo’s Park 65 HelloMIDlet.java from Yongwoo’s Park 66 HelloMIDlet.java from Yongwoo’s Park 67 HelloMIDlet.java from Yongwoo’s Park 68 HelloMIDlet.java from Yongwoo’s Park 69 HelloMIDlet.java from Yongwoo’s Park 70 HelloMIDlet.java from Yongwoo’s Park 71 Summary from Yongwoo’s Park MIDlet and XML The J2ME platform, CLDC, and MIDP Technical Overview XML Overview and XML in enterprise Java technology Developing a MIDlet - Steps MIDlet accessing XML data in enterprise Java technology Three-tier application architecture May include XML and transformations for different client types May make sense to send XML to a MIDP client Various small parsers exist Differentiated by execution model, license, size Optimizations Document size, network connections Code size 72 Resources from Yongwoo’s Park Parsing XML in J2ME http://wireless.java.sun.com/midp/articles/parsingxml/ Connected, Limited Device Configuration http://java.sun.com/products/cldc Mobile Information Device Profile http://java.sun.com/products/midp Download the Sun J2ME Wireless Toolkit: http://java.sun.com/products/j2mewtoolkit The J2ME Platform and Wireless Webcasts: http://java.sun.com/jdc/onlineTraining/webcasts 73 참고 서적 from Yongwoo’s Park 74 Questions … from Yongwoo’s Park from Yongwoo’s Park [email protected]