JAC project
AOPSYS
CEDRIC & LIP6 labs

org.objectweb.jac.aspects.persistence
Interface PersistenceConf

All Known Implementing Classes:
PersistenceAC

public interface PersistenceConf

This is the configuration interface of the persistence aspect.

See Also:
PersistenceAC

Method Summary
 void configureStorage(ClassItem storageClass, String[] storageParameters)
          Specify which storage class to use and the parameters to use to instanciate it.
 void defineMaxIdleCheckPeriod(long period)
          Defines the period that is used to check that the collection max idle time has not been reached.
 void disableCache(CollectionItem collection)
          This configuration method allows to disable the cache for a given collection.
 void makePersistent(String classExpr, String nameExpr)
          Configure persistence for one class.
 void maxIdle(CollectionItem collection, long maxIdle)
          Set a max idle time for a collection.
 void preloadAllFields(ClassItem cl)
          Set all fields of a class to be preloaded
 void preloadField(FieldItem field)
          Sets a field or collection to be preloaded
 void registerStatics(String classExpr, String nameExpr)
          Registers a static name, that is a name that will not be changed by the persistence AC.
 void setValueConverter(ClassItem cl, ClassItem converter)
          Associate a String-Object converter with a class
 

Method Detail

setValueConverter

public void setValueConverter(ClassItem cl,
                              ClassItem converter)
Associate a String-Object converter with a class

In order to stock objects in database, those objects must be converted in a String format. Basic classes are already implemented, but for new classes (such as java.awt.Dimension) new converters must be used. New converters can be used with fhis function.

Parameters:
cl - the class to convert
converter - the converter used. The class must implement org.objectweb.jac.aspects.persistenceconf.StringConverter.
See Also:
StringConverter

configureStorage

public void configureStorage(ClassItem storageClass,
                             String[] storageParameters)
Specify which storage class to use and the parameters to use to instanciate it. The choice of the storage's constructor is based on the number of arguments, so there should not be several constructors with the same number of arguments. Available storage are FSStorage and PostgresStorage

Parameters:
storageClass - the storage class
storageParameters - the parameters
See Also:
FSStorage, PostgresStorage

makePersistent

public void makePersistent(String classExpr,
                           String nameExpr)
Configure persistence for one class.

The persistence type must be PersistenceAC.ROOT (a named object that is an entry point in the storage) or PersistenceAC.PERSISTENT for a regular persistent class.

ROOT objects are always wrapped, PERSISTENT are only wrapped when they become persistent, that is when they are linked to an already persistent object.

Parameters:
classExpr - class expression of static objects
nameExpr - name expression of static objects

registerStatics

public void registerStatics(String classExpr,
                            String nameExpr)
Registers a static name, that is a name that will not be changed by the persistence AC.

Note that the root objects, as defined by the rtti aspect are automatically considered as static objects by the persistence aspect. Thus, it is useless to define a root object static.

Parameters:
classExpr - class expression of static objects
nameExpr - name expression of static objects
See Also:
RttiConf.addRoot(String)

preloadField

public void preloadField(FieldItem field)
Sets a field or collection to be preloaded

By default, persistent fields are loaded when accessed. Preloading a field force it to be loaded when the object is created : in the constructor.

Parameters:
field - the field to preload

preloadAllFields

public void preloadAllFields(ClassItem cl)
Set all fields of a class to be preloaded

Same as preloadField, but for all fields of the class

Parameters:
cl - the class
See Also:
#preloadField(ClassItem,String)

maxIdle

public void maxIdle(CollectionItem collection,
                    long maxIdle)
Set a max idle time for a collection.

The idle time corresponds to the time the collection is loaded in memory without having been accessed. By default, a collection stays in memory when it is loaded. For big collections, it might be interested to define a max idle time. When the max idle time is reached, the persistence aspect unloads this collection from the memory. The collection will be reloaded on the next access.

The frequency the max idle time has be reached is global to all collection and can be defined by defineMaxIdleCheckPeriod

Parameters:
collection - the collection that has a max idle
maxIdle - the max idle time in ms
See Also:
defineMaxIdleCheckPeriod(long)

defineMaxIdleCheckPeriod

public void defineMaxIdleCheckPeriod(long period)
Defines the period that is used to check that the collection max idle time has not been reached.

If a collection max idle time is defined and that it has not been used for this time, then the collection is unloaded from the memory by the peristence.

This method is not mandatory, by default, a check period of 200.000 ms is defined.

Parameters:
period - the period time check in ms
See Also:
maxIdle(CollectionItem,long)

disableCache

public void disableCache(CollectionItem collection)
This configuration method allows to disable the cache for a given collection.

Then, the collection will never be loaded in the memory but the objects will be accessed directly in the storage.


Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli