com.sun.sgs.impl.service.data.store
Class AbstractDataStore

java.lang.Object
  extended by com.sun.sgs.impl.service.data.store.AbstractDataStore
All Implemented Interfaces:
DataStore, TransactionParticipant
Direct Known Subclasses:
DataStoreClient, DataStoreImpl

public abstract class AbstractDataStore
extends Object
implements DataStore, TransactionParticipant

A skeletal implementation of DataStore that does logging, checks arguments, reports object accesses, implements the next key locking scheme for name bindings, and is a transaction participant. Object and name accesses are logged to AccessReporters whose source name includes the name of the concrete class.

This class uses a next key locking scheme when reporting accesses to name bindings. This scheme is a way to insure isolation when different transactions are creating, removing, and iterating over name bindings at the same time. The idea is to use the next key after a given key as a proxy for the existence of the given key even when that key does not exist. That way, iterators know when they lock the next key after a particular key that they will prevent others from changing what that next key ought to be. See the individual methods for getting, setting, removing, and iterating over bindings for details of how each operation fits into this scheme.

Note that this class does not perform next key locking for objects, because the way objects are allocated and used makes that unnecessary. Because there is no method at the application level for obtaining objects by object ID, applications can only officially obtain objects that are stored as the value of a name binding, or that are reachable by navigation from a name binding. In addition, object IDs are never reused. The combination of these two factors means that applications cannot ask to see an object that was created simultaneously by another transaction, which is what next key locking is intended to prevent. This lack of consistency enforcement for objects does mean that services, which can access objects by ID, need to make sure not to ask questions about objects that they don't have other reasons to believe exist. In particular, it means that object iteration may return inconsistent results.


Field Summary
protected  LoggerWrapper abortLogger
          The logger for transaction abort exceptions.
protected  LoggerWrapper logger
          The main logger for this class.
protected  AccessReporter<String> nameAccesses
          The reporter to notify of bound name accesses.
protected  AccessReporter<Long> objectAccesses
          The reporter to notify of object accesses.
 
Constructor Summary
protected AbstractDataStore(ComponentRegistry systemRegistry, LoggerWrapper logger, LoggerWrapper abortLogger)
          Creates an instance of this class.
 
Method Summary
 void abort(Transaction txn)
          Tells the participant to abort its involvement with the given transaction.
protected abstract  void abortInternal(Transaction txn)
          Performs the actual operation for abort.
static void checkOid(long oid)
          Checks that the object ID argument is not negative.
 void commit(Transaction txn)
          Tells the participant to commit its state associated with the given transaction.
protected abstract  void commitInternal(Transaction txn)
          Performs the actual operation for commit.
 long createObject(Transaction txn)
          Reserves an object ID for a new object.
protected abstract  long createObjectInternal(Transaction txn)
          Performs the actual operation for createObject.
 long getBinding(Transaction txn, String name)
          Obtains the object ID bound to a name.
protected abstract  BindingValue getBindingInternal(Transaction txn, String name)
          Performs the actual operation for getBinding.
 int getClassId(Transaction txn, byte[] classInfo)
          Returns the class ID to represent classes with the specified class information.
protected abstract  int getClassIdInternal(Transaction txn, byte[] classInfo)
          Performs the actual operation for getClassId.
 byte[] getClassInfo(Transaction txn, int classId)
          Returns the class information associated with the specified class ID.
protected abstract  byte[] getClassInfoInternal(Transaction txn, int classId)
          Performs the actual operation for getClassInfo.
 long getLocalNodeId()
          Returns the node ID for the local node.
protected abstract  long getLocalNodeIdInternal()
          Performs the actual operation for getLocalNodeId.
protected static String getNameForAccess(String name)
          Returns the name to use for reporting access to a name binding.
 byte[] getObject(Transaction txn, long oid, boolean forUpdate)
          Obtains the data associated with an object ID.
protected abstract  byte[] getObjectInternal(Transaction txn, long oid, boolean forUpdate)
          Performs the actual operation for getObject.
 String getTypeName()
          Returns the fully qualified type name of the participant.
protected  RuntimeException handleException(Transaction txn, Level level, RuntimeException e, String operation)
          Performs any operations needed when an exception is going to be thrown, as well as allowing the implementation to replace the exception with a different one.
 void markForUpdate(Transaction txn, long oid)
          Notifies the DataStore that an object is going to be modified.
protected abstract  void markForUpdateInternal(Transaction txn, long oid)
          Performs the actual operation for markForUpdate.
 String nextBoundName(Transaction txn, String name)
          Returns the next name after the specified name that has a binding, or null if there are no more bound names.
protected abstract  String nextBoundNameInternal(Transaction txn, String name)
          Performs the actual operation for nextBoundName.
 long nextObjectId(Transaction txn, long oid)
          Returns the object ID for the next object after the object with the specified ID, or -1 if there are no more objects.
protected abstract  long nextObjectIdInternal(Transaction txn, long oid)
          Performs the actual operation for nextObjectId.
 boolean prepare(Transaction txn)
          Tells the participant to prepare for commiting its state associated with the given transaction.
 void prepareAndCommit(Transaction txn)
          Tells the participant to both prepare and commit its state associated with the given transaction.
protected abstract  void prepareAndCommitInternal(Transaction txn)
          Performs the actual operation for prepareAndCommit.
protected abstract  boolean prepareInternal(Transaction txn)
          Performs the actual operation for prepare.
 void ready()
          Notifies the data store that services associated with the application have been successfully created.
 void removeBinding(Transaction txn, String name)
          Removes the binding for a name.
protected abstract  BindingValue removeBindingInternal(Transaction txn, String name)
          Performs the actual operation for removeBinding.
 void removeObject(Transaction txn, long oid)
          Removes the object with the specified object ID.
protected abstract  void removeObjectInternal(Transaction txn, long oid)
          Performs the actual operation for removeObject.
protected  void reportNameAccess(Transaction txn, String name, AccessReporter.AccessType type)
          Reports a name access.
protected  void reportObjectAccess(Transaction txn, long oid, AccessReporter.AccessType type)
          Reports an object access.
 void setBinding(Transaction txn, String name, long oid)
          Binds an object ID to a name.
 void setBindingDescription(Transaction txn, String name, Object description)
          Associates a description with a bound name, for use in describing name accesses.
protected abstract  BindingValue setBindingInternal(Transaction txn, String name, long oid)
          Performs the actual operation for setBinding.
 void setObject(Transaction txn, long oid, byte[] data)
          Specifies data to associate with an object ID.
 void setObjectDescription(Transaction txn, long oid, Object description)
          Associates a description with an object ID, for use in describing object accesses.
protected abstract  void setObjectInternal(Transaction txn, long oid, byte[] data)
          Performs the actual operation for setObject.
 void setObjects(Transaction txn, long[] oids, byte[][] dataArray)
          Specifies data to associate with a series of object IDs.
protected abstract  void setObjectsInternal(Transaction txn, long[] oids, byte[][] dataArray)
          Performs the actual operation for setObjects.
 void shutdown()
          Shuts down this data store.
protected abstract  void shutdownInternal()
          Performs the actual operation for shutdown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final LoggerWrapper logger
The main logger for this class.


abortLogger

protected final LoggerWrapper abortLogger
The logger for transaction abort exceptions.


objectAccesses

protected final AccessReporter<Long> objectAccesses
The reporter to notify of object accesses.


nameAccesses

protected final AccessReporter<String> nameAccesses
The reporter to notify of bound name accesses.

Constructor Detail

AbstractDataStore

protected AbstractDataStore(ComponentRegistry systemRegistry,
                            LoggerWrapper logger,
                            LoggerWrapper abortLogger)
Creates an instance of this class.

Parameters:
systemRegistry - the registry of available system components
logger - the main logger for this class
abortLogger - the logger for transaction abort exceptions
Method Detail

ready

public void ready()
           throws Exception
Notifies the data store that services associated with the application have been successfully created. If the method throws an exception, then the application should be shutdown.

This implementation does nothing.

Specified by:
ready in interface DataStore
Throws:
Exception - if an error occurs

getLocalNodeId

public long getLocalNodeId()
Returns the node ID for the local node.

This implementation does logging and calls getLocalNodeIdInternal() to perform the actual operation.

Specified by:
getLocalNodeId in interface DataStore
Returns:
the node ID for the local node

getLocalNodeIdInternal

protected abstract long getLocalNodeIdInternal()
Performs the actual operation for getLocalNodeId.

Returns:
the local node ID

createObject

public long createObject(Transaction txn)
Reserves an object ID for a new object. Note that calling other operations using this ID are not required to find the object until setObject or setObjects is called. Aborting a transaction is also not required to unassign the ID so long as other operations treat it as a non-existent object.

This implementation does logging and calls createObjectInternal to perform the actual operation.

Specified by:
createObject in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
Returns:
the new object ID

createObjectInternal

protected abstract long createObjectInternal(Transaction txn)
Performs the actual operation for createObject.

Parameters:
txn - the transaction under which the operation should take place
Returns:
the new object ID
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

markForUpdate

public void markForUpdate(Transaction txn,
                          long oid)
Notifies the DataStore that an object is going to be modified. The implementation can use this information to obtain an exclusive lock on the object in order to avoid contention when the object is modified. This method does nothing if the object does not exist.

This implementation does logging, checks that oid is valid, reports object accesses, and calls markForUpdateInternal to perform the actual operation.

Specified by:
markForUpdate in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
oid - the object ID

markForUpdateInternal

protected abstract void markForUpdateInternal(Transaction txn,
                                              long oid)
Performs the actual operation for markForUpdate.

Parameters:
txn - the transaction under which the operation should take place
oid - the object ID
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

getObject

public byte[] getObject(Transaction txn,
                        long oid,
                        boolean forUpdate)
Obtains the data associated with an object ID. If the forUpdate parameter is true, the caller is stating its intention to modify the object. The implementation can use that information to obtain an exclusive lock on the object in order avoid contention when the object is modified.

This implementation does logging, checks that oid is valid, reports object accesses, and calls getObjectInternal to perform the actual operation.

Specified by:
getObject in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
oid - the object ID
forUpdate - whether the caller intends to modify the object
Returns:
the data associated with the object ID

getObjectInternal

protected abstract byte[] getObjectInternal(Transaction txn,
                                            long oid,
                                            boolean forUpdate)
Performs the actual operation for getObject.

Parameters:
txn - the transaction under which the operation should take place
oid - the object ID
forUpdate - whether the caller intends to modify the object
Returns:
the data associated with the object ID
Throws:
ObjectNotFoundException - if the object is not found
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

setObject

public void setObject(Transaction txn,
                      long oid,
                      byte[] data)
Specifies data to associate with an object ID.

This implementation does logging, checks that oid is valid and data is not null, reports object accesses, and calls setObjectInternal to perform the actual operation.

Specified by:
setObject in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
oid - the object ID
data - the data

setObjectInternal

protected abstract void setObjectInternal(Transaction txn,
                                          long oid,
                                          byte[] data)
Performs the actual operation for setObject.

Parameters:
txn - the transaction under which the operation should take place
oid - the object ID
data - the data
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

setObjects

public void setObjects(Transaction txn,
                       long[] oids,
                       byte[][] dataArray)
Specifies data to associate with a series of object IDs.

This implementation does logging, checks that oids is not null and its elements are valid, that dataArray and its elements are not null, and that oids and dataArray have the same length, reports object accesses, and calls setObjectsInternal to perform the actual operation.

Specified by:
setObjects in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
oids - the object IDs
dataArray - the associated data values

setObjectsInternal

protected abstract void setObjectsInternal(Transaction txn,
                                           long[] oids,
                                           byte[][] dataArray)
Performs the actual operation for setObjects.

Parameters:
txn - the transaction under which the operation should take place
oids - the object IDs
dataArray - the associated data values
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

removeObject

public void removeObject(Transaction txn,
                         long oid)
