You are on page 1of 18

ECE/CS 4984

Wireless and Mobile Systems Design


Spring 2003

Lecture 3
Middleware Fundamentals

Ing-Ray Chen
Copyright Reserved

Lecture Objectives
• Understand role of middleware
• Understand unique requirements of wireless and
mobile applications that middleware should address
• Understand mobile computational models and
functionality supported by various middleware
platforms

ECE/CS 4984, Spring 2003 2 Middleware: Fundamentals

1
Sources
• S. Helal, “Pervasive Java,” IEEE Pervasive
Computing, Vol. 1, No. 1, 2002, pp. 82-85 and Vol. 1,
No. 2, 2002, pp. 85-89.
• C. Neable, “The .NET Compact Framework,” IEEE
Pervasive Computing, Vol. 1, No. 3, 2002, pp. 84-87.
• A. Tripath, “Challenges in designing next-generation
middleware systems,” Communications on the ACM,
Vol. 45, No. 6, June 2002, pp. 39-42.
• http://www.wapforum.org/ - for WAP
• http://www.wapforum.com/ - for WAP
• F.P. Coyle, Wireless Web, Addison-Wesley, 2001.

ECE/CS 4984, Spring 2003 3 Middleware: Fundamentals

Agenda
• Characteristics of mobile wireless applications
• Role of middleware
• Desirable functionality of mobile middleware
• Overview of mobile middleware for application
developments
• Building your first iPAQ applications with GUI using
the following middleware:
! Sun’s Java Wireless Toolkit and Java 2 Micro Edition (J2ME)
! Microsoft’s Embedded Visual Tool (eVT) with application
wizards

ECE/CS 4984, Spring 2003 4 Middleware: Fundamentals

2
Middleware for Mobile Application
Developments
• Client-server computational model:
! Wireless application protocol (WAP)
! Wireless web access
" Server: Microsoft’s Mobile Internet Toolkit (MIT)
" Client: Microsoft’s eMbedded Visual Tool, Sun’s Java 2
Micro Edition, Microsoft’s .NET Compact Framework
• Peer-to-peer and ad hoc computational model:
! Intel/Microsoft Universal Plug and Play (UPnP)
! Jini/J2ME
! Service Location Protocol (SLP)
• Pervasive (or ubiquitous) computing
! Context-sensitive middleware: Transparency vs. awareness
• Data services in wireless mobile environments

ECE/CS 4984, Spring 2003 5 Middleware: Fundamentals

Characteristics of Wireless and Mobile


Applications
• Resource-poor on mobile devices
! Limited memory/buffer space (no disk typically)
! Small screen
! Low processing capability
! Low battery power
• Locations of mobile devices are subject to frequent
changes due to mobility
• Limited and fluctuated wireless bandwidth
• Unreliable communication
• Forced or voluntary disconnection
! Disconnected operations (read/write) require system supports
on data caching, pre-fetching and integration.
ECE/CS 4984, Spring 2003 6 Middleware: Fundamentals

3
Role of Middleware
• Middleware is defined as services
provided by a layer in between
the operating system and the Applications
applications
• Middleware provides an abstract User Profile and
interface that gives an application QoS Policy
developer a uniform view of low-
level operating systems and Middleware
networks Services and Protocols
• In wireless mobile environments,
middleware must be flexible to
enable adaptation to changes in Network and Operating
the underlying operating systems System Resources
and networks, and to changes in
application requirements
ECE/CS 4984, Spring 2003 7 Middleware: Fundamentals

Desirable Middleware Functionality


• Optimization – data compression
• Transformation – data format transformation to suit various
device specifications
! HTML pages to WML (for WAP 1.0) and vice versa
! SOAP/XML for web services: from XML to xHTML (for WAP 2.0 and
future i-mode) or cHTML (for existing i-mode phone devices)
• Security and privacy
• Mobility support
! Location transparency (ad hoc communication) vs. awareness
• Service discovery support
• Disconnected operation support
• Context-aware adaptability
! Status of the host device, the user, the surrounding environment,
and the interactions between the host device and other devices
• Platform independence – same program can be downloaded and
run over a wide variety of devices and platforms
ECE/CS 4984, Spring 2003 8 Middleware: Fundamentals

