|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
BasicProperties | Provides the foundation class for property management. |
EnhancedProperties | Provides a concrete implementation of ImportableProperties useable in the J2SE (desktop) world. |
Event | This class represents a generic event carrying some information
(accessible in the form of Object parameters) and
provides support for synchronous processing through the
waitUntilProcessed() and notifyProcessed()
methods. |
ExpandedProperties | Extends EnhancedProperties and adds support for fetching system environment variables (those usable from the OS shell). |
HashCache | This class is a cache with fixed dimension that can be set in the constructur. |
ImportableProperties | This class serves as a basis for supporting the ability to import properties from files. |
InputQueue | This class implements a FIFO queue of objects that can be put and got in a synchronized way. |
Logger | This class provides a uniform way to produce logging printouts in a device dependent way. |
RWLock | This class provides support for synchronizing threads acting on a generic resource in such a way that - If a thread is writing the resource no other thread can act on it in any way - Several threads can read the resource at the same time - If one or more threads are reading the resource no thread can write it |
SynchList | Implementation of a list of objects providing methods to synchronize threads acting on the list in such a way to prevent concurrent modifications (addition/remotion of elements) and concurrent scanning/modification. |
Exception Summary | |
PropertiesException | Property related exception. |
WrapperException | This class acts as a base class for all the exceptions that wrap another (nested) exception. |
This package contains utility classes and in particular: classes for handling properties and the leap subpackage that is a replacement for the Java collection framework that is not supported by J2ME.
These property classes provide a convenient method to easily provide an agent with configuration data. For example, the following would be usable in any agent running in an environment supporting ExpandedProperties:
// Add and initialize the following in your agent. protected myProperties = new ExpandedProperties(); // Called by JADE with any arguments given to the agent from the command line. public void setArguments(String[] args) { myProperties.parseArgs(args); // myPropeties may now be used throughout your agent code. // See the class BasicProperties for all its easy to use getters. }Properties are of the form: key=value or key:value. The special property import:foo.properties causes the property file foo.properties to be read. The ".properties" suffix is simply a common convention and is not required or enforced by these classes. One property file may import from others. Circular imports are checked for and if detected will throw a PropertiesException (extension of RuntimeException). Here is an example of a properties file:
# Specifies one or more user IDs to notify. # Separate each with a space. jabber.notify=smith # The Jabber server. jabber.server=theserver.hpl.hp.com SimpleCalendar.input=${AGENT_HOME}/config/simplecalendar.properties weather.state=CA weather.city=MOFFETT ARPT weather.zonecode=CAZ006Property files may contain as many pairs as necessary. Blank lines as well as lines beginning with '#' or '!' are ignored. A line ending with '\' is interpreted as continued to the next line. Within a collection of continued lines, any beginning with '#' or '!' are ignored making it easy to comment out particular ones.
To fetch the value associated with a key, use the format ${xxx}. An all uppercase key, such as ${AGENT_HOME} in the above example will cause the environment space (full not just those in the JVM's System properties) to be checked if the key doesn't exist in the properties collection.
A property may be set such that it can't be altered by ending the key value with a '!'. For example:
agentClass!=com.hp.agent.FooOne still references this property as ${agentClass}. This is particularly handy when you want to make a property collection available but prevent the changing of particular values. We have used this in conjunction with loading a property collection from the same jar file as a particul class. This is demonstrated below:
String defaultPropName = "com/hp/agent/smartagent/setup.properties"; properties = new ExpandedProperties(); InputStream propertyStream = this.getClass().getClassLoader().getResourceAsStream(defaultPropName); if (propertyStream != null) { try { properties.load(propertyStream); } catch (IOException ioe) { throw new PropertiesException("Error reading:" + defaultPropName); } }
Consult each classes documentation for further information but they relate as follows:
return new InputStreamReader(new FileInputStream(aFileName));whereas in the CLDC environment it would be:
return new InputStreamReader(Connector.openInputStream(aFileName));
|
|||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |