Article permettant de mieux comprendre l'AMS :
comparaison du model des applications autonomes et Applets, MIDlets
PDAlets,
Xlets...
http://developers.sun.com/techtopics/mobility/midp/articles/models/
Article
Understanding J2ME Application Models
-------------------------------------
-------------------------------------
Supression
d'une MIDlet :
removes the MIDlet suite, including any push-registry
entries and record
stores created by any MIDlet in the suite.
Etats d'execution :
When a MIDlet begins execution, the AMS first calls the
zero-argument constructor to create a new instance of the MIDlet.
When the constructor returns,
the AMS places the MIDlet in the
Paused state.
To shift the
MIDlet to the
Active state the AMS calls the
midlet.startApp() method.
These transition methods give you the opportunities you need to
manage resources effectively. Typically, you'll use
startApp() to allocate record stores, network connections,
UI components, and such, and use
pauseApp() to release
these resources.
public class Etats extends MIDlet {
private boolean once = false;
Mandy() {
}
public void startApp() {
if ( once == false ) {
once = true;
// acquire one-time resources
}
// acquire "other" resources
}
public void pauseApp() {
// release "other" resources
}
public void destroyApp(boolean b)
{
}
}
A quel moment startApp est appellé et pourquoi pauseApp est appelé ? voir spec ...
--------------------------------------
Application
Management
Software
(AMS) :
-telechargement et installation des midlets
-Cycle de vie
-Etats d'execution d'une
MIDlet – creation, started, paused, and destroyed–
-L'AMS fourni le runtime environment
pour une
MIDlet.
-Gere la security, permissions et
fourni le system de classes et scheduling.
-L'AMS peut aussi gérer les
versions
L'Application Manager tourne sur le mobile, dépend du
terminal et est implémenté par le fabricant du terminal .
Pour mieux comprendre la gestion des threads dans MIDP :
A
system thread is any thread not started and
managed by an
application. In a MIDP environment, system threads are created by the
application management software (AMS) that controls MIDlet execution.
Each active application has at least one system thread and zero or more
application threads.
Article
----------------------------------------
Deux fichiers un JAD et
un JAR :
Une MIDlet suite est composée de Java
Application
Descriptor (JAD) et un un fichier Java Archive
(JAR) .
Le JAR peut contenir plusieurs Midlets, le nombre varie en fonction des
profiles des appareils
Exemple de fichier JAD :
MIDlet-Name: SunSamples
MIDlet-Version: 1.0
MIDlet-Vendor: Sun
Microsystems, Inc.
MicroEdition-Profile: MIDP-1.0
MicroEdition-Configuration:
CLDC-1.0
MIDlet-1: Sokoban,
/icons/Sokoban.gif,
example.sokoban.Sokoban
MIDlet-2: Tickets,
/icons/Auction.gif,
TicketAuction
MIDlet-3: Colors,
/icons/ColorChooser.gif, example.Color
MIDlet-4: Stock,
/icons/Stock.gif, example.stock.StockMIDlet
MIDlet-5: Tiles,
/icons/Tiles.gif, example.tiles.Tiles
MIDlet-6: ManyBalls,
/icons/ManyBalls.gif, example.ManyBalls
MIDlet-7: Sampler,
/icons/App.gif, Sampler
MIDlet-8: Properties,
/icons/App.gif, example.PropExample
MIDlet-9: HttpTest,
/icons/App.gif, example.HttpTest
------------------------------------------------------------
------------------------------------------------------------
Model de sécurité :
Au niveau du CLDC : sécurité bas niveau :
verificateur de byte code, haut niveau model du sandbox
Au niveau des applications MIDlelts suites :
-Les midlets sont vérifiés avant
d'etre inclues dans le JAR
-le programmeur ne peut pas redefinir un autre
classe loader
-Pas de JNI
-Les classes System ne peuvent pas etre redefinies
The manifest is a key component of the MIDP 2.0
signed-MIDlet model. In a signed MIDlet suite, attributes in the JAD
must agree with those in the manifest. While you can modify the JAD
file
attributes easily, you can't modify those in the signed MIDlet without
re-signing the MIDlet suite.
Conclusions :
-Pas possible de modifier l'environnement
d'execution
-Pas possible de modifier les midlets suite
-Pas possible de sortir de l'environnement
d'execution
-----------------------------------------
Installation :
Il exise deux facons d'installer une MIDlet
suite.
1-La première est directe
connexion par cable, infrarouge IrDA , or
Bluetooth entre le telephone et le PC de développement.
Cette méthode utilise l'Installateur d'applications du
constructeur de telephones sur le PC et un cable par exemple USB au
telephone.
Cette methode est certes pratique pour un appareil mais pas pour
l'installation de midlets sur des centaines de telephones.
2-La deuxième solution Over-the-air
provisioning (OTA) permet de
déployer des midlets sur des milliers d'appareils ( gestion
des versions
) .
Le principe , les MIDlets suites sont développées sur un
PC sur lequel il y a un émulateur ensuite elles sont
publiés sur un serveur WEB classique configuré avec le
bon type MIME .
Sur le telephone il existe un navigateur fourni par le constructeur a
partir du quel il suffit de specifier l'URL vers une page soit
WML, CHTML, XHTML , HTML
sur laquelle il y a un hyperlien vers le JAD le fichier jad est
installé par l'AMS comme sur le JAD il y a l'URL du
JAR il vas le charger et l'executer.
Voici les étapes :
- Le client envoi une requete HTTP GET au serveur pour
une URL donnée.
- Le serveur retourne une reponse HTTP avec le
fichier JAD dansle corps du message HTTP.
- Le client verifie la reponse HTTP et extrait les
attributs
MIDlet-Jar-File et MIDlet-Jar-Size
.
- Le client envoi une requete HTTP GET pour demander le
fichier JAR.
- Le serveur envoi une reponse HTTP avec le fichier JAR dans
le corps du message.
- Le client verifie le message et le fichier JAR.
- L'appareil demande a l'utilisateur de utiliser l'application et
la verifier.
Cette description ne tient pas compte de la
signature des MIDlet suites,
permissions, et push-registry.
Les problèmes possibles sont la taille du JAR , et les
MIME types qui doivent etre configurés sur le serveur WEB et
eventuellement sur le client.
pour tester l'utilisation d'un serveur web et d'un navigateur
configuré correctement permettant d'éxécuter les
JAR
dans l'émulateur via : OTA provisioning.
Le MIME type pour le
JAD text/vnd.sun.j2me.app-descriptor
Et pour le
JAR
application/java-archive.
******************************************************
MIDP 2.0 – New Features :
-->HTTPS, Comm, Datagram, SSL, Socket, ServerSocket
-->Remarque: Seul HTTP et
HTTPS sont obligatoires
-->Technologie Push :
permet de lancer une MIDlet en réponse a un message entrant
-->Over The Air (OTA)
provisioning
Présentation de J2ME WTK 2.2
|
J2ME Wireless Toolkit compatible
a
100% avec JTWI 1.0 Java Community Process (JCP):
Vous pouvez utiliser aussi CLDC 1.0 et MIDP 1.0 avec cette version.
J2ME Wireless Toolkit 2.2 inclu les nouveautés de Wireless Toolkit 2.1, comme la signature des MIDlet,
gestion des certificats, over-the-air (OTA) Provisioning emulation,
push registry emulation, et plus encore.
CLDC : CLDC 1.0 et CLDC 1.1
MIDP : MIDP 1.0 et MIDP 2.0
OP : WMA, MMAPI , M3G , Web services ...
--------------------------------------------
Installation J2ME WTK 2.2
Tout d'abord il faut avoir le JDK 1.4.2 deja installé sur le sytème (linux ou win):
http://java.sun.com/j2se/downloads.html
Ensuite : http://java.sun.com/products/j2mewtoolkit/download-2_2.html
Il vous faut un éditeur de code, en effet il n'y en a pas dans WTK2.2 ,
UltraEdit sur Win c'est tres bien ou si non il y en existe d'autres jEdit.
Un obfuscator de code "ProGuard " ou un autre
afin d'optimiser le code ( facultatif ).
---------------------------------------------------------
-Applications
J2ME en réseau:
--------------------------------
Rappel :
Le MIME type pour le
JAD text/vnd.sun.j2me.app-descriptor
Et pour le
JAR application/java-archive.
OTA Over The Air Provisioning :

Source : (
Simon Ritter http://www.sun.com/developers/evangcentral
)
Web Services Over The Air : EME Enabling the Mobile Enterprise
Solutions commerciales :
http://www.aenix.fr/solutions/mobility/Fiche_Mobilite_Aenix.pdf
Fournisseurs de MIDlets
suites via OTA
|
Utilisation de J2ME WTK 2.2 |
Etapes du
développement d'une MIDlet suite :
Rappel :
Il existe deux facons d'installer
et executer une midlet suite sur un
téléphone mobile :
La premiere consiste a
télécharger sur le portable une
midlet suite a partir d'un PC avec l'application de
téléchargement fournie par le constructeur du portable.
La deuxième
façon est plus apte pour "
la
publication de masse " elle consiste a publier la
MIDlet suite
sur le serveur OTA , le telephone se connecte et la
telecharger Over The Aire.
Le J2ME WTK 2.2 permet de simuler
OTA .
Comment utiliser le WTK 2.2 :
Il est possible de construire la MIDlet en mode
graphique (
GUI) a partir
du
Ktoolbar soit
en mode ligne de
commande (
Console).
--------------------------------------------
MIDP 2.0
Les etapes du development :
1) Editer la Midlet avec un éditeur de votre choix.
2) Compiler avec le javac du jdk
3) preverify
4) Package dans un fichier JAR
4.1) Signer le JAR ( MIDP
2.0 – Optional)
5) Creer le J2me Application Descriptor JAD
6) Publier la MIDlet suite
7) Installer OTA sur le
device ou emulator
----------------------------------
Etapes du développement d'une MIDlet :
Outils de Securité WTK 2.2 :
preferences -> Permissions
selection des API protegées pour etre placées sur le JAD
Signature du fichier JAR
Creer, supprime , ou importe les pairs de clés
Exporte les certificats sur le ME keystore
Signe les MIDlet suite (fichier JAR)
Certificate Manager (gestionnaire de certificats)
Importe les certificats
supprime les certificats
Etapes du développement
d'une "midlet suite" :
Etape 1 Design
: Il existe des outils UML :
Rational
décrit ici comment utiliser UML pour développer des
applications
embarquées mobiles. Un exemple, basé sur le
Mobile
information device
profile (MIDP), illustre le propos.
http://www.electronique.biz/Pdf/ELM200403010145064.pdf
Etape 2 Codage :
Il n'y a pas d'édieur dans J2ME WTK 2.2
import java.util.Date;
import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.Display; import javax.microedition.midlet.MIDlet;
public class DateTimeApp extends MIDlet {
Alert timeAlert;
public DateTimeApp() { timeAlert = new Alert("Alert!"); timeAlert.setString(new Date().toString()); }
public void startApp() { Display.getDisplay(this).setCurrent(timeAlert); }
public void pauseApp() { System.out.println("Dans pauseApp"); }
public void destroyApp(boolean unconditional) { System.out.println("Dans pauseApp"); } }
/*
C:\WTK22\lib WIN> javac -bootclasspath C:\WTK22\lib\cldcapi11.jar;C:\WTK22\lib\midpapi20.jar DateTimeApp.java
WIN>C:\WTK22\bin\preverify1.1.exe -classpath C:\WTK22\lib\cldcapi11.jar;C:\WTK22\lib\midpapi20.jar DateTimeApp WIN>jar -cvfm DateTimeApp.jar Manifest.mf *.class
WIN>C:\WTK22\bin\emulator.exe -Xdescriptor DateTimeApp.jad
*/
|
Etape 3 Compilation :
WIN>
javac -bootclasspath
C:\WTK22\lib\cldcapi11.jar;C:\WTK22\lib\midpapi20.jar DateTimeApp.java
Etape 4 preverify :
WIN>C:\WTK22\bin\preverify1.1.exe
-classpath C:\WTK22\lib\cldcapi11.jar;C:\WTK22\lib\midpapi20.jar
DateTimeApp
agéneré un repertoir Output dans le quel il a
deposé le fichier .class preverifié
Etape 5 package : creation de deux fichiers
JAR et un autre JAD
creation d'un manifeste pour inclure dans le JAR :
Nom du fichier Manifest.mf
:
MIDlet-Name:
DateTimeApp
MIDlet-Version: 1.0.0
MIDlet-Vendor: Sun
output > jar -cvfm
DateTimeApp.jar Manifest.mf *.class
Et enfin pour terminer l'etape 5 il nous faut le JAD :
Nom du fichier
DateTimeApp.jad :
MIDlet-1:
DateTimeApp, , DateTimeApp
MIDlet-Name: DateTimeApp
MIDlet-Version: 1.0.0
MIDlet-Vendor: Sun
MIDlet-Jar-URL: DateTimeApp.jar
MIDlet-Jar-Size: ??????????????????
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.1
Attention !!!!! si on ne specifie pas la propriete
MIDlet-Jar-Size:
com.sun.kvem.midletsuite.InvalidJadException:
Reason = 31
The jar size value in the Application Descriptor does not match the
real jar file size.
Etape 6
Tester :
WIN>C:\WTK22\bin\emulator.exe
-Xdescriptor DateTimeApp.jad
C:\WTK22\bin>emulator.exe
Syntax:
emulator [arguments] <Application>
Arguments are:
-classpath, -cp The class path for the VM
-D<property=value> Property definitions
-version
Display version information about the emulator
-help
Display list of valid arguments
-Xverbose[: allocation | gc | gcverbose | class | classverbose |
verifier | stackmaps |
bytecodes | calls |
callsverbose | frames
| stackchunks | exceptions |
events | threading |
monitors | networking | all
enable verbose output
-Xquery
Query options
-Xdebug
Use a remote debugger
-Xrunjdwp:[transport=<transport>,address=<address>,server=<y/n>
suspend=<y/n>]
Debugging options
-Xdevice:<device name>
Name of the device to be emulated
-Xdescriptor:<JAD file name>
The JAD file to be executed
-Xjam[:install=<JAD file url> | force | list | storageNames |
run=[<storage name> | <storage number>] |
remove=[<storage name> | <storage number> | all] |
transient=<JAD file url>]
Java Application Manager and support
for Over The Air provisioning (OTA)
-Xautotest:<JAD file url>
Run in autotest mode
-Xheapsize:<size> (e.g. 65536 or 128k or 1M)
specifies the VM heapsize
(overrides default value)
-Xprefs:<filename> Override preferences by properties in file
-Xnoagent
Supported for backwards compatibility
-Xdomain:<domain_name>
Set the MIDlet suite's security domain

Etape 7 déployer :
Configurer tout d'abord le serveur avec les Types MIME:
Jakarta/Tomcat
:
text/vnd.sun.j2me.app-descriptor
jad
application/java-archive
jar
Déploiemment d'une MIDlet suite
:

-----------------------------------------
Travaux pratiques :
Basés sur deux code camps chez SUN Microsystems :
http://objetjava.free.fr/ISTR/MIDP20/samplesLab2002/
http://objetjava.free.fr/ISTR/MIDP20/samplesLab2004/
EXEMPLES MIDP
1.0 :
http://objetjava.free.fr/ISTR/MIDP20/samplesLab2002/
Premier exemple
permettant de ce familliariser avec J2ME WTK 2.2 :
UI User Interfaces API de haut
niveau :
UI User Interfaces de bas niveau :
Persistence API
(RMS) :
Networking API :
HHTP,HTTPS, comm, Socket,ServerSocket, Datagram
---> KSOAP, XML-RPC (Web
Services)
http://www.javaworld.com/javaworld/jw-08-2002/jw-0823-wireless.html
---> JXTA-J2ME (JXME) exemple d'un chat avec
JXTA :
http://objetjava.free.fr/ISTR/MIDP20/TEST-CHAT-JXME/chat.html
----> Wireless messaging
with JXTA, Part 2: Implement JXTA-for-JMS
Learn how to use JXTA
technology to integrate thin Java 2 Platform,
Micro Edition (J2ME) clients into enterprise-scale messaging
applications by developing a set of classes that let you integrate J2ME
clients into JMS (Java Message Service) applications running on Java 2
Platform, Enterprise Edition (J2EE) servers.
http://www-128.ibm.com/developerworks/java/library/wi-jxta2/
Utilitaires API :
--------------------------------------------------------
EXEMPLES
MIDP 2.0 :
http://objetjava.free.fr/ISTR/MIDP20/samplesLab2004/
MIDP OTA provisioning : HTTPMIDlet.java
Signer les MIDlets suites :
HTTPS Connection SSL/TLS :
Push Registry :
Utilisation de CustomItem :
Game API :

Wirless Mobile API (WMA) :
Mobile Media API (MMAPI) :
Understanding MIDP 2.0's Security
Architecture :
http://developers.sun.com/techtopics/mobility/midp/articles/permissions/
Insecurity
of JAVA embedded environments
Barrer la route aux virus de
téléphones portables
http://www.hsc.fr/ressources/articles/virus_telephones_portables/index.html.en
http://www.hsc.fr/ressources/presentations/eurosec03/img1.html
Security and Trust Service
APIs (SATSA)
for J2ME– JSR 177
● Defines security elements within J2ME
● Functionality:
–
Three optional packages
● APDU-based communication for accessing Smart Cards
● Java Card RMI-based communication for accessing Smart Cards
● Trust services: PKI based user certificate management for user
authentication
–
Recommended practices:
● Access control policy for GSM/UMTS-compliant devices
● MIDP 2.0 based access control for Smart Card application
● Initially targeted at MIDP 2.0
● Specification lead: Sun
● Target FCS (RI and TCK): Q1 2004
//-----------------------------------------------------------------------------------------
Une autre facon de concevoir
le
plateforme J2ME :
Source :
http://www.ajile.com/products.htm
JXTA for
J2ME : JXME
2.0 Proxyless
|
The next release of JXME 2.0, is scheduled
for June 14th, 2005. This release will contain the new binding of JXME
proxy-less platform on CDC1.1 ( JSR218 ). A Beta test version of JXME 2.0
is now available.
How to get involved :
1. Build the beta from the CVS tag "JXME_2_0_BETA"
2. Build/Port/Rebuild your application with JXME 2.0 Beta.
3. Test with your application.
4. File bugs, propose patches, provide comments at discuss@jxme.jxta.org
5. If you want to have interactive discussion, drop in MyJxta
chat-room with MyJxta2 application or #jxta channel on
irc.freenode.net with your favorite IRC client
The JXME Core Team
New Features & Significant Changes
------------------------------------------------------------------------
* Full support of the core protocols
o TCP Transport
o Relay Transport
o Endpoint (including the router)
o Resolver
o RendezVous (ad-hoc, and infrastructure edge, including edge
side PeerView support)
o Discovery
o Edge side SRDI
o Pipe
* Simplified Programmatic Platform Configuration
o Singleton ConfigurationFactory provides the simplest way to
configure a peer
* Core Services
o Discovery Service
o Resolver Service
o RendezVous Service
o Pipe Service (Unicast, and Propagate)
* XML-Lite Support
* Support for all core Advertisements
* Support for all Core ID's
* Demo Application
o ChatDemo - J2SE interoperable group chat demo
o GroupDemo - J2SE interoperable group, and chat demo
Downloading and Installing
------------------------------------------------------------------------
You can download the dist zip from:
Sources : http://jxme.jxta.org/files/documents/38/207/jxme_2_0_beta.zip
Binaries : http://jxme.jxta.org/files/documents/38/208/jxme_2_0_beta_bin.zip
or alternatively directly access CVS :
http://jxme.jxta.org/servlets/ProjectSource#commandlinecvs
The instruction on how to build JXME can be found at:
http://jxme.jxta.org/buildJXME20proxyless.html
hamada@jxta.org
--
http://blogs.sun.com/roller/page/hamada
http://weblogs.java.net/blog/hamada
Inca X ME™
for MIDP and Jini™
technology
What is Inca X ME?
Inca X ME is a visual platform for creating and deploying Jini
services that can be accessed by either J2ME MIDP or J2SE Jini clients.
J2ME and MIDP integration
Inca X ME (micro
edition) adds the following options, which allow you to create MIDP
clients for your Jini services.
- MIDlet creation wizard
- Build MIDlet
- Run in emulator
- OTA provisioning
- Generate Jini service connector code
Inca X ME community release is free of charge,
click here to download X
ME
Source : http://www.incax.com/index.htm?http://www.incax.com/ee-service-browser.htm
Futur
de MIDP :
MIDP
3 JSR 271:
Mobile Information Device Profile 3 |
MIDP 3 :
JSR 271:
Mobile Information Device Profile 3
http://jcp.org/en/jsr/detail?id=271
This JSR will build upon the success of MIDP2 by enhancing the Profile
with the following additions/changes:
* Enable and specify proper behavior for MIDlets
on each of CLDC, CDC, and OSGi, for example:
o Enable multiple concurrent
MIDlets in one VM
o Specify proper firewalling,
runtime behaviors, and lifecycle management issues for MIDlets
o Enable background MIDlets
(e.g. UI-less)
o Enable ?auto-launched?
MIDlets (e.g. started at platform boot time)
o Enable inter-MIDlet
communications
* Enable shared libraries for MIDlets
* Tighten spec in all areas to improve
cross-device interoperability
* Increase functionality in all areas. E.g.
o Improve UI expressability
and extensibility
o Better support for devices
with larger displays
o Enable MIDlets to draw to
secondary display(s)
o Enable richer and higher
performance games
o Secure RMS stores
o Removable/remote RMS stores
o IPv6
o Multiple network interfaces
per device
* Specify standard ways for doing MIDlet provisioning
through other
means (e.g. OMA (SyncML) DM/DS, Bluetooth, removable media, MMS,
JSR-232, etc.)
* Extensive device capabilities query
* Localization & Internationalization (if
appropriate, integrating/augmenting JSR-238 as needed)
A key design goal of MIDP3 will be backward compatibility with MIDP2
content.
Sources , Ressources ,
références et bibliographie
|
Sources de référence
J2ME de SUN microsystems :
Sun Wireless Developer site:
http://wireless.java.sun.com
J2ME™ Platform homepage:
http://java.sun.com/j2me
Download the Sun J2ME Wireless Toolkit:
http://java.sun.com/products/j2mewtoolkit/download-2_2.html
Srikanth Raju's J2ME Page:
http://www.srikanthraju.com/j2me
Bill Day's J2ME Archive:
http://billday.com/j2me
Ce document est un
résumé basé sur les documents de SUN
microsystems :
http://java.sun.com/j2me/docs/index.html
http://developers.sun.com/
Autres ressources qui ont
étés utilisés dans cette presentation :
http://www.midlet.org
http://www-adele.imag.fr/%7Edonsez/cours/j2me.pdf
https://embeddedjava.dev.java.net/