org.objectweb.perseus.persistence.lib
Class TransactionalPersistenceManagerImpl

java.lang.Object
  extended byorg.objectweb.perseus.persistence.lib.TransactionalPersistenceManagerImpl
All Implemented Interfaces:
PersistenceManager, TransactionalPersistenceManager, TransactionalPersistenceManagerAttributeController

public class TransactionalPersistenceManagerImpl
extends java.lang.Object
implements TransactionalPersistenceManager, TransactionalPersistenceManagerAttributeController

This class is an implementation of the TransactionalPersistenceManager interface. It manages the persistency, the concurrency and the caching of persistent objects. To do this it uses several other components: - a cache manager, - a concurrency manager, - a storage manager, - a state manager, - a memory instance manager, - a working set manager. This implementation is compliant to fractal by implementing the BindingController interface permitting the management of bindings between components.

Author:
S.Chassande-Barrioz, P.Dechamboux, O.Lobry, Y. Bersihand

Field Summary
protected  CacheManager cache
          The cache of the persistent object.
static java.lang.String CACHE_MANAGER_BINDING
           
protected  ConcurrencyManager cm
          The concurrency manager
static java.lang.String CONCURRENCY_MANAGER_BINDING
           
protected  java.util.Collection filters
          The list of filters to order the working sets
protected  Logger logger
           
static java.lang.String MEMORY_INSTANCE_MANAGER_BINDING
           
protected  MemoryInstanceManager mim
          The factory of persistent objects
static java.lang.String STATE_MANAGER_BINDING
           
protected  StateManager stateManager
          The manager of state of persistent object.
protected  StorageManager storage
          The storage manager in charge of the I/O to the data support, and the naming management.
static java.lang.String STORAGE_MANAGER_BINDING
           
static java.lang.String UNBIND_MANAGER_BINDING
           
protected  UnbindManager unbindManager
           
static java.lang.String WORKINGSET_MANAGER_BINDING
           
protected  WorkingSetManager wsManager
          The manager of working set instance.
 
Constructor Summary
TransactionalPersistenceManagerImpl()
           
 
Method Summary
 State _writeIntention(WorkingSet ws, CacheEntry ce, java.lang.Object thinLock)
           
 void accessCompletion(WorkingSet ws, State ce)
          This method can be used to mark the end of an access to a data object.
 void begin(TransactionalWorkingSet tx)
          converts a context to a transaction
protected  void bindCeInWS(State state, WorkingSet ws, byte mode)
          Deprecated. Attaches a state to a working Set.
 void bindFc(java.lang.String s, java.lang.Object o)
           
protected  void checkCacheEntry(CacheEntry ce, WorkingSet ws)
          Check if a cache entry is already referenced in the cache.
 void close(WorkingSet context)
          Closes and releases a context.
 void commit(TransactionalWorkingSet tx)
          commits a transactional context.
protected  CacheEntry createCacheEntry(WorkingSet ws, java.lang.Object oid)
          creates a CacheEntry without state, corresponding to an identifier.
 WorkingSet createWS(java.lang.Object userObject)
          creates a working set
 WorkingSet createWS(java.lang.Object userObject, java.lang.Object workingSetType)
          creates a working set
 boolean evict(WorkingSet ws, java.lang.Object oid, boolean force)
          The unfix action is out of date.
 int evictAll(WorkingSet ws, boolean force)
          This methods permits to try the cache eviction of all persistent object
 State export(WorkingSet ws, java.lang.Object obj)
          Given an object, this method creates the corresponding copy in permanent support.
 State export(WorkingSet ws, java.lang.Object obj, java.lang.Object hints)
          This method permits to given some information to build the identifier of the new persistent object.
 void flush(WorkingSet ws, State stateToFlush)
          This method permits to flush entries associated to a context.
 void flush(WorkingSet ws, StateFilter statefilter)
          This method permits to flush entries associated to a context.
protected  CacheEntry getCacheEntry(WorkingSet ws, java.lang.Object oid)
          finds or creates the CacheEntry matching to an identifier.
 java.util.Collection getFilters()
           
 CacheEntry getObjectById(WorkingSet ws, java.lang.Object oid)
          This method retrieves a CacheEntry without checking if the persistent object, exists.
 java.lang.String[] listFc()
           
 java.lang.Object lookupFc(java.lang.String s)
           
 boolean prepare(TransactionalWorkingSet tx)
          Prepare the transactinal context.
 State readIntention(WorkingSet ws, java.lang.Object oid, java.lang.Object thinLock)
          This method records an access intention to a data object in read mode.
 void refresh(WorkingSet ws, java.lang.Object oid)
          Forget modifications of a dirty persistent object.
 void rollback(TransactionalWorkingSet tx)
          rollbacks a transactional context.
 void setFilters(java.util.Collection filters)
          Set the list of filters to be applied to order the working set.
 void unbind(WorkingSet ws, java.lang.Object oid)
          Detach a persistent object from the persistent support.
 void unbindFc(java.lang.String s)
           
 State unexport(WorkingSet ws, java.lang.Object oid)
          Deletes the binding between an in main-memory object, and its corresponding copy in permanent support.
 State writeIntention(WorkingSet ws, java.lang.Object oid, java.lang.Object thinLock)
          This method records an access intention to a data object in write mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_MANAGER_BINDING

public static final java.lang.String CACHE_MANAGER_BINDING
See Also:
Constant Field Values

CONCURRENCY_MANAGER_BINDING

public static final java.lang.String CONCURRENCY_MANAGER_BINDING
See Also:
Constant Field Values

STORAGE_MANAGER_BINDING

public static final java.lang.String STORAGE_MANAGER_BINDING
See Also:
Constant Field Values

STATE_MANAGER_BINDING

public static final java.lang.String STATE_MANAGER_BINDING
See Also:
Constant Field Values

MEMORY_INSTANCE_MANAGER_BINDING

public static final java.lang.String MEMORY_INSTANCE_MANAGER_BINDING
See Also:
Constant Field Values

UNBIND_MANAGER_BINDING

public static final java.lang.String UNBIND_MANAGER_BINDING
See Also:
Constant Field Values

WORKINGSET_MANAGER_BINDING

public static final java.lang.String WORKINGSET_MANAGER_BINDING
See Also:
Constant Field Values

cache

protected CacheManager cache
The cache of the persistent object.


unbindManager

protected UnbindManager unbindManager

cm

protected ConcurrencyManager cm
The concurrency manager


storage

protected StorageManager storage
The storage manager in charge of the I/O to the data support, and the naming management.


stateManager

protected StateManager stateManager
The manager of state of persistent object.


wsManager

protected WorkingSetManager wsManager
The manager of working set instance.


mim

protected MemoryInstanceManager mim
The factory of persistent objects


logger

protected Logger logger

filters

protected java.util.Collection filters
The list of filters to order the working sets

Constructor Detail

TransactionalPersistenceManagerImpl

public TransactionalPersistenceManagerImpl()
Method Detail

bindCeInWS

protected void bindCeInWS(State state,
                          WorkingSet ws,
                          byte mode)
Deprecated. Attaches a state to a working Set.

Parameters:
state - is the state of the persistent object which must be attached to working set.
ws - is the working set to attach the state.

getCacheEntry

protected CacheEntry getCacheEntry(WorkingSet ws,
                                   java.lang.Object oid)
                            throws PersistenceException
finds or creates the CacheEntry matching to an identifier. If no cache antry matching the identifier is found in the cache, an new instance is created without state.

Parameters:
ws - if the WorkingSet requiring a CacheEntry.
oid - the identifier of the expected cache entry
Returns:
a cache entry instance (never null).
Throws:
PersistenceException - if it is not possible to instanciate a persistent object
RolledBackPersistenceException - if the cache is full (case of the entry has not been found into the cache and a new entry is bound).

createCacheEntry

protected CacheEntry createCacheEntry(WorkingSet ws,
                                      java.lang.Object oid)
                               throws PersistenceException
creates a CacheEntry without state, corresponding to an identifier.

Parameters:
ws - if the WorkingSet requiring a CacheEntry.
oid - the identifier of the expected cache entry
Returns:
a cache entry instance (never null).
Throws:
PersistenceException - if it is not possible to instanciate a persistent object
RolledBackPersistenceException - if the cache is full.

checkCacheEntry

protected void checkCacheEntry(CacheEntry ce,
                               WorkingSet ws)
                        throws PersistenceException
Check if a cache entry is already referenced in the cache. If the entry has not been found, the entry is bound in the cache.

Parameters:
ce - is the cache entry to check
Throws:
PersistenceException - if the cache is full or if another cache entry has been found in the cache with the same identifier.

listFc

public java.lang.String[] listFc()

lookupFc

public java.lang.Object lookupFc(java.lang.String s)

