org.apache.lenya.cms.repository
Class SessionImpl

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.lenya.cms.repository.SessionImpl
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled, Session, UnitOfWork

public class SessionImpl
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements Session

Repository session.


Field Summary
protected static java.lang.String UNMODIFIABLE_SESSION_ID
           
 
Constructor Summary
SessionImpl(Identity identity, boolean modifiable, org.apache.avalon.framework.service.ServiceManager manager, org.apache.avalon.framework.logger.Logger logger)
          Ctor.
 
Method Summary
 void addListener(RepositoryListener listener)
           
 void commit()
          Commits the transaction.
 Lock createLock(Lockable lockable, int version)
          Creates a lock.
protected  java.lang.String createUuid()
           
 void enqueueEvent(RepositoryEvent event)
           
 java.lang.String getId()
           
 Identity getIdentity()
           
protected  IdentityMap getIdentityMap()
           
 RepositoryItem getRepositoryItem(RepositoryItemFactory factory, java.lang.String key)
           
protected  SharedItemStore getSharedItemStore()
           
protected  UnitOfWork getUnitOfWork()
           
 boolean isDirty(Transactionable transactionable)
           
 boolean isListenerRegistered(RepositoryListener listener)
          Checks if a listener is registered.
 boolean isModifiable()
           
 void registerDirty(Transactionable object)
          Registers an object as modified.
 void registerNew(Transactionable object)
          Registers an object as new.
 void registerRemoved(Transactionable object)
          Registers an object as removed.
 void removeLock(Lockable lockable)
          Removes a lock.
 void rollback()
          Rolls the transaction back.
protected  void savePersistables()
          Save all persistable objects to their nodes.
 void setIdentity(Identity identity)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNMODIFIABLE_SESSION_ID

protected static final java.lang.String UNMODIFIABLE_SESSION_ID
See Also:
Constant Field Values
Constructor Detail

SessionImpl

public SessionImpl(Identity identity,
                   boolean modifiable,
                   org.apache.avalon.framework.service.ServiceManager manager,
                   org.apache.avalon.framework.logger.Logger logger)
Ctor.

Parameters:
identity - The identity.
modifiable - Determines if the repository items in this session can be modified.
manager - The service manager.
logger - The logger.
Method Detail

createUuid

protected java.lang.String createUuid()

getIdentity

public Identity getIdentity()
Specified by:
getIdentity in interface Session
Returns:
the identity this session belongs to.

getUnitOfWork

protected UnitOfWork getUnitOfWork()
Returns:
The unit of work.

commit

public void commit()
            throws RepositoryException,
                   ConcurrentModificationException
Commits the transaction.

Specified by:
commit in interface Session
Specified by:
commit in interface UnitOfWork
Throws:
RepositoryException - if an error occurs.
ConcurrentModificationException - if a transactionable has been modified by another session.

savePersistables

protected void savePersistables()
                         throws RepositoryException
Save all persistable objects to their nodes.

Throws:
RepositoryException - if an error occurs.

rollback

public void rollback()
              throws RepositoryException
Rolls the transaction back.

Specified by:
rollback in interface Session
Specified by:
rollback in interface UnitOfWork
Throws:
RepositoryException - if an error occurs.

getSharedItemStore

protected SharedItemStore getSharedItemStore()

getRepositoryItem

public RepositoryItem getRepositoryItem(RepositoryItemFactory factory,
                                        java.lang.String key)
                                 throws RepositoryException
Specified by:
getRepositoryItem in interface Session
Parameters:
factory - The factory.
key - The key.
Returns:
The item for the specific key.
Throws:
RepositoryException - if an error occurs.
See Also:
Session.getRepositoryItem(org.apache.lenya.cms.repository.RepositoryItemFactory, java.lang.String)

registerNew

public void registerNew(Transactionable object)
                 throws TransactionException
Description copied from interface: UnitOfWork
Registers an object as new.

Specified by:
registerNew in interface UnitOfWork
Parameters:
object - The object.
Throws:
TransactionException - if an error occurs.

registerDirty

public void registerDirty(Transactionable object)
                   throws TransactionException
Description copied from interface: UnitOfWork
Registers an object as modified.

Specified by:
registerDirty in interface UnitOfWork
Parameters:
object - The object.
Throws:
TransactionException - if an error occurs.

registerRemoved

public void registerRemoved(Transactionable object)
                     throws TransactionException
Description copied from interface: UnitOfWork
Registers an object as removed.

Specified by:
registerRemoved in interface UnitOfWork
Parameters:
object - The object.
Throws:
TransactionException - if an error occurs.

setIdentity

public void setIdentity(Identity identity)
Specified by:
setIdentity in interface Session
Parameters:
identity - The identity.

isDirty

public boolean isDirty(Transactionable transactionable)
Specified by:
isDirty in interface UnitOfWork
Parameters:
transactionable - A transactionable.
Returns:
If the transactionable is registered as dirty.

createLock

public Lock createLock(Lockable lockable,
                       int version)
                throws TransactionException
Description copied from interface: UnitOfWork
Creates a lock.

Specified by:
createLock in interface UnitOfWork
Parameters:
lockable - The lockable.
version - The version.
Returns:
A lock.
Throws:
TransactionException - if a lock is already placed on this transactionable.

removeLock

public void removeLock(Lockable lockable)
                throws TransactionException
Description copied from interface: UnitOfWork
Removes a lock.

Specified by:
removeLock in interface UnitOfWork
Parameters:
lockable - The lockable.
Throws:
TransactionException - if no lock is placed on this transactionable.

addListener

public void addListener(RepositoryListener listener)
                 throws RepositoryException
Specified by:
addListener in interface Session
Parameters:
listener - The listener to add.
Throws:
RepositoryException - if the listener is already registered.

isListenerRegistered

public boolean isListenerRegistered(RepositoryListener listener)
Description copied from interface: Session
Checks if a listener is registered.

Specified by:
isListenerRegistered in interface Session
Parameters:
listener - The listener.
Returns:
A boolean value.

enqueueEvent

public void enqueueEvent(RepositoryEvent event)
Specified by:
enqueueEvent in interface Session
Parameters:
event - The event to add to the queue.

getIdentityMap

protected IdentityMap getIdentityMap()

isModifiable

public boolean isModifiable()
Specified by:
isModifiable in interface Session
Returns:
if the repository items in this session can be modified.

getId

public java.lang.String getId()
Specified by:
getId in interface Session
Returns:
The ID of this session.


Copyright 1999-2006 Apache Software Foundation. All Rights Reserved.