4
WAP and Wireless Web Access
• Data transformation
! The WAP gateway performs
data transformation between
WML (or XHTML) and HTML
• Data compression Encoded Encoded
! Technique are used for dealing request Response
with images/graphics (WML)
• Adaptability
! User profile and device WAP Gateway
characteristics are stored in the
WAP gateway
• Security Request Response
! SEP (Secure Enterprise Proxy (e.g., HTTP) (e.g., HTML)
using 128-bit encryption) in
WAP 1.2
• Service discovery and mobility
support Web
! WAP’s “walled garden” – WAP
Server
gateways are provided by ISP
such as AOL

ECE/CS 4984, Spring 2003 9 Middleware: Fundamentals

J2ME – Java for Hand-Held Devices


• Platform independence
! The same byte-code Java application (e.g.,
a MIDlet created based on the MIDP API)
can be downloaded and executed by all
java-enabled devices
! Pre-verification at compile time to verify if Byte-code Java Applications
an application can run with J2ME’s KVM (e.g., MIDlets) dynamically
• Data compression delivered to mobile devices
! A MIDlet application comes with a JAD
metafile containing instructions for
uncompressing the application in
compressed JAR (Java Archive) format
• Security
! Java Card technology using public key
! A downloaded Java program must have a
legal digital signature to execute
• Service discovery
! JINI based on Java service objects

ECE/CS 4984, Spring 2003 10 Middleware: Fundamentals

5
J2ME Architecture

• Profile layer: minimum


set of APIs available for
the specified underlying
configuration

Personal
• Configuration layer:
profile defining a minimum set
of JVM features and core
Mobile Information Java class libraries
Foundation profile
Device (MID) profile available on a particular
category of devices
Connected Device
Configuration
Connected, Limited
Device Configuration
• JVM layer (bottom layer)

C virtual machine Kilobyte Virtual Machine

ECE/CS 4984, Spring 2003 11 Middleware: Fundamentals

Setup J2ME/MIDP Runtime Environment


on iPAQ/Pocket PC
• Sun Microsystems has J2ME applications
released JVM with MIDP for
PDAs (with PalmOS), but is (MIDP)
not continuing development
of JVM for PocketPC (with
Windows CE). ME4SE
• To setup the J2ME (including J2ME emulator)
environment on iPAQ/Pocket
PC, you need to first install
the Jeode JVM that provides Jeode JVM
Personal Java 1.2 support.
(Personal Java)
• Then, a software package
called “me4se” that includes
a simulator for MIDP devices iPAQ/Pocket
based on Personal Java
needs to be installed. on Windows CE

ECE/CS 4984, Spring 2003 12 Middleware: Fundamentals

6
HelloJ2ME – Hello World MIDlet
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HelloJ2ME extends MIDlet implements CommandListener


{
private Display display; private TextField tfHello;
private Command cmExit; private Form fmMain;
public HelloJ2ME()
{
//Get a handle to the display object
display = Display.getDisplay(this);
//Create the main form
fmMain = new Form("HelloJ2ME");
//Create the exit command button
cmExit = new Command("Exit", Command.SCREEN,1);
//Create a single-line text field 15 characters long with the label “ECE/CS 4984"
tfHello = new TextField(“ECE/CS 4984","Hello World!",15,TextField.ANY);
//Add the components to the form and set up the command listener
fmMain.addCommand(cmExit); fmMain.append(tfHello);
fmMain.setCommandListener(this);
}
ECE/CS 4984, Spring 2003 13 Middleware: Fundamentals

HelloJ2ME – Hello World MIDlet (cont.)


public void startApp()
{
//set fmMain as the active object
display.setCurrent(fmMain);
}
public void pauseApp() { /*app is being paused*/ }
public void destroyApp(boolean unconditional) { /*app is being ended*/ }
public void commandAction(Command c, Displayable s)
{
//click on the Exit button
if (c == cmExit)
{
//destroyApp must be called manually
destroyApp(false);
//ask the manager to end the app
notifyDestroyed();
}
}}
ECE/CS 4984, Spring 2003 14 Middleware: Fundamentals

7
Build your First J2ME MIDlet Application
using Sun’s J2ME Wireless Toolkit
• Create a new project
“HelloJ2ME”
• Create a Java source file
using Notepad and put
the file under
C:\WTK104\apps\HelloJ2
ME\src
• Build HelloJ2ME
• Run HelloJ2ME on a
selected emulator
• Input: Can use the
keyboard on the PC
ECE/CS 4984, Spring 2003 15 Middleware: Fundamentals

Deploy and Run your First J2ME MIDlet


Application on an iPAQ
• To deploy the MIDlet onto an iPAQ,
package the MIDlet first
! Create a MIDlet package from
Project -> Package -> Create
Package using Sun’s J2ME
Wireless Toolkit
• Copy HelloJ2ME.jar created to the
iPAQ’s /Windows folder
• On the iPAQ, execute Jeode with
appropriate program arguments:
! -cp
/Windows/me4se.jar;/Windows/png
.jar;/Windows/HelloJ2ME.jar
org.me4se.MIDletRunner
HelloJ2ME
• Input: use stylus on the iPAQ or
use keyboard on a “Remote
Display Control” PC host

ECE/CS 4984, Spring 2003 16 Middleware: Fundamentals

8
Microsoft’s .NET Compact Framework

• .NET CF (as part of .NET Framework) is based on


Microsoft’s Common Language Infrastructure (CLI)
standard
! Source code and complied binaries (in MSIL - Microsoft
Intermediate Language) can run across CLI-based
heterogeneous devices
! Microsoft’s common language runtime (CLR) is sort of like
Sun’s JVM for the reason of platform independence
• .NET CF allows smart devices to easily access
remote (server) data using the Internet standard
protocols such as XML-based SOAP and WSDL (Web
Service Description Language)
! XML Web services is central to Microsoft .NET framework
ECE/CS 4984, Spring 2003 17 Middleware: Fundamentals

.NET CF Architecture for dealing with


Device Heterogeneity
• On top of the host operating system
is the platform adaptation layer (PAL)
tailored for a specific platform
Applications
• Build on top of the PAL is the CLR
that runs MSIL and uses Just-in-time .NET
Windows forms, XML/SOAP
(JIT) compiler to convert MSIL to CF
web services, ADO.NET
native code
• On top of CLR is a set of CLI- CLI-compliant
compliant base class libraries that Base Classes Compiled
provide building block functionality Into
for all applications including basic CLR execution
MSIL
file I/O, networking and XML handling
• Available to applications in .NET CF
Platform Adaptation
are: windows forms library for JIT
windows CE, XML web services, and Layer (PAL) to
ADO.NET (the remote data-access native
technology available in Microsoft’s Host Operating System code
.NET framework)

ECE/CS 4984, Spring 2003 18 Middleware: Fundamentals

9
Mobile Data Access in .NET CF

• ADO .NET (Active Data Object) lets


mobile applications access Microsoft
SQL Server 2000 on remote servers or
SQL Server CE
access a SQL Server CE locally on the
(CSI)
device
• Disconnected mode support: SQL caching synchronization
Server CE lets applications cache Internet
large volumes of data (tens of Internet Information
MBytes), read, and update in Server
disconnected mode (SSI)
• SQL Server CE provides
synchronization mechanisms for
changes made upon reconnection SQL Server

ECE/CS 4984, Spring 2003 19 Middleware: Fundamentals

Middleware Functionality in .NET CF


• Platform independence
! The same .NET MSIL-code application
can be downloaded and executed by CLR
enabled devices
• Optimization MSIL-code .NET Applications
! Proxy protocols can be designed to can be dynamically
delivered to CLR-enabled
optimize performance using techniques
such as forms differencing mobile devices

• Data Transformation: XML to HTML,


XHTML, cHTML, WML is transformed
automatically in .NET technology (at the
server end)
• Disconnected operations
! Data caching, pre-fetching and
synchronization available using Microsoft
SQL server 2000 on the remote server
and SQL CE on the local device
ECE/CS 4984, Spring 2003 20 Middleware: Fundamentals

10
User Interface Design on Pocket PC
• User Interface design constraints
! A small, portrait-oriented, touch-sensitive screen
! User input with an input panel and the stylus (pointer)
" Single-tap: opening an item
" A tap and hold: displaying a pop-up menu or a tip
• Normally no “Close” button is necessary:
! Pocket PC automatically closes idle applications as more
memory is needed
• Normally no “Save” button is necessary:
! The pocket PC relies on application’s “autosave” to retain
user data, so no data loss would occur when switching
applications or powering down

ECE/CS 4984, Spring 2003 21 Middleware: Fundamentals

User Interface Design on Pocket PC


(cont.)
• System-level and
Start
navigation actions at
the top of the screen Navigation
! Start Menu, Navigation bar
Bar (top)
• Application-level and
editing actions at the
bottom of the screen
! Menu bar (also called
command bar)
! Input Panel Button: far
side of the command bar
Command
(menu) bar Input
Keyboard (on/off)
option
ECE/CS 4984, Spring 2003 22 Middleware: Fundamentals

11
Pocket PC User Interface Controls
• Buttons • Combo boxes
• Check boxes • Up/Down controls
• Option buttons • Date/Time pickers
• Command bars • MonthCal controls
• Tool bars • List views
• ToolTips • Header controls
• Menus • Tree views
• Pop-up menus • Group Line Separators
• Message boxes • Scroll bars
• Property sheets • Sliders
• Tabs • Status bars
• Text boxes • Progress bars
• List boxes
ECE/CS 4984, Spring 2003 23 Middleware: Fundamentals

Microsoft’s Embedded Visual Tool


• Microsoft’s Embedded Visual Tool is an integrated
development environment (IDE) for creating mobile
applications and system components
• A wide range of processors and Windows CE based
platforms are supported with emulation:
! Pocket PC
! Palm-size PC
! Handheld PC
• Programming languages supported include
eMbedded Visual Basic® and eMbedded Visual C++®

ECE/CS 4984, Spring 2003 24 Middleware: Fundamentals

12
Build Your First Pocket PC Application
with GUI using Microsoft’s eVC++ (1)
• Building a Pocket PC application with GUI:
! Use the eVC++ IDE Application Wizard to create the shell
of your application instead of from scratch
! Use the Resource Editor to create menus and resources,
such as dialog boxes
! Use “drag and drop” to put UI controls in your
application and fill in the event code for control actions
• Running your GUI application
! Select project configuration
" Run/debug in the emulation environment
" Release/deploy the project to Pocket PC
! Set the active WCE configuration
" Choose platform/device: WIN32 WCE/Pocket PC
ECE/CS 4984, Spring 2003 25 Middleware: Fundamentals

Build Your First Pocket PC Application


with GUI using Microsoft’s eVC++ (2)
• Create a
project
from
eVC++
• Select the
MFC
AppWizard
(exe) to
create
executable From Pocket PC SDK
files

ECE/CS 4984, Spring 2003 26 Middleware: Fundamentals

13
Build Your First Pocket PC Application
with GUI using Microsoft’s eVC++ (3)
• Types of
Applications:
! Single
Document with
Doc List
! Single
Document
Interface (SDI)
! Dialog based
• All are forms-
based
! Dialog-based
is the simplest

ECE/CS 4984, Spring 2003 27 Middleware: Fundamentals

Build Your First Pocket PC Application


with GUI using Microsoft’s eVC++ (4)
• A single document
interface (SDI), forms-
based application allows
only one instance of a
particular form to run at a
time. However, it is
possible to run different
forms at the same time by
selecting a new form from
the “New” command
! “New”, “Edit”, “Tools”
menus in the menu bar are
created automatically
ECE/CS 4984, Spring 2003 28 Middleware: Fundamentals

14
Build Your First Pocket PC Application
with GUI using Microsoft’s eVC++ (5)
• When a single document with
Doc List application is created,
a Doc List control is also added
to the UI
• All Folders also lets you see
files that are saved in the root
of the My Documents folder.
The folders shown in the menu
are subfolders of My
Documents
• “New”, and “Tools” menus are
created automatically in the
menu bar by the AppWizard
! The developer then insert code
into event handler routines
ECE/CS 4984, Spring 2003 29 Middleware: Fundamentals

Build Your First Pocket PC Application


with GUI using Microsoft’s eVC++ (6)
• Use the “drag
and drop”
feature to add text
UI controls to
button
the main
dialog of your
application
• Change
properties of
controls:
! Caption
! ID
ECE/CS 4984, Spring 2003 30 Middleware: Fundamentals

15
Build Your First Pocket PC Application
with GUI using Microsoft’s eVC++ (7)
• Add event-
handling code
to UI controls
in response to
input, e.g., to button
a text control,
or to a button
control, etc.
• Double click
on a control to
bring up the
code insertion
interface

ECE/CS 4984, Spring 2003 31 Middleware: Fundamentals

eVC++ Example – A Standalone


Stock Quote Client
void CLab3Dlg::OnGo()
{
CListBox * resList = (CListBox *)GetDlgItem(IDC_RESULTS); // display in a listbox
CEdit * symbol = (CEdit *)GetDlgItem(IDC_SYMBOL ); // user input in an edit box
CString strSymbol ; // hold stock entered by the user
char buf[40]; // hold randomly generated stock quote

// get the stock symbol entered by user from the edit box
symbol->GetWindowText(strSymbol) ;
// generate a stock price in the range of 20*(1+[-10%,10%])
sprintf( buf, "%6f", 20 *(1 + (rand() % 20 -10)/100.0));
// insert the result into the list box for display
resList->InsertString(0, strSymbol + “\t” + CString(buf) );
}
ECE/CS 4984, Spring 2003 32 Middleware: Fundamentals

16
Debugging and Deployment in eVC++

• Applications can be debugged locally using an


emulator and then deployed remotely on the device
• Local debugging
! Run the application on an emulator

• deployment
! Deploy and run the application on the iPAQ

ECE/CS 4984, Spring 2003 33 Middleware: Fundamentals

Local Debugging on Emulation vs.


Remote Execution on Device
Emulator VS. iPAQ

ECE/CS 4984, Spring 2003 34 Middleware: Fundamentals

17
J2ME Code for the Standalone Stock
Quote Application
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
import javax.microedition.io.*;

public class lab3_j2me extends MIDlet implements CommandListener {


Form mainForm = new Form ("StockQuotes");
TextField symbolField = new TextField ("Symbol","A001",5, TextField.ANY);
StringItem resultItem = new StringItem ("", "");
Command getCommand=new Command ("Get", Command.SCREEN, 1);

public lab3_j2me () {
mainForm.append (symbolField);
mainForm.append (resultItem);
mainForm.addCommand (getCommand);
mainForm.setCommandListener (this);
}

ECE/CS 4984, Spring 2003 35 Middleware: Fundamentals

J2ME Code for the Standalone Stock


Quote Application (Cont.)
public void startApp ()
{ Display.getDisplay (this).setCurrent (mainForm); }

public void pauseApp () { }

public void destroyApp (boolean unconditional) { }

public void commandAction (Command c, Displayable d)


{
// build request string
String symbol = symbolField.getString ();
resultItem.setLabel ("Price of " + symbol);
resultItem.setText (" " + Integer.toString((int)symbol.charAt(0)) );
}
}

ECE/CS 4984, Spring 2003 36 Middleware: Fundamentals

18

You might also like