Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.storage.sql
Class CachingRowMapper

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.CachingRowMapper
All Implemented Interfaces:
RowMapper
Direct Known Subclasses:
CachingMapper

public class CachingRowMapper
extends Object
implements RowMapper

A RowMapper that has an internal cache.

The cache only holds Rows that are known to be identical to what's in the underlying RowMapper.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.sql.RowMapper
RowMapper.CopyResult, RowMapper.IdWithTypes, RowMapper.NodeInfo, RowMapper.RowBatch, RowMapper.RowUpdate
 
Constructor Summary
CachingRowMapper(Model model, RowMapper rowMapper, InvalidationsPropagator cachePropagator, InvalidationsPropagator eventPropagator, InvalidationsQueue repositoryEventQueue)
           
 
Method Summary
 void clearCache()
          Clears the mapper's cache (if any)
 void close()
           
 RowMapper.CopyResult copy(RowMapper.IdWithTypes source, Serializable destParentId, String destName, Row overwriteRow)
          Copies the hierarchy starting from a given row to a new parent with a new name.
 boolean isClusterReconnecting()
           
 List<? extends RowId> read(Collection<RowId> rowIds)
          Reads a set of rows for the given RowIds.
 Serializable[] readCollectionRowArray(RowId rowId)
          Gets an array for a CollectionFragment from the database, given its table name and id.
 List<Row> readSelectionRows(SelectionType selType, Serializable selId, Serializable filter, Serializable criterion, boolean limitToOne)
          Reads the rows corresponding to a selection.
 Row readSimpleRow(RowId rowId)
          Gets a row for a SimpleFragment from the database, given its table name and id.
 Invalidations.InvalidationsPair receiveInvalidations()
          Processes and returns the invalidations queued for processing by the cache (if any).
 List<RowMapper.NodeInfo> remove(RowMapper.NodeInfo rootInfo)
          Deletes a hierarchy and returns information to generate invalidations.
 void rollback(Xid xid)
          Rollback the XA Resource.
 void sendInvalidations(Invalidations invalidations)
          Post-transaction invalidations notification.
 void setEventQueue(InvalidationsQueue eventQueue)
          Used by the server to associate each mapper to a single event invalidations queue per client repository.
 void write(RowMapper.RowBatch batch)
          Writes a set of rows.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingRowMapper

public CachingRowMapper(Model model,
                        RowMapper rowMapper,
                        InvalidationsPropagator cachePropagator,
                        InvalidationsPropagator eventPropagator,
                        InvalidationsQueue repositoryEventQueue)
Method Detail

close

public void close()
           throws StorageException
Throws:
StorageException

receiveInvalidations

public Invalidations.InvalidationsPair receiveInvalidations()
                                                     throws StorageException
Description copied from interface: RowMapper
Processes and returns the invalidations queued for processing by the cache (if any).

Called pre-transaction by session start or transactionless save;

Specified by:
receiveInvalidations in interface RowMapper
Returns:
the invalidations (both for the mapper and the events), or null
Throws:
StorageException

sendInvalidations

public void sendInvalidations(Invalidations invalidations)
                       throws StorageException
Description copied from interface: RowMapper
Post-transaction invalidations notification.

Called post-transaction by session commit/rollback or transactionless save.

Specified by:
sendInvalidations in interface RowMapper
Parameters:
invalidations - the known invalidations to send to others, or null
Throws:
StorageException

setEventQueue

public void setEventQueue(InvalidationsQueue eventQueue)
Used by the server to associate each mapper to a single event invalidations queue per client repository.


clearCache

public void clearCache()
Description copied from interface: RowMapper
Clears the mapper's cache (if any)

Called after a rollback, or a manual clear through RepositoryStatus MBean.

Specified by:
clearCache in interface RowMapper

rollback

public void rollback(Xid xid)
              throws XAException
Description copied from interface: RowMapper
Rollback the XA Resource.

This is in the RowMapper interface because on rollback the cache must be invalidated.

Specified by:
rollback in interface RowMapper
Throws:
XAException

read

public List<? extends RowId> read(Collection<RowId> rowIds)
                           throws StorageException
Description copied from interface: RowMapper
Reads a set of rows for the given RowIds.

For each requested row, either a Row is found and returned, or a RowId (not implementing Row) is returned to signify an absent row.

Specified by:
read in interface RowMapper
Parameters:
rowIds - the row ids (including their table name)
Returns:
the collection of Rows (or RowIds if the row was absent from the database). Order is not the same as the input rowIds
Throws:
StorageException

write

public void write(RowMapper.RowBatch batch)
           throws StorageException
Description copied from interface: RowMapper
Writes a set of rows. This includes creating, updating and deleting rows.

Specified by:
write in interface RowMapper
Parameters:
batch - the set of rows and the operations to do on them
Throws:
StorageException

readSimpleRow

public Row readSimpleRow(RowId rowId)
                  throws StorageException
Description copied from interface: RowMapper
Gets a row for a SimpleFragment from the database, given its table name and id. If the row doesn't exist, null is returned.

Specified by:
readSimpleRow in interface RowMapper
Parameters:
rowId - the row id
Returns:
the row, or null
Throws:
StorageException

readCollectionRowArray

public Serializable[] readCollectionRowArray(RowId rowId)
                                      throws StorageException
Description copied from interface: RowMapper
Gets an array for a CollectionFragment from the database, given its table name and id. If no rows are found, an empty array is returned.

Specified by:
readCollectionRowArray in interface RowMapper
Parameters:
rowId - the row id
Returns:
the array
Throws:
StorageException

readSelectionRows

public List<Row> readSelectionRows(SelectionType selType,
                                   Serializable selId,
                                   Serializable filter,
                                   Serializable criterion,
                                   boolean limitToOne)
                            throws StorageException
Description copied from interface: RowMapper
Reads the rows corresponding to a selection.

Specified by:
readSelectionRows in interface RowMapper
Parameters:
selType - the selection type
selId - the selection id (parent id for a hierarchy selection)
filter - the filter value (name for a hierarchy selection)
criterion - an optional additional criterion depending on the selection type (complex prop flag for a hierarchy selection)
limitToOne - whether to stop after one row retrieved
Returns:
the list of rows
Throws:
StorageException

copy

public RowMapper.CopyResult copy(RowMapper.IdWithTypes source,
                                 Serializable destParentId,
                                 String destName,
                                 Row overwriteRow)
                          throws StorageException
Description copied from interface: RowMapper
Copies the hierarchy starting from a given row to a new parent with a new name.

If the new parent is null, then this is a version creation, which doesn't recurse in regular children.

If overwriteRow is passed, the copy is done onto this existing node as its root (version restore) instead of creating a new node in the parent.

Specified by:
copy in interface RowMapper
Parameters:
source - the id, primary type and mixin types of the row to copy
destParentId - the new parent id, or null
destName - the new name
overwriteRow - when not null, the copy is done onto this existing row, and the values are set in hierarchy
Returns:
info about the copy
Throws:
StorageException

remove

public List<RowMapper.NodeInfo> remove(RowMapper.NodeInfo rootInfo)
                                throws StorageException
Description copied from interface: RowMapper
Deletes a hierarchy and returns information to generate invalidations.

Specified by:
remove in interface RowMapper
Parameters:
rootInfo - info about the root to be deleted with its children (root id, and the rest is for invalidations)
Returns:
info about the descendants removed (including the root)
Throws:
StorageException

isClusterReconnecting

public boolean isClusterReconnecting()
Specified by:
isClusterReconnecting in interface RowMapper
Returns:
true if cluster mode enabled and connection is established but needs to be validated. this occurs after a connection error
See Also:
JDBCConnection.checkConnectionReset(java.lang.Throwable)

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.