bindFc

public void bindFc(java.lang.String s,
                   java.lang.Object o)

unbindFc

public void unbindFc(java.lang.String s)

export

public State export(WorkingSet ws,
                    java.lang.Object obj)
             throws PersistenceException
Description copied from interface: PersistenceManager
Given an object, this method creates the corresponding copy in permanent support. At the same time, it establishes a binding between the object in main-memory and the permanent copy. Roughly, the internal tasks include: - Reserving space on permanent support, - Establishing a binding between the object in main memory and the permanent copy, - Marking the object as dirty, (internal or by the concurrency control module?) - Adding the object to the cache

Specified by:
export in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
obj - The object whose state is to be copied to
Returns:
the state associated to the working set
Throws:
PersistenceException - Whenever the object is invalid (e.g. NULL) or it has been previously bound to another oid.

export

public State export(WorkingSet ws,
                    java.lang.Object obj,
                    java.lang.Object hints)
             throws PersistenceException
Description copied from interface: PersistenceManager
This method permits to given some information to build the identifier of the new persistent object.

Specified by:
export in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
obj - The object whose state is to be copied to
hints - can be used to build the identifier of the object.
Returns:
the state associated to the working set
Throws:
PersistenceException - Whenever the object is invalid (e.g. NULL) or it has been previously bound to another oid.

unexport

public State unexport(WorkingSet ws,
                      java.lang.Object oid)
               throws PersistenceException
Description copied from interface: PersistenceManager
Deletes the binding between an in main-memory object, and its corresponding copy in permanent support. At the same time, it frees (may be) the space in the permanent support allocated to the permanent copy.

Specified by:
unexport in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
oid - The identifier of the corresponding object to be destroyed.
Returns:
the state associated to the working set
Throws:
PersistenceException

getObjectById

public CacheEntry getObjectById(WorkingSet ws,
                                java.lang.Object oid)
                         throws PersistenceException
Description copied from interface: PersistenceManager
This method retrieves a CacheEntry without checking if the persistent object, exists. If the entry is already in the working or in the cache, the found entry is returned. Otherwise a new CacheEntry is returned. This method does not permit an access to persistent data, because no intention has been declared. Then a call to readIntention or writeIntention is required.

Specified by:
getObjectById in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
oid - The identifier of the corresponding object to find
Throws:
PersistenceException

readIntention

public State readIntention(WorkingSet ws,
                           java.lang.Object oid,
                           java.lang.Object thinLock)
                    throws PersistenceException
Description copied from interface: PersistenceManager
This method records an access intention to a data object in read mode.

Specified by:
readIntention in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
oid - is the object identifier.
Returns:
the state associated to the working set
Throws:
PersistenceException

writeIntention

public State writeIntention(WorkingSet ws,
                            java.lang.Object oid,
                            java.lang.Object thinLock)
                     throws PersistenceException
Description copied from interface: PersistenceManager
This method records an access intention to a data object in write mode.

Specified by:
writeIntention in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
oid - is the object identifier.
Returns:
the state associated to the working set
Throws:
PersistenceException

_writeIntention

public State _writeIntention(WorkingSet ws,
                             CacheEntry ce,
                             java.lang.Object thinLock)
                      throws PersistenceException
Throws:
PersistenceException

accessCompletion

public void accessCompletion(WorkingSet ws,
                             State ce)
                      throws PersistenceException
This method can be used to mark the end of an access to a data object.

Specified by:
accessCompletion in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
ce - is the cache entry on which the access is finished.
Throws:
PersistenceException

flush

public void flush(WorkingSet ws,
                  StateFilter statefilter)
           throws PersistenceException
This method permits to flush entries associated to a context.

Specified by:
flush in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
statefilter - is a filter of the state which must be flushed
Throws:
PersistenceException - if the context is not valid.

flush

public void flush(WorkingSet ws,
                  State stateToFlush)
           throws PersistenceException
This method permits to flush entries associated to a context.

Specified by:
flush in interface PersistenceManager
Parameters:
ws - is an identifier of the execution context. It can be a transaction handle.
stateToFlush - is the state taht must be flushed
Throws:
PersistenceException - if the context is not valid.

evict

public boolean evict(WorkingSet ws,
                     java.lang.Object oid,
                     boolean force)
              throws PersistenceException
The unfix action is out of date.

Specified by:
evict in interface PersistenceManager
Parameters:
ws - is the working set asking the eviction.
oid - is the identifier of the persistent object to evict from the cache
force - indicates if the entry MUST be evicted (true) or TRIES to be evicted (false).
Returns:
true if the entry has been evicted from the cache, otherwise false
Throws:
PersistenceException - if the instance is dirty or used by other working set.

evictAll

public int evictAll(WorkingSet ws,
                    boolean force)
             throws PersistenceException
Description copied from interface: PersistenceManager
This methods permits to try the cache eviction of all persistent object

Specified by:
evictAll in interface PersistenceManager
Returns:
the number of entry staying in the cache (not evicted)
Throws:
PersistenceException

unbind

public void unbind(WorkingSet ws,
                   java.lang.Object oid)
            throws PersistenceException
Description copied from interface: PersistenceManager
Detach a persistent object from the persistent support. After calling this method the persistent object is no more associated to the context and this instance is no more in the cache. If the persistent object has been modified, it is flushed. Be carefull the lock for the concurrency (read | write) is kept until the end of the context.

Specified by:
unbind in interface PersistenceManager
Parameters:
ws - is the current working set
oid - is the identifier of the persistent object
Throws:
PersistenceException

refresh

public void refresh(WorkingSet ws,
                    java.lang.Object oid)
             throws PersistenceException
Description copied from interface: PersistenceManager
Forget modifications of a dirty persistent object. The state is re-read from the cache or later from the database. Be carefull the lock for the concurrency (read | write) is kept until the end of the context.

Specified by:
refresh in interface PersistenceManager
Parameters:
ws - is the current working set
oid - is the identifier of the persistent object
Throws:
PersistenceException

createWS

public WorkingSet createWS(java.lang.Object userObject)
                    throws PersistenceException
creates a working set

Specified by:
createWS in interface PersistenceManager
Parameters:
userObject - can be an external user depending on the personnality.
Returns:
a new WorkingSet
Throws:
PersistenceException

createWS

public WorkingSet createWS(java.lang.Object userObject,
                           java.lang.Object workingSetType)
                    throws PersistenceException
creates a working set

Specified by:
createWS in interface PersistenceManager
Parameters:
userObject - can be an external user depending on the personnality.
workingSetType - is a type of the working set.
Returns:
a new WorkingSet
Throws:
PersistenceException

close

public void close(WorkingSet context)
           throws PersistenceException
Closes and releases a context.

Specified by:
close in interface PersistenceManager
Parameters:
context - which must be closed
Throws:
PersistenceException - if the context is a transactional context which has not been commited or aborted.

begin

public void begin(TransactionalWorkingSet tx)
           throws PersistenceException
converts a context to a transaction

Specified by:
begin in interface TransactionalPersistenceManager
Parameters:
tx - becomes transactional
Throws:
PersistenceException - if the context is already transactional.

prepare

public boolean prepare(TransactionalWorkingSet tx)
                throws PersistenceException
Prepare the transactinal context.

Specified by:
prepare in interface TransactionalPersistenceManager
Parameters:
tx - the
Returns:
true if the transaction can be commit or false is the transaction must be rolled back.
Throws:
PersistenceException - if an error raised during the prepare operation, or if the context is not a transactional context.

commit

public void commit(TransactionalWorkingSet tx)
            throws PersistenceException
commits a transactional context. The call to the prepare method is required.

Specified by:
commit in interface TransactionalPersistenceManager
Parameters:
tx -
Throws:
PersistenceException - if an error raised during the commit operation, or if the context is not a transactional context.

rollback

public void rollback(TransactionalWorkingSet tx)
              throws PersistenceException
rollbacks a transactional context. The call to the prepare method is required.

Specified by:
rollback in interface TransactionalPersistenceManager
Parameters:
tx -
Throws:
PersistenceException - if an error raised during the rollback operation, or if the context is not a transactional context.

setFilters

public void setFilters(java.util.Collection filters)
                throws java.lang.IllegalArgumentException
Description copied from interface: TransactionalPersistenceManagerAttributeController
Set the list of filters to be applied to order the working set.

Specified by:
setFilters in interface TransactionalPersistenceManagerAttributeController
Throws:
java.lang.IllegalArgumentException

getFilters

public java.util.Collection getFilters()
Specified by:
getFilters in interface TransactionalPersistenceManagerAttributeController
Returns:
the list of filters applied when ordering working set


Copyright © 2000-2002 France Telecom S.A., INRIA, IMAG-LSR All Rights Reserved.