J | ava | A | spect | C | omponents |
Aspects of in the JAC framework are configured with files. Two
syntaxes for these files are currenctly supported :
acc
and xml
. The acc
syntax is used when the filename ends with
.acc
. The xml
syntax is used when the
filename ends with .xml
.
The acc
syntax is more concise and is intended to
be edited by hand. The xml
notation was introduced
to allow easier communication with other programs.
Aspect configuration files are first searched relative to the current directory, then as ressources in the classpath.
An acc file consists of calls to aspect configuration methods defined by the aspect component that you wish to configure.
<configuration_method> [<value> ...] ;
Parameters are separated by spaces. If special characters such
as '{' '}' ',' ';' '"'
or ' '
(space)
are to be used in a value, you should quote the value:
addRestrictedMethod mypackage.MyClass "myMethod(String,int)";
Values can be arrays :
{ <value> [ , <value> ] }
For instance:
setAttributesOrder Customer { lastName, firstName, phone, email };
It is often useful to share some configurations between applications, so an include mecanism is provided:
include <file_name>
Note that there is no ; after te include directive. The
Some aspects provide useful default settings that you can reuse in your applications. For instance:
include "org/objectweb/jac/aspect/gui/gui.acc"
Since you are likely to call several methods with some common paramaters, you can use grouping syntax:
class <group_value> { <configuration_method> [<value> ...] ; ... }
The <group_value>
will be prepended to the
parameter list of each configuration inside the
class
block. Therefore, the two following
configurations are equivalent:
class Customer { setAttributesOrder { lastName, firstName, phone, email }; setParameterNames "Customer(String,String)" { "Last name","First name" }; }
setAttributesOrder Customer { lastName, firstName, phone, email }; setParameterNames Customer "Customer(String,String)" { "Last name","First name" };
You can also provide a comma separated list of arguments to the group constructor.
class Customer,Employee { setAttributesOrder { lastName, firstName, phone, email }; }
is equivalent to
setAttributesOrder Customer { lastName, firstName, phone, email }; setAttributesOrder Employee { lastName, firstName, phone, email };
You can nest grouping block:
class Customer { attribute lastName { setCategory "General"; setEmbeddedEditor; } attribute firstName { setCategory "General"; setEmbeddedEditor; } }
is equivalent to
setCategory Customer lastName "General"; setEmbeddedEditor Customer lastName; setCategory Customer firstName "General"; setEmbeddedEditor Customer firstName;
In fact the class
and attribute
keywords can be substituted for one another. You can also use
method
and block
to create an
arbitrary number of nested bocks.
You can of course include comments in your configuration files:
// Settings for the Customer class class Customer { setAttributesOrder { lastName, firstName, phone, email }; setParameterNames "Customer(String,String)" { "Last name","First name" }; } /* * Multi-line c-style comments * are also supported */
Here is a sample of an XML configuration file for the session aspect of the contacts sample:
<?xml version="1.0" encoding="UTF-8" ?> <AspectConfiguration version="1.0"> <method name="declareStoredAttributes"> <arg type="java.lang.reflect.Array"> <item type="java.lang.String" value="Authentication.user" /> </arg> </method> <method name="defineSessionHandlers"> <arg type="java.lang.String" value="org.objectweb.jac.samples.contacts.FilteredContacts" /> <arg type="java.lang.String" value="ALL" /> <arg type="java.lang.String" value="filteredcontacts0" /> </method> <method name="definePerSessionObjects"> <arg type="java.lang.String" value="org.objectweb.jac.samples.contacts.FilteredContacts" /> <arg type="java.lang.String" value="filteredcontacts0" /> </method> </AspectConfiguration>