Removes the object with the specified object ID. The implementation will make an effort to flag subsequent references to the removed object by throwing ObjectNotFoundException, although this behavior is not guaranteed. The implementation is not required to check that the object is an externally visible object rather than one used internally by the implementation.

This implementation does logging, checks that oid is valid and data is not null, reports object accesses, and calls removeObjectInternal to perform the actual operation.

Specified by:
removeObject in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
oid - the object ID

removeObjectInternal

protected abstract void removeObjectInternal(Transaction txn,
                                             long oid)
Performs the actual operation for removeObject.

Parameters:
txn - the transaction under which the operation should take place
oid - the object ID
Throws:
ObjectNotFoundException - if the object is not found
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

getBinding

public long getBinding(Transaction txn,
                       String name)
Obtains the object ID bound to a name.

This implementation does logging, checks that name is not null, reports name accesses, and calls getBindingInternal to perform the actual operation.

Specified by:
getBinding in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
name - the name
Returns:
the object ID

getBindingInternal

protected abstract BindingValue getBindingInternal(Transaction txn,
                                                   String name)
Performs the actual operation for getBinding. If the name is bound, the return value contains the object ID that the name is bound to and a next name of null. If the name is not bound, the return value contains an object ID of -1 and the next name found, which may be null.

Parameters:
txn - the transaction under which the operation should take place
name - the name
Returns:
information about the object ID and the next name
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

setBinding

public void setBinding(Transaction txn,
                       String name,
                       long oid)
Binds an object ID to a name.

This implementation does logging, checks that name is not null and that oid is valid, reports name accesses, and calls setBindingInternal to perform the actual operation.

Specified by:
setBinding in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
name - the name
oid - the object ID

setBindingInternal

protected abstract BindingValue setBindingInternal(Transaction txn,
                                                   String name,
                                                   long oid)
Performs the actual operation for setBinding. If the name is bound, the return value contains an arbitrary non-negative object ID and a next name of null. If the name is not bound, the return value contains an object ID of -1 and the next name found, which may be null.

Parameters:
txn - the transaction under which the operation should take place
name - the name
oid - the object ID
Returns:
information about the old object ID and the next name
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

removeBinding

public void removeBinding(Transaction txn,
                          String name)
Removes the binding for a name.

This implementation does logging, checks that name is not null, reports name accesses, and calls removeBindingInternal to perform the actual operation.

Specified by:
removeBinding in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
name - the name

removeBindingInternal

protected abstract BindingValue removeBindingInternal(Transaction txn,
                                                      String name)
Performs the actual operation for removeBinding. If the name is bound, the return value contains an arbitrary non-negative object ID, otherwise it contains -1. In all cases, the return value contains the next name found, which may be null.

Parameters:
txn - the transaction under which the operation should take place
name - the name
Returns:
information about the object ID and the next name
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

nextBoundName

public String nextBoundName(Transaction txn,
                            String name)
Returns the next name after the specified name that has a binding, or null if there are no more bound names. If name is null, then the search starts at the beginning.

This implementation does logging, reports name accesses, and calls nextBoundNameInternal to perform the actual operation.

Specified by:
nextBoundName in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
name - the name to search after, or null to start at the beginning
Returns:
the next name with a binding following name, or null if there are no more bound names

nextBoundNameInternal

protected abstract String nextBoundNameInternal(Transaction txn,
                                                String name)
Performs the actual operation for nextBoundName.

Parameters:
txn - the transaction under which the operation should take place
name - the name to search after, or null to start at the beginning
Returns:
the next name with a binding following name, or null if there are no more bound names
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

shutdown

public void shutdown()
Shuts down this data store. This method will block until the shutdown is complete.

This implementation does logging and calls shutdownInternal to perform the actual operation.

Specified by:
shutdown in interface DataStore

shutdownInternal

protected abstract void shutdownInternal()
Performs the actual operation for shutdown.


getClassId

public int getClassId(Transaction txn,
                      byte[] classInfo)
Returns the class ID to represent classes with the specified class information. Obtains an existing ID for the class information if present; otherwise, stores the information and returns the new ID associated with it. Class IDs are always greater than 0. The class information is the serialized form of the ObjectStreamClass instance that serialization uses to represent the class.

This implementation does logging, checks that classInfo is not null, and calls getClassIdInternal to perform the actual operation.

Specified by:
getClassId in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
classInfo - the class information
Returns:
the associated class ID

getClassIdInternal

protected abstract int getClassIdInternal(Transaction txn,
                                          byte[] classInfo)
Performs the actual operation for getClassId.

Parameters:
txn - the transaction under which the operation should take place
classInfo - the class information
Returns:
the associated class ID
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
TransactionNotActiveException - if the transaction is not active
IllegalStateException - if the operation failed because of a problem with the current transaction

getClassInfo

public byte[] getClassInfo(Transaction txn,
                           int classId)
                    throws ClassInfoNotFoundException
Returns the class information associated with the specified class ID. The class information is the serialized form of the ObjectStreamClass instance that serialization uses to represent the class.

This implementation does logging, checks that classId is valid, and calls getClassInfoInternal to perform the actual operation.

Specified by:
getClassInfo in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
classId - the class ID
Returns:
the associated class information
Throws:
ClassInfoNotFoundException - if the ID is not found

getClassInfoInternal

protected abstract byte[] getClassInfoInternal(Transaction txn,
                                               int classId)
                                        throws ClassInfoNotFoundException
Performs the actual operation for getClassInfo.

Parameters:
txn - the transaction under which the operation should take place
classId - the class ID
Returns:
the associated class information
Throws:
ClassInfoNotFoundException - if the ID is not found
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
IllegalStateException - if the operation failed because of a problem with the transaction

nextObjectId

public long nextObjectId(Transaction txn,
                         long oid)
Returns the object ID for the next object after the object with the specified ID, or -1 if there are no more objects. If objectId is -1, then returns the ID of the first object. The IDs returned by this method will not include ones for objects that have already been removed, and may not include identifiers for objects created after an iteration has begun. It is not an error for the object associated with the specified identifier to have already been removed.

Applications should not assume that objects associated with the IDs returned by this method, but which cannot be reached by traversing object field references starting with an object associated with a name binding, will continue to be retained by the data store.

This implementation does logging, checks that oid is valid, reports object accesses, and calls nextObjectIdInternal to perform the actual operation.

Specified by:
nextObjectId in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
oid - the identifier of the object to search after, or -1 to request the first object
Returns:
the identifier of the next object following the object with identifier oid, or -1 if there are no more objects

nextObjectIdInternal

protected abstract long nextObjectIdInternal(Transaction txn,
                                             long oid)
Performs the actual operation for nextObjectId.

Parameters:
txn - the transaction under which the operation should take place
oid - the identifier of the object to search after, or -1 to request the first object
Returns:
the identifier of the next object following the object with identifier oid, or -1 if there are no more objects
Throws:
TransactionAbortedException - if the transaction was aborted due to a lock conflict or timeout
IllegalStateException - if the operation failed because of a problem with the current transaction

setObjectDescription

public void setObjectDescription(Transaction txn,
                                 long oid,
                                 Object description)
Associates a description with an object ID, for use in describing object accesses. The description should provide a meaningful toString method.

Specified by:
setObjectDescription in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
oid - the object ID
description - the description
See Also:
AccessReporter.setObjectDescription

setBindingDescription

public void setBindingDescription(Transaction txn,
                                  String name,
                                  Object description)
Associates a description with a bound name, for use in describing name accesses. The description should provide a meaningful toString method.

Specified by:
setBindingDescription in interface DataStore
Parameters:
txn - the transaction under which the operation should take place
name - the name
description - the description
See Also:
AccessReporter.setObjectDescription

prepare

public boolean prepare(Transaction txn)
Tells the participant to prepare for commiting its state associated with the given transaction. This method returns a boolean flag stating whether the prepared state is read-only, meaning that no external state is modified by this participant. If this method returns true, then neither commit nor abort will be called.

If this method throws an exception, then the preparation failed, and the transaction will be aborted. If this method completes successfully, then the participant is required to be able to commit the transaction without failure.

This implementation does logging and calls prepareInternal to perform the actual operation.

Specified by:
prepare in interface TransactionParticipant
Parameters:
txn - the Transaction object
Returns:
true if this participant is read-only, false otherwise

prepareInternal

protected abstract boolean prepareInternal(Transaction txn)
Performs the actual operation for prepare.

Parameters:
txn - the transaction
Returns:
true if this participant is read-only, otherwise false
Throws:
IllegalStateException - if this participant has already been prepared, committed, or aborted, or if this participant is not participating in the given transaction

commit

public void commit(Transaction txn)
Tells the participant to commit its state associated with the given transaction.

This implementation does logging and calls commitInternal to perform the actual operation.

Specified by:
commit in interface TransactionParticipant
Parameters:
txn - the Transaction object

commitInternal

protected abstract void commitInternal(Transaction txn)
Performs the actual operation for commit.

Parameters:
txn - the transaction
Throws:
IllegalStateException - if this participant was not previously prepared, or if this participant has already committed or aborted, or if this participant is not participating in the given transaction

prepareAndCommit

public void prepareAndCommit(Transaction txn)
Tells the participant to both prepare and commit its state associated with the given transaction.

This implementation does logging and calls prepareAndCommitInternal to perform the actual operation.

Specified by:
prepareAndCommit in interface TransactionParticipant
Parameters:
txn - the Transaction object

prepareAndCommitInternal

protected abstract void prepareAndCommitInternal(Transaction txn)
Performs the actual operation for prepareAndCommit.

Parameters:
txn - the transaction
Throws:
IllegalStateException - if this participant has already been prepared, committed, or aborted, or if this participant is not participating in the given transaction

abort

public void abort(Transaction txn)
Tells the participant to abort its involvement with the given transaction.

This implementation does logging and calls abortInternal to perform the actual operation.

Specified by:
abort in interface TransactionParticipant
Parameters:
txn - the Transaction object

abortInternal

protected abstract void abortInternal(Transaction txn)
Performs the actual operation for abort.

Parameters:
txn - the transaction
Throws:
IllegalStateException - if this participant has already been aborted or committed, or if this participant is not participating in the given transaction

getTypeName

public String getTypeName()
Returns the fully qualified type name of the participant. If this participant is acting as a proxy for a Service, this will typically be the Service's type name.

Specified by:
getTypeName in interface TransactionParticipant
Returns:
the name of the participant

handleException

protected RuntimeException handleException(Transaction txn,
                                           Level level,
                                           RuntimeException e,
                                           String operation)
Performs any operations needed when an exception is going to be thrown, as well as allowing the implementation to replace the exception with a different one.

This implementation does logging, and aborts the transaction if it is not null and the exception is a TransactionAbortedException.

Parameters:
txn - the transaction or null
level - the logging level
e - the exception
operation - a description of the operation being performed
Returns:
the exception to throw

reportObjectAccess

protected void reportObjectAccess(Transaction txn,
                                  long oid,
                                  AccessReporter.AccessType type)
Reports an object access.

Parameters:
txn - the transaction
oid - the object ID
type - the type of access
Throws:
IllegalArgumentException - if oid is negative

reportNameAccess

protected void reportNameAccess(Transaction txn,
                                String name,
                                AccessReporter.AccessType type)
Reports a name access.

Parameters:
txn - the transaction
name - the name
type - the type of access

getNameForAccess

protected static String getNameForAccess(String name)
Returns the name to use for reporting access to a name binding. Uses the value "z.end" instead of null to represent a name beyond the last known name. Add the prefix "z" to any name whose first character is "z". Note that this scheme does not preserve order, but access reporting does not require that.

Parameters:
name - the name or null
Returns:
the name to use for reporting object accesses

checkOid

public static void checkOid(long oid)
Checks that the object ID argument is not negative.

Parameters:
oid - the object ID
Throws:
IllegalArgumentException - if oid is negative

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved