|
JAC project AOPSYS CEDRIC & LIP6 labs |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jac.core.AspectComponent | +--org.objectweb.jac.aspects.persistence.PersistenceAC
This AC defines a generic and configurable persistence aspect.
Nested Class Summary | |
static class |
PersistenceAC.NoSuchWrapperException
|
Field Summary | |
static String |
DISABLE_PRELOAD
|
static String |
NO_CACHE
|
static String |
PERSISTENT
The global identifier for a persistent class in the RTTI. |
static String |
PRELOAD_FIELD
|
static String |
RESTORE
|
static String |
ROOT
The global identifier for a persistence root class in the RTTI. |
protected Storage |
storage
The used storage. |
static String |
VALUE_CONVERTER
|
Fields inherited from class org.objectweb.jac.core.AspectComponent |
application, blockKeywords, firstCall, NOT_SHARED, SHARED, startWeavingCCount, startWeavingCount, startWeavingMethod, startWeavingType, systemListener, wrappers |
Fields inherited from interface org.objectweb.jac.core.BaseProgramListener |
FOUND_OBJECT |
Constructor Summary | |
PersistenceAC()
|
Method Summary | |
boolean |
beforeRunningWrapper(Wrapper wrapper,
String wrappingMethod)
This method is called when a wrapper is going to be applied to a wrappee. |
void |
checkUnload()
This method is a callback for the timer that defines the max idle time. |
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. |
String[] |
getDefaultConfigs()
Returns defaults configuration files that must be loaded before the user's configuration |
OID |
getOID(Wrappee wrappee)
|
Storage |
getStorage()
Returns the storage. |
static boolean |
isFieldPreloaded(FieldItem field)
|
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 |
onExit()
This method is upcalled when the system exits. |
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 |
protected void |
registerObject(OID oid,
Object object)
Add an object in the list of persistent objects. |
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 |
void |
whenConfigured()
This method should be defined by the programmer when specific actions are needed once the aspect component has be configured. |
void |
whenDeleted(Wrappee object)
Upcalled when an object is deleted. |
void |
whenDeserialized(SerializedJacObject orgObject)
This method allows the deserialization of the OID of a persistent object. |
void |
whenFree(Wrappee object)
Upcalled when an object is freed from the memory. |
void |
whenGetObjects(Collection objects,
ClassItem cl)
Load objects from the storage when required. |
String |
whenNameObject(Object object,
String name)
Delegates naming to the storage |
void |
whenObjectMiss(String name)
The persistence aspect checks whether an object was in the storage when a NameRepository.getObject call
failed. |
void |
whenSerialized(SerializedJacObject finalObject)
This method add the OID info to the serialized JAC object when a serialization is requested by another aspect. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String ROOT
public static final String PERSISTENT
public static final String VALUE_CONVERTER
public static final String PRELOAD_FIELD
public static final String DISABLE_PRELOAD
public static final String NO_CACHE
public static final String RESTORE
protected Storage storage
Constructor Detail |
public PersistenceAC()
Method Detail |
public void onExit()
BaseProgramListener
onExit
in interface BaseProgramListener
onExit
in class AspectComponent
public void setValueConverter(ClassItem cl, ClassItem converter)
PersistenceConf
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.
setValueConverter
in interface PersistenceConf
cl
- the class to convertconverter
- the converter used. The class must implement
org.objectweb.jac.aspects.persistenceconf.StringConverter
.StringConverter
public void checkUnload()
For all the collections that have a max idle time, it checks that this time is not reached. If it is reached, it unloads the collection.
defineMaxIdleCheckPeriod(long)
,
maxIdle(CollectionItem,long)
public void defineMaxIdleCheckPeriod(long period)
PersistenceConf
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.
defineMaxIdleCheckPeriod
in interface PersistenceConf
period
- the period time check in msPersistenceConf.maxIdle(CollectionItem,long)
public void maxIdle(CollectionItem collection, long maxIdle)
PersistenceConf
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
maxIdle
in interface PersistenceConf
collection
- the collection that has a max idlemaxIdle
- the max idle time in msPersistenceConf.defineMaxIdleCheckPeriod(long)
public void whenConfigured()
AspectComponent
whenConfigured
in class AspectComponent
public void configureStorage(ClassItem storageClass, String[] storageParameters)
PersistenceConf
FSStorage
and
PostgresStorage
configureStorage
in interface PersistenceConf
storageClass
- the storage classstorageParameters
- the parametersFSStorage
,
PostgresStorage
public void registerStatics(String classExpr, String nameExpr)
PersistenceConf
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.
registerStatics
in interface PersistenceConf
classExpr
- class expression of static objectsnameExpr
- name expression of static objectsRttiConf.addRoot(String)
public void makePersistent(String classExpr, String nameExpr)
PersistenceConf
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.
makePersistent
in interface PersistenceConf
classExpr
- class expression of static objectsnameExpr
- name expression of static objectspublic Storage getStorage()
public void whenObjectMiss(String name)
NameRepository.getObject
call
failed.
whenObjectMiss
in interface BaseProgramListener
whenObjectMiss
in class AspectComponent
BaseProgramListener.whenObjectMiss(String)
public String whenNameObject(Object object, String name)
whenNameObject
in interface BaseProgramListener
whenNameObject
in class AspectComponent
object
- the object to namename
- current name of the object or null
protected void registerObject(OID oid, Object object)
oid
- the OID of the objectobject
- the objectpublic OID getOID(Wrappee wrappee)
public void whenDeserialized(SerializedJacObject orgObject)
orgObject
- the JAC object structure that is beeing
deserializedwhenSerialized(SerializedJacObject)
public void whenSerialized(SerializedJacObject finalObject)
This adding allows, for instance, the OID to be transmitted to remote containers.
finalObject
- the object that is being serializedpublic void whenGetObjects(Collection objects, ClassItem cl)
whenGetObjects
in interface BaseProgramListener
whenGetObjects
in class AspectComponent
objects
- the returned list (can be modified)cl
- the class that was used by the program to filter its
instances (can be null for all the objects)ObjectRepository
public boolean beforeRunningWrapper(Wrapper wrapper, String wrappingMethod)
AspectComponent
By overloading this method, the aspect component can skip the
wrapper, for instance if the current collaboration shows that
the wrapper has allready been applied.
If the method returns true, then the wrapper is run, else it
is skipped. Default: return true.
beforeRunningWrapper
in interface BaseProgramListener
beforeRunningWrapper
in class AspectComponent
wrapper
- the wrapper that is going to be runnedwrappingMethod
- the name of the may-be runned wrapping
method
Wrappee
,
Wrapping.wrap(Wrappee,Wrapper,String,AbstractMethodItem)
,
Wrapper
,
Wrapper.proceed(Interaction)
public void whenDeleted(Wrappee object)
BaseProgramListener
whenDeleted
in interface BaseProgramListener
whenDeleted
in class AspectComponent
public void whenFree(Wrappee object)
BaseProgramListener
whenFree
in interface BaseProgramListener
whenFree
in class AspectComponent
public void preloadField(FieldItem field)
PersistenceConf
By default, persistent fields are loaded when accessed. Preloading a field force it to be loaded when the object is created : in the constructor.
preloadField
in interface PersistenceConf
field
- the field to preloadpublic void preloadAllFields(ClassItem cl)
PersistenceConf
Same as preloadField, but for all fields of the class
preloadAllFields
in interface PersistenceConf
cl
- the class#preloadField(ClassItem,String)
public static boolean isFieldPreloaded(FieldItem field)
public void disableCache(CollectionItem collection)
PersistenceConf
Then, the collection will never be loaded in the memory but the objects will be accessed directly in the storage.
disableCache
in interface PersistenceConf
public String[] getDefaultConfigs()
AspectComponent
getDefaultConfigs
in class AspectComponent
|
Contact JAC development team: Renaud Pawlak Lionel Seinturier Laurent Martelli |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |