9. Platforms – Java ME and Osgi
Total Page:16
File Type:pdf, Size:1020Kb
Department of Computer Science Institute for System Architecture, Chair for Computer Networks Application Development for Mobile and Ubiquitous Computing 9. Platforms – Java ME and OSGi Dr. Ing. Thomas Springer Technische Universität Dresden Chair of Computer Networks JAVA MICRO EDITION Java Micro Edition - Overview Creation of Stand-alone applications for resource limited devices • Native programming limits portability and reusability • Java is a widely deployed platform • supports portability and reusability • issues with resource-limited devices for Java SE Sun divides today the Java-technology into 3 domains: • Java SE (Standard Edition) ⇨ Desktop applications • Java ME (Micro Edition) ⇨ Resource restricted systems • Java EE (Enterprise Edition) ⇨ Server-side solution Goals of Java ME • Portability of applications for large range of resource-limited devices • same (Java) programming model • Comfortable development of applications for mobile devices Fast growing distribution of Java Micro Edition • Number of Java ME-enabled mobile phones: o 2002: 31 Mio. o 2003: 88 Mio. o 2008: 592 Mio. (prognosis) Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 3 Application Domains of Java ME Designed for devices with restrictions concerning processor power, memory, display size and networking capabilities Heterogeneous requirements for Java ME devices • Personal, mobile, networked devices o Mobile phones, PDA`s, Smart phones, pagers o Characteristics:• Simple User Interfaces • Memory capacity: 128 – 512 kb • Wireless network connection (low bandwidth) • Commonly used, stationary, networked devices o Set-Top-Boxes, video-phones, entertainment and navigation systems… o Characteristics:• More complex user interfaces • Memory capacity: 2 – 16 MB • Broadband network connection over TCP/IP Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 4 Modular Architecture – Java ME Contents Optional Packets Profiles Configurations CVM KVM … Kilo Virtual Machine, CVM … Compact Virtual Machine Ref: [Schmatz, Java 2 Micro Edition] Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 5 Modular Architecture- Details CVM/KVM • Kernel of Java ME • CVM for more powerful devices (High-End PDA) • KVM for resource restricted devices (Mobile Phones) o Restrictions compared to JVM (JNI, Class file-Verifier) Configurations • Horizontal classification of Java ME • Smallest common basis of all devices of that category Profiles • Vertical classification of Java ME • Adaptation to special devices (different display sizes) • Application development (MIDlets) Optional packets • Extension by additional functionality (SMS, MMS, Bluetooth) • support for device-specific functionality Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 6 Configurations Configuration defines • language support of Java • functionality of Virtual Machine (VM) • basic programming libraries o Usually subset of Java SE used o Alternative/additional functionality defined outside Java SE Two configurations • Connected, Limited Device Configuration (CLDC) o for personal, mobile, weakly-connected devices • Connected Device Configuration (CDC) o for shared, stationary, network integrated devices Different versions per configuration • Currently two versions (1.0 and 1.1) for CDC and CLDC Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 7 Configurations - CDC Connected Device Configuration (CDC) • Currently available in Version 1.1 (JSR-218) • Characteristics o Powerful CPUs (min. 32 Bit) o High memory resource (min. 4 Mbytes) o Good data transmission rates: permanent network connection Profiles are subsets of Java SE 1.4.2 • Foundation Profile 1.1 (JSR – 219) o Extension of CDC by security packets o No graphical user interfaces possible • Personal Basis Profile 1.1 (JSR-217) o Graphical User Interfaces by subset of AWT o Only light-weight components (container, component) oUsageofX-lets - Similar to MIDlets, States: Loaded, Active, Paused, Destroyed - Communication by Inter-Xlet-Communication(IXC) • Personal Profile 1.1 (JSR-216) o Supports almost all components of AWT o including Heavy Weight components (Buttons, Lists) Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 8 Configurations - CLDC Connected Limited Device Configuration (CLDC) • Currently available in Version 1.1 (JSR-139) • Kilo Virtual Machine o goal: 160 – 512 kb memory used o Subset of Java VM features - no floating point arithmetic (no float and double) (available for CLDC 1.1) - no native functions - no user defined class loaders - no introspection (no serialization, no RMI) - no Thread groups and daemon threads - limited Garbage Collector (no finalize(), no weak references (available for CLDC 1.1)) • Characteristics o Less powerful CPUs with 16-32 Bit o Low memory resources: 192-512 k byte o Short battery life time o Low transmission data rates -> no permanent network connection o Minimal operating system for managing hardware Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 9 Profiles of CLDC Mobile Information Device Profile (MIDP) • Timer (delay of activities) • Network connection by Generic Connection Framework (GCF) • Persistent memory (RMS) o Mini database as record store organized o Data operations (add, change, delete of records) o Record store assigned to applications • Application development o Generation of MIDlet-Suites • Grafical User Interfaces o Lowest Common Denominator User Interface (LCDUI) •Security o Trusted MIDlet Suites (MIDP 2.0) Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 10 CLDC Application Development Midlets are basic abstraction for application • Lifecycle managed by Application Management Software (AMS) on mobile Device • Deployed as Midlet Suites Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 11 MIDP Applications (2) MIDlet-Suites are running in a life cycle Installation, application cycle, de-installation Application cycle • MIDlets are in a state: Active, Paused, Destroyed • Paused in case of inactivity (break in case of other activities) • In state Destroyed: used resources are freed in case of ending the application new() destroyApp() pauseApp() startApp() destroyApp() Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 12 MIDlet – Basic Structure import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class Fligbookingsystem extends MIDlet implements javax.microedition.lcdui.CommandListener { // Constructor – invocation of method initialize public Flightbookingsystem() { initialize(); } public void startApp() { } public void pauseApp() { } public void destroyApp(boolean unconditional) { } } Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 13 Midlet Descriptions Manifest • Part of .jar file • Contains information about the application as attribute assignments • Mandatory attributes: o MIDlet-Name, MIDlet-Version, Midlet-URL, o Configuration and Profile requirements • Optional attributes: o MIDlet-Description, MIDlet-Icon Java Application Descriptors (JAD) • External of .jar file • Delivers information about the application before the installation on the device • Verification if available resources are sufficient, integrity of .jar and trustability of vendor • Contains Attributes of Manifest and • Signature of Midlet Suite, certificates of vendor and certification authorities, Access permissions Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 14 Midlet GUI No AWT supported in MIDP • Heterogeneous displays - small monochrome screens up to high resolution, high color screens • Lowest Common Denominator (LCDUI) Approach – weakest resources are reference Two variants for implementing graphical user interfaces • High-level API o Elements for abstract form-based UI elements (button, textbox, date field) o abstract UI elements mapped to native elements o High portability o Look-and-Feel depends on implementation - MIDlets can‘t manipulate visualization of UI elements (shape, color, font) - Simple user interactions handled internally – without notifying the MIDlet (e.g. navigation in dialog larger than display) - Abstraction of input devices and method • Low-level API o Basic graphic functions on Canvas addressing pixels (point, line, rectangle) o handling of physical input elements (e.g. phone buttons) o low level events (e.g. button pressed, button released) oUsed for Game-API Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 15 MIDP classes for GUI creation Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 16 LCDUI - Example Usage of High-Level API Set display to main menu during initialization of MIDlet For each MIDlet one display is assigned // This method initializes UI of the application. private void initialize() { getDisplay().setCurrent(get_mainMenu()); } // This method should return an instance of the display. public javax.microedition.lcdui.Display getDisplay () { return javax.microedition.lcdui.Display.getDisplay(this); } Dr. Thomas Springer Application Development - Lecture 9. Platforms - Java ME and OSGi 17 LCDUI – Example – Screens und Items public javax.microedition.lcdui.Form createInputForm() { Item items[]=new Item[5]; items[0] = new