JAC project
AOPSYS
CEDRIC & LIP6 labs

Package org.objectweb.jac.aspects.persistence

Provides a generic persistence aspect for JAC objects.

See:
          Description

Interface Summary
PersistenceConf This is the configuration interface of the persistence aspect.
Storage The Storage interface defines methods to store and retrieve objects fields to and from a media (it could be a database, simples files ...)
StringConverter The *StringConverter interface that converts Objects into String for stocking, and String into Objects
 

Class Summary
CollectionWrapper Base class for collection wrappers
DateStringConverter String converter for java.util.Date.
DimensionStringConverter String converter for java.awt.Dimension.
FSStorage A FileSystem storage
ListIterator  
ListWrapper A wrapper for the list interface.
LongOID An implementation of OID with a long
MapIterator  
MapWrapper A wrapper for the Map interface.
OID Abstract class that defines an object identifier.
PersistenceAC This AC defines a generic and configurable persistence aspect.
PersistenceWrapper This wrapper defines persistence extensions for objects that a defined persitent by a persistent aspect component.
PointStringConverter String converter for java.awt.Point.
PostgresStorage Implements the storage to store within a PostgreSQL database.
RectangleStringConverter String converter for java.awt.Rectangle.
RootObject  
SetIterator  
SetWrapper A wrapper for the Set interface.
SQLStorage Implements the storage to store within an SQL compliant database system.
StorageField  
StorageIterator  
StringOID An implementation of OID with a long
URLStringConverter String converter for java.net.URL.
ValueConverter General converter for all Objects.
 

Exception Summary
PersistenceAC.NoSuchWrapperException  
PersistenceWrapper.InvalidOidException  
SQLStorage.InvalidStorageException  
 

Error Summary
NoSuchOIDError  
 

Package org.objectweb.jac.aspects.persistence Description

Provides a generic persistence aspect for JAC objects.

This aspect is centered around a Storage interface which allows the programmer to adapt the persitence to any kind of storage (file based, databases, and so on).

A default implementation using the java.sql API (based on JDBC) is provided in the SQLStorage abtsract class. In order to create a concrete class, you only have to define the getNextVal(String sequence) method. As of today, the only storage available is PostgresStorage, which supports the Postgresql database.

The persitence aspect stores object's attributes in a storage so that a program can stopped and relaunched without losing data.

Here's a basic configuration for this aspect:

configureClass "org.objectweb.jac.samples.photos.Photo" "persistent"
configureClass "org.objectweb.jac.samples.photos.PhotoRepository" "root"
configureClass "org.objectweb.jac.samples.photos.Person" "root"
wrapCollection "org.objectweb.jac.samples.photos.PhotoRepository" "photos"
registerStatic "photorepository0"
configureStorage "org.objectweb.jac.aspects.persistence.PostgresStorage" { "photo" "jac" "" }
    

Classes can be configured to be persistence root, or just persistent. Instances of root classes are made persistent immediatly after you create them. Instances of persistent classes or made persistent only when they are attached to an already persistent object.

If you have a attribute of type Collection you want it to be stored in the storage, you should use wrapCollection. This is not very convenient and will not be needed any more in a forthcoming release.

Static objects are objects which are only created and saved once in the storage. The next time you create them, they will be reloaded from the storage.

Consider the following application:

public static void main( String[] args )
{
      PhotoRepository rep = new PhotoRepository();
}
    

It creates a PhotoRepository to work with. If the PhotoRepository rep is not declared static to the persistence aspect, a new PhotoRepository will be created each time you run this application, which is probably not what you want.

The configuration methods for this aspect are:

Related Documentation

For overviews, sources, tutorials, examples, guides, and tool documentation, please see:


Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli