1 / 37

Subject Name: Wireless Networks and Mobile Computing Subject Code:10CS831

Learn about the architecture of mobile applications using Java 2 Micro Edition (J2ME) technology, including the CDC and CLDC configurations, and the MIDP and RMI profiles.

glennk
Download Presentation

Subject Name: Wireless Networks and Mobile Computing Subject Code:10CS831

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. Subject Name: Wireless Networks and Mobile Computing Subject Code:10CS831 Prepared By:Mrs.ThanuKurian Department:Computer Science Date:30/08/2014

  2. A Typical Mobile Application architecture

  3. Java Technology - Editions Memory footprint decreases

  4. JAVA2 MICRO EDITION(J2ME)TECHNOLOGY • J2ME is a complete Java runtime environment,consisting of: • A JVM(Java Virtual Machine) • A set of Core Java runtime classes • A set of supported API(Application Programming Interface) • J2ME is a subset of J2SE • Configuration can be defined as a specification that identifies the system level facilities available,ie,thecharateristics and features of the virtual machine present and the minimum java libraries that are supported. • J2ME supports two configurations that represent two distinct categories of devices • First implement the Connected Device Configuration(CDC)-constantly connected eg: settopboxes,IntenetTVs,high end communicators • Second implements Connected,Limited Device Configuration(CDLC)-intermittent communication eg:mobilephones,two way pagers,PDA etc

  5. Java2 Micro Edition - Architecture

  6. CDC • CDC is a configutration for high end devices with larger memory(2MB or more),providing connectivity through some kind of network and some UI support. • CDC specification defines • A full-featured JVM,called CVM • A subset of J2SE 1.3 classes • APIs introduced in the CDLC-the Generic Connection Framework

  7. The CDC defines three profiles • Foundation profile: Has following requirements • Memory minimum 1024 KB ROM and 512 KB RAM for profile and configuration. • Stable Network Connectivity • Personal Basis Profile: • It caters device that enjoy reliable and constatnt internet connectivity and rich GUI.These devices are characterised by: • A minimum of 2.5 MB of ROM and 1MB RAM • Robust internet connectivity • Rich GUI with browser like internet support

  8. J2ME RMI Profile • Provides support for RMI across applications • Uses TCP/IP as underlying connection protocol

  9. CLDC • CDLC is meant for low end,itermittentlyconnected,battery operated devices • CDLC device is charaterised by following capabilities: • A minimum of 128 to 512KB for the pllatform • A 16-bit or 32-bit low end processor • A low bandwidth network with internittent connectivity • Sun has released two profiles tha sit atop the CDLC • Mobile Information Device Profile • Persona Digital Assistant Profile

  10. CLDC Packages • CLDC packages: • java.lang • java.io • java.util • javax.microedition.io

  11. MIDP • Most popular and widely supported one • It provides classes for writing downloadable applications and services that are of interest to the consumer-games,personalisation services etc • The MIDP profile requires the devices to have following capabilities • Minimum of 512 KB for the platform • Limited user interfaces • Intermittent connectivity • Some kind of input mechanism

  12. MIDP – Mobile Information Device Profile MIDP + CLDC = Part of J2ME Runtime Environment MIDP addresses: • User Interface • Persistent storage • Networking • Application model

  13. MIDP Packages MIDP Packages: • javax.micoredition.io • javax.microedition.midlet • javax.microedition.lcdui • javax.microedition.rms

  14. What is a MIDlet? • MIDP Application = MIDlet • MIDlet is similar to applet. • MIDlet Structure: • startApp() • pauseApp() • destroyApp(boolean unconditional)

  15. Paused pauseApp( ) startApp( ) Active destroyApp( ) destroyApp( ) Destroyed MIDlet’s Life Cycle

  16. MIDlet Class • All MIDP applications MUST inherit from the MIDlet class • Does not have a main() function • Cannot call System.exit() • It triggers a SecurityException to be thrown

  17. JAVA Packages • java.lang.* • java.io.* • java.util.* • javax.microedition.io.* • javax.microedition.ui.* • javax.microedition.rms.* • javax.microedition.midlet.*

  18. javax.microedition.io • StreamConnection • To open a basic connection that reads/writes simple data. • ContentConnection • To open a connection that provides content length, type, and encoding information. This interface extends from the StreamConnection interface.

  19. javax.microedition.io • HttpConnection • To open a connection that provides capabilities to interface through HTTP including getting/setting headers and HTTP-specific handling. This interface extends from the ContentConnectioninterface.

  20. javax.microedition.midlet • MIDlet • Used to build MIDP applications

  21. Hello Midlet import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloMidlet extends MIDlet { private Display display; TextBox box = null; public HelloMidlet() { } public void startApp() { display = display.getDisplay(this); box = new TextBox("Midlet Example", "Hello CS616", 20, 0); display.setCurrent(box); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }

  22. Hello Midlet

  23. User Interface: Display • Device screen on which a MIDlet displays its user interface: Display object (package javax.microedition.lcdui) • To obtain a reference to it: displayManager = getDisplay(this) (this is the current MIDlet) • To display something on that screen: displayManager.setCurrent(something) where something is Displayable

  24. User Interface: Good Practices Inputting text can be tedious on portable devices, help the user by: • providing pre-filled in fields • providing lists to choose from rather than text input boxes • remembering previously typed in information • organizing easy navigation within the MIDlet screens • keeping screens simple: few elements, short texts so there is no need to scroll down

  25. Interaction and Commands • Only a simple “window” displayed at the time • Need commands to change displayed content according to user input • Command items may be added (addCommand method) to a Displayable to be presented to the user. • Most important commands may be access directly, remaining commands are automatically presented in a menu. • Command behavior is defined in a CommandListener associated to the Displayable. • Most displayable items have set and get methods to change displayed content and get user input.

  26. Interaction and Commands: Example 1/2 import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class FirstCommands extends MIDlet implements CommandListener { private Form welcomeScreen; private TextField userInput; private Ticker banner; private final Command QUIT = new Command("Exit",Command.EXIT, 2); private final Command CHANGE = new Command("Change",Command.SCREEN,1); public FirstCommands() { welcomeScreen = new Form("First Command"); welcomeScreen.addCommand(QUIT); welcomeScreen.addCommand(CHANGE); welcomeScreen.setCommandListener(this); banner = new Ticker("Welcome here! "); welcomeScreen.setTicker(banner); userInput = new TextField("enter banner text:","",40,TextField.ANY); welcomeScreen.append(userInput); }

  27. Interaction and Commands: Example 2/2 protected void startApp() throws MIDletStateChangeException { Display.getDisplay(this).setCurrent(welcomeScreen); } protected void pauseApp() {} protected void destroyApp(boolean arg0) {} public void commandAction(Command c, Displayable d) { if (c == QUIT) notifyDestroyed(); if (c == CHANGE) banner.setString(userInput.getString()); } }

  28. Packaging • Create a MANIFEST.MF file: MIDlet-1: Hello MIDlet,,HelloWorld MIDlet-Name: Hello MIDlet MIDlet-Vendor: Virginie Galtier MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.1 MicroEdition-Profile: MIDP-2.0 • \Hello\output>jar cvfm Hello.jar MANIFEST.MF HelloWorld.class • Create a JAD file HelloWorld.jad: MIDlet-1: Hello MIDlet,,HelloWorld MIDlet-Jar-Size: 1130 MIDlet-Jar-URL: Hello.jar MIDlet-Name: Hello MIDlet MIDlet-Vendor: Virginie Galtier MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.1 MicroEdition-Profile: MIDP-2.0 • Test with emulator: \Hello\output>c:\WTK22\bin\emulator -classpath . -Xdescriptor HelloWorld.jad

  29. Accessing JAD and Manifest Information • getAppProperty(String key) method of the MIDlet class, key is the attribute name in the .jad and manifest files • Example: getAppProperty("MicroEdition-Configuration") returns “CLDC 1.1” • Useful for “about” information • Useful to pass parameter to the MIDlet: you can define your own attribute in the jad file. If you decide to change the values of thoses parameters, change only the .jad file, no need to modify the jar file!

  30. Over The Air Deployment Test • Place jar and jad file on a web server • Install and execute: \Hello\output>c:\WTK22\bin\emulator -Xjam:transient=http://localhost/Hello/HelloWorld.jad • List installed MIDlet: \Hello\output>c:\WTK22\bin\emulator -Xjam:list Result: Running with storage root DefaultColorPhone [1] Name: Hello MIDlet Vendor: Virginie Galtier Version: 1.0 Storage name: #Virginie%0020#Galtier_#Hello%0020#M#I#Dlet_ Size: 2K Installed From: http://localhost/Hello/HelloWorld.jad MIDlets: Hello MIDlet • Remove installed MIDlet: \Hello\output>c:\WTK22\bin\emulator -Xjam:remove=1 • Install: \Hello\output>c:\WTK22\bin\emulator -Xjam:install=http://localhost/Hello/HelloWorld.jad • Execute: \Hello\output>c:\WTK22\bin\emulator -Xjam:run=1

  31. Over The Air Deployment • create a hello.html file linking to the jad file: <html> <body> <a href="http://localhost/Hello/HelloWorld.jad">HelloWorld.jad</a> </body> </html> • launch the AMS: \Hello\output>c:\WTK22\bin\emulator -Xjam

  32. Installing and Running MIDlet on PocketPC • install IBM Workplace Client Technology Micro Edition • click on Start / programs / MIDlet HQ • enter jad URL

  33. Persistent Storage • Save information as collections of records • record = an array of bytes with associated integer identifier • record store = a collection of records identified by a name class javax.microedition.rms.RecordStore • record store names are shared by all MIDlets in a MIDlet suite: • allows information sharing • ! caution when accessing a RecordStore with multiple threads!

  34. Record Stores • Create and/or open: • static RecordStore openRecordStore(String name, boolean create) • If no record with the given exists • If create is true: a new one is created • If create is false: a RecordStoreNotFoundException is thrown • Close: • closeRecordStore • If a record store is opened more than once by a MIDlet, it won’t be closed until each open instance is closed • Other operations: • static void deleteRecordStore(String name) • static String[] listRecordStores() • String getName() • long getLastModified() • int getVersion(): incremented each time a record is added, removed or modified • …

  35. Records: creation • int addRecord(byte[] data, int offset, int size) • Returns identifier • Identifiers start at 1, increased by one at each record creation, identifiers of removed records are not reused • Record contains range of bytes from data[offset] to data[offset + size – 1] • Simple way to create a record from class instance fields: ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeUTF(secretary.name); dos.writeInt(secretary.age); dos.close(); byte[] data = baos.toByteArray(); int id = recordStrore.addRecord(data,0,data.length);

  36. Records: other operations • Retrieve information from a record store: byte[] data = recordStore.getRecord(recordId); ByteArrayInputStream bais = new ByteArrayInputStream(); DataInputStream dis = new DataInputStream(bais); Person secretary = new Person(); secretary.name = dis.readUTF(); secretary.age = dis.readInt(); dis.close(); • Update: void setRecord(int recordId, byte[] data, int offset, int size) • Remove: void deleteRecord(int recordId)

  37. Records: other operations • Retrieve information from a record store: byte[] data = recordStore.getRecord(recordId); ByteArrayInputStream bais = new ByteArrayInputStream(); DataInputStream dis = new DataInputStream(bais); Person secretary = new Person(); secretary.name = dis.readUTF(); secretary.age = dis.readInt(); dis.close(); • Update: void setRecord(int recordId, byte[] data, int offset, int size) • Remove: void deleteRecord(int recordId)

More Related