|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface PersistenceManager
This class is used to store and retrieve objects by their type
in the database.
A persistence instance can be obtains using the method
PersistenceManagerFactory.getPersistenceManager().
To be persistent, an object must have its interface tagged by
the annotation Persistent.
In order to track the relation between a location on the disk
and a persistent object, the persistent manager use a special
getter of the persistent class to store an uniq id.
Its up to the developer to declare it in a persistent type
using the annotation Id).
Only one getter can be tagged by Id in the persistent type
and the persitent type must not own a corresponding setter.
By default, a persistent type only support getter and setter typed with
a primitive type (not even String) but implementors can provide an
implementation without these restrictions.
However, a persistent type can't own a method that is not a
setter or a getter.
All operations on persistent objects rely on a
thread-local context.
This context is created using
newContext(fr.umlv.javaodb.PersistenceContext.Kind).
The context kind taken as argument
is a user's on that which kind of context is requested,
but depending on the implementation of the manager andd
on the runtime environment the kind of created context can be downgraded/upgraded
to another kind to ensure coherence
(see context.getKind() for more info).
All the methods of the persistence manager are thread safe.
PersistenceManagerFactory,
PersistenceContext| Method Summary | |
|---|---|
void |
close()
Shutdown the database. |
void |
commit()
Convenient method for PersistenceContext.commit()
on the inner most thread-local context. |
void |
drop(Class<?> persistenceType)
Drops all objects of the specfic persistence type. |
Set<? extends Class<?>> |
getPersistentTypes()
Returns the types of all persistent objects stored in the database. |
boolean |
isClosed()
Returns whenever the current manager is close or not. |
PersistenceContext |
newContext(PersistenceContext.Kind kind)
Creates a thread local context or a nested context if a context already exists on the current thread. |
void |
rollback()
Convenient method for PersistenceContext.rollback()
on the inner most thread-local context. |
| Method Detail |
|---|
void drop(Class<?> persistenceType)
throws PersistenceException
persistenceType - an interface tagged by Persistent.
PersistenceException - if the type is not persistent or
if the current manager is closed or if an IO error occurs.
Set<? extends Class<?>> getPersistentTypes()
throws PersistenceException
PersistenceException - if the current manager is closed
or if if an IO error occurs.
PersistenceContext newContext(PersistenceContext.Kind kind)
throws PersistenceException
kind - a hint of the context kind.
PersistenceException - if contexts can't be nested or
if the current manager is closed.PersistenceContext.getKind()
void commit()
throws PersistenceException
PersistenceContext.commit()
on the inner most thread-local context.
PersistenceException - if no thread-local context is defined
or if the current manager is closed.PersistenceContext.commit()
void rollback()
throws PersistenceException
PersistenceContext.rollback()
on the inner most thread-local context.
PersistenceException - if no thread-local context is defined
or if the current manager is closed.PersistenceContext.rollback()boolean isClosed()
void close()
throws PersistenceException
PersistenceException - if current manager can't be closed or is
already closed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||