0% found this document useful (0 votes)
25 views

JADETutorial Programming 240105 155442

This document provides an overview of the JADE platform and framework for developing multi-agent systems. It describes how to create agent classes and behaviors in JADE, and how agents communicate and coordinate their activities.

Uploaded by

Ko Sai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

JADETutorial Programming 240105 155442

This document provides an overview of the JADE platform and framework for developing multi-agent systems. It describes how to create agent classes and behaviors in JADE, and how agents communicate and coordinate their activities.

Uploaded by

Ko Sai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Giovanni Caire

JADE Board Technical Leader


[email protected]

JADE Tutorial for beginners

organized by the JADE Board


The Hague, 12th Oct. 2004
Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS
– Mobility

CONFIDENTIAL – All rights reserved


– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


The HalloWorld agent

• A type of agent is created by extending the jade.core.Agent


class and redefining the setup() method.
• Each Agent instance is identified by an AID (jade.core.AID).
– An AID is composed of a unique name plus some addresses
– An agent can retrieve its AID through the getAID() method of
the Agent class

import jade.core.Agent;

CONFIDENTIAL – All rights reserved


public class HalloWorldAgent extends Agent {

protected void setup() {


System.out.println(“Hallo World! my name is “+getAID().getName());
}
}

The Hague, 12/10/04


Local names, GUID and addresses

• Agent names are of the form <local-name>@<platform-name>


• The complete name of an agent must be globally unique.
• The default platform name is <main-host>:<main-port>/JADE
• The platform name can be set using the –name option
• Within a single JADE platform agents are referred through their
names only.
• Given the name of an agent its AID can be created as
– AID id = new AID(localname, AID.ISLOCALNAME);

CONFIDENTIAL – All rights reserved


– AID id = new AID(name, AID.ISGUID);
• The addresses included in an AID are those of the platform MTPs
and are ONLY used in communication between agents living on
different FIPA platforms

The Hague, 12/10/04


Passing arguments to an agent

• It is possible to pass arguments to an agent


– java jade.Boot .... a:myPackage.MyAgent(arg1 arg2)
– The agent can retrieve its arguments through the
getArguments() method of the Agent class

protected void setup() {


System.out.println(“Hallo World! my name is “+getAID().getName());
Object[] args = getArguments();
if (args != null) {

CONFIDENTIAL – All rights reserved


System.out.println(“My arguments are:”);
for (int i = 0; i < args.length; ++i) {
System.out.println(“- ”+args[i]);
}
}
}

The Hague, 12/10/04


Agent termination
• An agent terminates when its doDelete() method is called.
• On termination the agent’s takeDown() method is invoked
(intended to include clean-up operations).

protected void setup() {


System.out.println(“Hallo World! my name is “+getAID().getName());
Object[] args = getArguments();
if (args != null) {
System.out.println(“My arguments are:”);
for (int i = 0; i < args.length; ++i) {
System.out.println(“- ”+args[i]);

CONFIDENTIAL – All rights reserved


}
}
doDelete();
}

protected void takeDown() {


System.out.println(“Bye...”);
}

The Hague, 12/10/04


Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS
– Mobility

CONFIDENTIAL – All rights reserved


– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


The Behaviour class

• The actual job that an agent does is typically carried out within
“behaviours”
• Behaviours are created by extending the
jade.core.behaviours.Behaviour class
• To make an agent execute a task it is sufficient to create an
instance of the corresponding Behaviour subclass and call the
addBehaviour() method of the Agent class.
• Each Behaviour subclass must implement

CONFIDENTIAL – All rights reserved


– public void action(): what the behaviour actually does
– public boolean done(): Whether the behaviour is finished

The Hague, 12/10/04


Behaviour scheduling and execution

• An agent can execute several behaviours in parallel, however,


behaviour scheduling is not preemptive, but cooperative and
everything occurs within a single Java Thread

CONFIDENTIAL – All rights reserved


Behaviour switch occurs only when
the action() method of the currently
scheduled behaviour returns.

The Hague, 12/10/04


The agent
setup()
- Initializations

execution model
- Addition of initial
behaviours

Agent has been killed YES


(doDelete() method
called)?

NO

Get the next behaviour from


the pool of active behaviours

b.action()
Highlighted in red - Agent “life” (execution
the methods that of behaviours)
programmers have
to/can implement NO

CONFIDENTIAL – All rights reserved


b.done()?

YES

Remove currentBehaviour from


the pool of active behaviours

takeDown() - Clean-up operations

The Hague, 12/10/04


Behaviour types
• “One shot” behaviours.
– Complete immediately and their action() method is executed
only once.
– Their done() method simply returns true.
– jade.core.behaviours.OneShotBehaviour class
• “Cyclic” behaviours.
– Never complete and their action() method executes the same
operation each time it is invoked
– Their done() method simply returns false.

CONFIDENTIAL – All rights reserved


– jade.core.behaviours.CyclicBehaviour class
• “Complex” behaviours.
– Embed a state and execute in their action() method different
operation depending on their state.
– Complete when a given condition is met.

The Hague, 12/10/04


Scheduling operations at given points in
time
• JADE provides two ready-made classes by means of which it is
possible to easily implement behaviours that execute certain
operations at given points in time
• WakerBehaviour
– The action() and done() method are already implemented so
that the onWake() method (to be implemented by subclasses) is
executed after a given timeout
– After that execution the behaviour completes.
• TickerBehaviour

CONFIDENTIAL – All rights reserved


– The action() and done() method are already implemented so
that the onTick() (to be implemented by subclasses) method is
executed periodically with a given period
– The behaviour runs forever unless its stop() method is
executed.

The Hague, 12/10/04


More about behaviours

• The onStart() method of the Behaviour class is invoked only


once before the first execution of the action() method. Suited for
operations that must occur at the beginning of the behaviour
• The onEnd() method of the Behaviour class is invoked only once
after the done() method returns true. Suited for operations that
must occur at the end of the behaviour
• Each behaviour has a pointer to the agent executing it: the
protected member variable myAgent

CONFIDENTIAL – All rights reserved


• The removeBehaviour() method of the Agent class can be used
to remove a behaviour from the agent pool of behaviours. The
onEnd() method is not called.
• When the pool of active behaviours of an agent is empty the agent
enters the IDLE state and its thread goes to sleep

The Hague, 12/10/04


Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS
– Mobility

CONFIDENTIAL – All rights reserved


– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


The communication model

• Based on asynchronous message passing


• Message format defined by the ACL language (FIPA)

Get the message


Prepare the from the message
message to A2 queue and process it

A1 A2

CONFIDENTIAL – All rights reserved


Send the message Post the message in
A2’s message queue

Distributed JADE runtime

The Hague, 12/10/04


The ACLMessage class

• Messages exchanged by agents are instances of the


jade.lang.acl.ACLMessage class.
• Provide accessor methods to get and set all the fields defined by
the ACL language
– get/setPerformative();
– get/setSender();
– add/getAllReceiver();
– get/setLanguage();

CONFIDENTIAL – All rights reserved


– get/setOntology();
– get/setContent();
– ....

The Hague, 12/10/04


Sending and receiving messages
• Sending a message is as simple as creating an ACLMessage object
and calling the send() method of the Agent class

ACLMessage msg = new ACLMessage(ACLMessage.INFORM);


msg.addReceiver(new AID(“Peter”, AID.ISLOCALNAME));
msg.setLanguage(“English”);
msg.setOntology(“Weather-Forecast-Ontology”);
msg.setContent(“Today it’s raining”);
send(msg);

• Reading messages from the private message queue is


accomplished through the receive() method of the Agent class.

CONFIDENTIAL – All rights reserved


ACLMessage msg = receive();
if (msg != null) {
// Process the message
}

The Hague, 12/10/04


Blocking a behaviour waiting for a message
• A behaviour that processes incoming messages does not know exactly
when a message will arrive Æ It should poll the message queue by
continuously calling myAgent.receive().
• This of course would completely waste the CPU time.
• The block() method of the Behaviour class removes a behaviour from
the agent pool and puts it in a blocked state (it’s not a blocking call!!).
• Each time a message is received all blocked behaviours are inserted back
in the agent pool and have a chance to read and process the message.
public void action() {
ACLMessage msg = myAgent.receive();

CONFIDENTIAL – All rights reserved


if (msg != null) { This is the strongly
// Process the message recommended
} pattern to receive
else { messages within a
block(); behaviour
}
}

The Hague, 12/10/04


Selective reading from the message queue
• The receive() method returns the first message in the message queue
and removes it.
• If there are two (or more) behaviours receiving messages, one may “steal”
a message that the other one was interested in.
• To avoid this it is possible to read only messages with certain
characteristics (e.g. whose sender is agent “Peter”) specifying a
jade.lang.acl.MessageTemplate parameter in the receive() method.

MessageTemplate tpl = MessageTemplate.MatchOntology(“Test-Ontology”);

public void action() {

CONFIDENTIAL – All rights reserved


ACLMessage msg = myAgent.receive(tpl);
if (msg != null) {
// Process the message
}
else {
block();
}
}

The Hague, 12/10/04


Receiving messages in blocking mode
• The Agent class also provides the blockingReceive() method
that returns only when there is a message in the message queue.
• There are overloaded versions that accept a MessageTemplate
(the method returns only when there is a message matching the
template) and or a timeout (if it expires the method returns null).
• Since it is a blocking call it is “dangerous” to use
blockingReceive() within a behaviour. In fact no other behaviour
can run until blockingReceive() returns.

- Use receive() + Behaviour.block() to

CONFIDENTIAL – All rights reserved


receive messages within behaviours.
- Use blockingReceive() to receive messages
within the agent setup() and takeDown()
methods.

The Hague, 12/10/04


Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS
– Mobility

CONFIDENTIAL – All rights reserved


– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


The yellow pages service

A1: - serviceX
A1 - serviceY A4

A2: - serviceZ
Publish
Search for
provided
A3: - serviceW agents
services - serviceK providing the
- serviceH
A2 required
services A5
Yellow Pages service

CONFIDENTIAL – All rights reserved


DF

A3 Exploit required A6
service

The Hague, 12/10/04


Interacting with the DF Agent

• The DF is an agent and as such it communicates using ACL


• The ontology and language that the DF “understands” are specified
by FIPA Æ It is possible to search/register to a DF agent of a
remote platform.
• The jade.domain.DFService class provides static utility
methods that facilitate the interactions with the DF
– register();
– modify();

CONFIDENTIAL – All rights reserved


– deregister();
– search();
• The JADE DF also supports a subscription mechanism

The Hague, 12/10/04


DFDescription format
• When an agent registers with the DF it must provide a description
(implemented by the
jade.domain.FIPAAgentManagement.DFAgentDescription
class) basically composed of
– The agent AID
– A collection of service descriptions (implemented by the class
ServiceDescription). This, on its turn, includes:
• The service type (e.g. “Weather forecast”);
• The service name (e.g. “Meteo-1”);
• The languages, ontologies and interaction protocols that must be

CONFIDENTIAL – All rights reserved


known to exploit the service
• A collection of service-specific properties in the form key-value pair
• When an agent searches/subscribes to the DF it must specify
another DFAgentDescription that is used as a template

The Hague, 12/10/04


Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS

CONFIDENTIAL – All rights reserved


– Mobility
– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS

CONFIDENTIAL – All rights reserved


– Mobility
– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


JADE support for handling content
expressions
Inside an ACLMessage Inside the agent code

Information
Information
represented as a string or a JADE
represented as Java objects
sequence of bytes support for
(EASY TO HANDLE)
(EASY TO TRANSFER) handling
content class Person {
expressions private String name;

CONFIDENTIAL – All rights reserved


int age;
(Person :name john :age 35) public String getName();
public void setName(String n);
public int getAge();
public void setAgen(int a);
}

The Hague, 12/10/04


How it works
• Creating the Ontology (domain specific)
– Defining the schemas ontology elements
– Defining the corresponding Java classes
• Handling content expressions as Java objects
• Using the ContentManager to fill and parse message
contents
Concept Predicate
Person john = new Person(“John”, 35);
Person bill = new Person(“Bill”, 67);

CONFIDENTIAL – All rights reserved


FatherOf f = new FatherOf();
f.setFather(bill);
+children f.addChildren(john);
Person 1..* FatherOf
1
+father
(father-of (person :name Bill :age 67) (set (person :name John :age 35) ) )

The Hague, 12/10/04


Creating ontologies with Protege`

Beangenerator
Predefined
Predefined
base
baseelements
elements

CONFIDENTIAL – All rights reserved


class
classCar
Carextends
extendsConcept
Concept{ {
private
privateint
intyear;
year;
private
privateString
Stringtype;
type;
.....
.....
}}

The Hague, 12/10/04


Documentation

• A complete tutorial is available on the JADE site:


• http://jade.tilab.com/doc/CLOntoSupport.pdf
• API documentation (javadoc): jade.content package and
subpackages
• Sample code: examples.content package in the examples
included in the JADE distribution.

CONFIDENTIAL – All rights reserved


The Hague, 12/10/04
Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS

CONFIDENTIAL – All rights reserved


– Mobility
– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


Interaction protocols
• Having a standard set of types of messages (INFORM, REQUEST,
PROPOSE ....) allows specifying predefined sequences of
messages exchanged by agents during a conversations.
• These are known as Interaction Protocols
FIPA-Subscribe Protocol

Initiator Responder

SUBSCRIBE

CONFIDENTIAL – All rights reserved


REFUSE
[refused]

[AGREE]

[agreed]

INFORM 0-n
[agreed]
FAILURE
[failed]
The Hague, 12/10/04
Support for interaction protocols

• The jade.proto package contains behaviours for both the initiator


and responder role in the most common interaction protocol:
– FIPA-request (AchieveREInitiator/Responder)
– FIPA-Contract-Net (ContractNetInitiator/Responder)
– FIPA-Subscribe (SubscriptionInitiator/Responder)
• All these classes automatically handle
– the flow of messages checking that it is compliant to the
protocol

CONFIDENTIAL – All rights reserved


– The timeouts (if any)
• They provide callback methods that should be redefined to take the
necessary actions when e.g. a message is received or a timeout
expires.

The Hague, 12/10/04


Documentation

• Chapter 3.5 in the Programmers guide included in the JADE


distribution provides a detailed explanation of the interaction
protocol support
• API documentation (javadoc): jade.proto package
• Sample code: examples.protocols package in the examples
included in the JADE distribution.

CONFIDENTIAL – All rights reserved


The Hague, 12/10/04
Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS

CONFIDENTIAL – All rights reserved


– Mobility
– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


Working with the AMS

• The AMS (Agent Management System) represents the authority in a


JADE platform.
• All platform management actions (creating/killing agents, killing
containers...) are under the control of the AMS.
• Other agents can request the AMS to perform these actions by
using
– The fipa-request interaction protocol
– The SL language

CONFIDENTIAL – All rights reserved


– The JADE-Management ontology and related actions
• The AID of the AMS can be retrieved through the getAMS() method
of the Agent class

The Hague, 12/10/04


Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS
– Mobility

CONFIDENTIAL – All rights reserved


– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


Mobility
• JADE supports “hard mobility” i.e. mobility of status and code.
– Status: an agent can i) stop its execution on the local container
ii) move to a remote container (likely on a different host) and iii)
restart its execution there from the exact point where it was
interrupted.
– Code: If the code of the moving agent is not available on the
destination container it is automatically retrieved on demand.
• In order to be able to move, an agent must be Serializable
• Mobility can be

CONFIDENTIAL – All rights reserved


– self-initiated through the doMove() method of the Agent class
– forced by the AMS (following a request from another agent)
• Besides mobility also agent cloning is available (method
doClone())

The Hague, 12/10/04


Documentation

• Chapter 3.7 in the Programmers guide included in the JADE


distribution provides a detailed explanation of the mobility support
• API documentation (javadoc): jade.core.Agent class,
jade.core.Location interface and jade.domain.mobility
package
• Sample code: examples.mobile package in the examples
included in the JADE distribution.

CONFIDENTIAL – All rights reserved


The Hague, 12/10/04
Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS

CONFIDENTIAL – All rights reserved


– Mobility
– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


Security

• Distributed as an add-on
• Examples of potential threats:
– A malicious agent can request the AMS to kill another agent
– A malicious agent can request the AMS to shutdown the platform
– A malicious entity can sniff or tamper sensible information
included in an ACLMessage
• Prevents the above threats by providing support for:
– Authentication and authorization

CONFIDENTIAL – All rights reserved


– End-to-end message integrity and confidentiality
• Based on JAAS
• Further evolutions are expected Æ Comments and contributions are
Welcome

The Hague, 12/10/04


JADE as a multi-user environment

User John
--- --- User Alice --- ---
Alice XYZ
----- - ----- -
Bob KHJ
-- --
John QPO
policy file
Owns Main policy file
A password file

Owns A A
Container 2

CONFIDENTIAL – All rights reserved


Main Container
A A A

Owns
Container 1 --- ---
User Bob
----- -
--
policy file
The Hague, 12/10/04
Policy file

• grant principal jade.security.Name "alice" {


permission jade.security.PlatformPermission "", "create";
permission jade.security.ContainerPermission "", "create";
permission jade.security.AMSPermission "agent-class=*",
"register, derister,modify";
permission jade.security.AgentPermission "agent-class=*", "create,
kill";
permission jade.security.MessagePermission "agent-owner:alice",

CONFIDENTIAL – All rights reserved


"send-to";
};

The Hague, 12/10/04


Signing and encrypting messages

• All security related API are embedded into the SecurityHelper


• Can be retrieved through the getHelper() method of the Agent
class

// Create the message


ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
......

// Retrieve the SecurityHelper


SecurityHelper myHelper = (SecurityHelper)

CONFIDENTIAL – All rights reserved


getHelper("jade.core.security.Security");

// The message must be signed


mySecurityHelper.setUseSignature(msg);

// Send the message


send(msg);

The Hague, 12/10/04


Documentation

• The Security add-on comes with a complete guide and some code
examples.

CONFIDENTIAL – All rights reserved


The Hague, 12/10/04
Other advanced features
• In-process interface
– Allow using JADE (i.e. creating a container and starting agents
on it) from an external Java program.
– jade.core.Runtime class and jade.wrapper package
– Documentation: chapter 3.8 of the JADE programmers guide.
• Threaded behaviours
– Allow executing a normal JADE behaviour in a dedicated thread
– jade.core.behaviours.ThreadedBehaviourFactory class
– Documentation: chapter 3.4.13 of the JADE programmers guide
• Persistence

CONFIDENTIAL – All rights reserved


– Allow saving and reloading agent state on relational DB
– Based on Hibernate (http://www.hibernate.org)
– Distributed as an add-on
– Still in experimental version Æ Comments and contributions
welcome

The Hague, 12/10/04


Outline
• JADE basics
– Creating Agents
– Agent tasks
– Agent communication
– The Yellow Pages service
• JADE advanced
– Managing content expressions
– Interaction protocols
– Working with the AMS

CONFIDENTIAL – All rights reserved


– Mobility
– Security
– Others
• JADE on mobile phones
– The LEAP add-on
– Creating JADE-based MIDlet

The Hague, 12/10/04


The LEAP add-on
• Allows running JADE agents on PDA and mobile phones (MIDP,
PersonalJava)
• Developed in the LEAP IST European project (Motorola, BT,
Broadcom, Siemens, Univ. Parma, ADAC, TILAB)
• Replaces some parts of JADE Æ JADE-LEAP (J2se, PJava, MIDP)
• Different internal implementation
• Same APIs for agents

JADE APIs JADE APIs JADE APIs JADE APIs

CONFIDENTIAL – All rights reserved


JADE JADE-LEAP JADE-LEAP
J2se JADE-LEAP
PJava Midp

The Hague, 12/10/04


Building JADE-LEAP

• JADE-LEAP can be downloaded in binary form (for J2se, PJava and


MIDP) directly from the download area of the JADE site.
• Alternatively one can download the JADE sources, then the LEAP
add-on and finally build JADE-LEAP using an ANT build file
included in the LEAP add-on (ANT 1.6 is required).
• The LEAP add-on also includes the LEAP user guide that provides
all the details about using JADE-LEAP.
• Using JADE-LEAP for J2se is identical to using JADE (same tools,
configuration parameters...) except for:

CONFIDENTIAL – All rights reserved


– Agents on the command line must be separated by ‘;’ instead of
blank
– Agent arguments must be separated by ‘,’ instead of a blank
(both on the command line and in the RMA)

The Hague, 12/10/04


Creating JADE-based MIDlet

• All MIDP applications are called MIDlets and their main class
extends javax.microedition.midlet.MIDlet.
• JADE-LEAP for MIDP is itself a MIDlet
– The main class is jade.MicroBoot
• A MIDlet must be packaged as a single JAR file
– A JADE-based MIDlet JAR file must include both JADE-LEAP
classes and application specific classes and resources (e.g.
images)

CONFIDENTIAL – All rights reserved


– The typical build process includes the following steps:
• Compile the application sources with JADE-LEAP in the classpath
• Mix application .class files and JADE-LEAP .class files
• Pre-verify the whole
• Jar the whole

The Hague, 12/10/04


Configuration parameters in MIDP

• JADE accepts a number of configuration parameters either on the


command line or in a property file
• Both ways of specifying parameters are not available in MIDP
• In MIDP configuration parameters are specified in the JAD/manifest
of the MIDlet.
• Example
– java ... jade.Boot .... –host ibm8695 –port 2222 ....
– Manifest ....
MIDlet-LEAP-host: ibm8695

CONFIDENTIAL – All rights reserved


MIDlet-LEAP-port: 2222
....

• Only a subset of the JADE configuration parameters are


available/meaningful in a MIDP manifest/JAD (e.g. –container)

The Hague, 12/10/04


Minimization
• JADE-LEAP for MIDP is ~450 Kbytes: VERY BIG!
• In general however its really rare that an application exploits all
features provided by JADE. It would be highly desirable to remove
all classes related to unused features from the application JAR file
• This can be achieved by means of the minimize target of the ANT
build file included in the LEAP add-on
– ant minimize –DJAR=<jar-file> -DDLC=<dlc-file>
-DMANIFEST=<manifest>
– Where the dlc-file includes the list of dynamically loaded
classes

CONFIDENTIAL – All rights reserved


• After the minimization process an average JADE-based application
becomes ~150Kbytes
• Using a good obfuscator it is possible to sensibly reduce the code
size further

The Hague, 12/10/04


Logging

• When running on a cell phone typically printouts produced by


System.out.println() have no effect at all.
• The jade.util.Logger class provides a uniform way over J2SE,
PJava and MIDP to produce printouts.
– In J2SE it uses JAVA Logging and therefore allow exploiting all
its flexibility
– In PJava it simply uses System.out.println()
– In MIDP it writes the output in a proper RecordStore where it

CONFIDENTIAL – All rights reserved


can be later viewed by means of the
jade.util.leap.OutputViewer MIDlet

The Hague, 12/10/04


Thanks for your attention!!!!

•Questions?

CONFIDENTIAL – All rights reserved


The Hague, 12/10/04

You might also like