org.apache.commons.transaction.file
Class VirtualAdminCommandsFileResourceManager

java.lang.Object
  extended by org.apache.commons.transaction.file.FileResourceManager
      extended by org.apache.commons.transaction.file.VirtualAdminCommandsFileResourceManager
All Implemented Interfaces:
Status, ResourceManager, ResourceManagerErrorCodes

public class VirtualAdminCommandsFileResourceManager
extends FileResourceManager
implements ResourceManager, ResourceManagerErrorCodes

A resource manager for streamable objects stored in a file system that features additional administration commands.

Version:
$Id: FileResourceManager.java 519647 2007-03-18 17:50:02Z ozeigermann $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.commons.transaction.file.FileResourceManager
FileResourceManager.TransactionContext
 
Field Summary
protected  String virtualAdminPath
           
 
Fields inherited from class org.apache.commons.transaction.file.FileResourceManager
cleanUp, CONTEXT_FILE, debug, DEFAULT_COMMIT_TIMEOUT_FACTOR, DEFAULT_ISOLATION_LEVEL, DEFAULT_PARAMETER_ENCODING, DEFAULT_TIMEOUT_MSECS, defaultTimeout, dirty, globalOpenResources, globalTransactions, idCnt, idMapper, LOCK_ACCESS, LOCK_COMMIT, LOCK_EXCLUSIVE, LOCK_SHARED, lockManager, logger, NATIVE_ISOLATION_LEVEL, NO_LOCK, OPERATION_MODE_RECOVERING, OPERATION_MODE_STARTED, OPERATION_MODE_STARTING, OPERATION_MODE_STOPPED, OPERATION_MODE_STOPPING, operationMode, storeDir, txIdMapper, WORK_CHANGE_DIR, WORK_DELETE_DIR, workDir
 
Fields inherited from interface org.apache.commons.transaction.file.ResourceManager
ISOLATION_LEVEL_READ_COMMITTED, ISOLATION_LEVEL_READ_UNCOMMITTED, ISOLATION_LEVEL_REPEATABLE_READ, ISOLATION_LEVEL_SERIALIZABLE, PREPARE_FAILURE, PREPARE_SUCCESS, PREPARE_SUCCESS_READONLY, SHUTDOWN_MODE_KILL, SHUTDOWN_MODE_NORMAL, SHUTDOWN_MODE_ROLLBACK
 
Fields inherited from interface javax.transaction.Status
STATUS_ACTIVE, STATUS_COMMITTED, STATUS_COMMITTING, STATUS_MARKED_ROLLBACK, STATUS_NO_TRANSACTION, STATUS_PREPARED, STATUS_PREPARING, STATUS_ROLLEDBACK, STATUS_ROLLING_BACK, STATUS_UNKNOWN
 
Fields inherited from interface org.apache.commons.transaction.file.ResourceManagerErrorCodes
ERR_DEAD_LOCK, ERR_DUP_TX, ERR_ISOLATION_LEVEL_UNSUPPORTED, ERR_LOCK, ERR_MARKED_FOR_ROLLBACK, ERR_NO_LOCK, ERR_NO_SUCH_RESOURCE, ERR_NO_TX, ERR_RESOURCE_EXISTS, ERR_RESOURCEID_INVALID, ERR_SYSTEM, ERR_SYSTEM_INCONSISTENT, ERR_THREAD_INVALID, ERR_TX_INACTIVE, ERR_TX_INCONSISTENT, ERR_TXID_INVALID, ERR_UNKNOWN
 
Constructor Summary
VirtualAdminCommandsFileResourceManager(String storeDir, String workDir, boolean urlEncodePath, LoggerFacade logger)
          Creates a new resource manager operation on the specified directories.
VirtualAdminCommandsFileResourceManager(String storeDir, String workDir, boolean urlEncodePath, LoggerFacade logger, boolean debug)
          Creates a new resource manager operation on the specified directories.
VirtualAdminCommandsFileResourceManager(String storeDir, String workDir, ResourceIdToPathMapper idMapper, LoggerFacade logger, boolean debug)
          Creates a new resource manager operation on the specified directories.
VirtualAdminCommandsFileResourceManager(String storeDir, String workDir, ResourceIdToPathMapper idMapper, TransactionIdToPathMapper txIdMapper, LoggerFacade logger, boolean debug)
          Creates a new resource manager operation on the specified directories.
 
Method Summary
protected  void checkForVirtualAdminCommand(Object resourceId)
           
 void copyResource(Object txId, Object fromResourceId, Object toResourceId, boolean overwrite)
           
 void createResource(Object txId, Object resourceId)
          Creates a resource.
 void createResource(Object txId, Object resourceId, boolean assureOnly)
          Creates a resource.
 void deleteResource(Object txId, Object resourceId)
          Deletes a resource.
 void deleteResource(Object txId, Object resourceId, boolean assureOnly)
          Deletes a resource.
protected  InputStream executeAdminCommand(Object resourceId)
           
 String getVirtualAdminPath()
           
protected  boolean isAKnowCommand(String command)
           
protected  boolean isVirtualAdminId(Object resourceId)
           
 void moveResource(Object txId, Object fromResourceId, Object toResourceId, boolean overwrite)
           
 InputStream readResource(Object resourceId)
          Opens a streamable resource for a single reading request not inside the scope of a transaction.
 InputStream readResource(Object txId, Object resourceId)
          Opens a streamable resource for reading.
 boolean resourceExists(Object resourceId)
          Checks if a resource exists wihtout being in a transaction.
 boolean resourceExists(Object txId, Object resourceId)
          Checks if a resource exists.
 void setVirtualAdminPath(String virutalAdminPath)
           
 OutputStream writeResource(Object txId, Object resourceId, boolean append)
           
 
Methods inherited from class org.apache.commons.transaction.file.FileResourceManager
applyDeletes, assureLeadingSlash, assureNotMarkedForRollback, assureRMReady, assureStarted, closeOpenResource, commitTransaction, fileInitialSaneCheck, generatedUniqueTxId, getChangePath, getContext, getDefaultIsolationLevel, getDefaultTransactionTimeout, getDeletePath, getIsolationLevel, getLogger, getMainPath, getPathForRead, getPathForWrite, getSharedLockLevel, getStoreDir, getSupportedIsolationLevels, getTransactionBaseDir, getTransactionState, getTransactionTimeout, getWorkDir, isIsolationLevelSupported, lockResource, lockResource, lockResource, markTransactionForRollback, prepareTransaction, recover, recoverContexts, registerOpenResource, releaseGlobalOpenResources, reset, rollBackOrForward, rollbackTransaction, setDefaultTransactionTimeout, setDirty, setIsolationLevel, setTransactionTimeout, shutdown, start, startTransaction, stop, stop, sync, txInitialSaneCheck, txInitialSaneCheckForWriting, undoScheduledChangeOrCreate, undoScheduledDelete, waitForAllTxToStop, writeResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.transaction.file.ResourceManager
commitTransaction, getDefaultIsolationLevel, getDefaultTransactionTimeout, getIsolationLevel, getSupportedIsolationLevels, getTransactionState, getTransactionTimeout, isIsolationLevelSupported, lockResource, lockResource, lockResource, markTransactionForRollback, prepareTransaction, recover, rollbackTransaction, setIsolationLevel, setTransactionTimeout, start, startTransaction, stop, stop, writeResource
 

Field Detail

virtualAdminPath

protected String virtualAdminPath
Constructor Detail

VirtualAdminCommandsFileResourceManager

public VirtualAdminCommandsFileResourceManager(String storeDir,
                                               String workDir,
                                               boolean urlEncodePath,
                                               LoggerFacade logger)
Creates a new resource manager operation on the specified directories.

Parameters:
storeDir - directory where main data should go after commit
workDir - directory where transactions store temporary data
urlEncodePath - if set to true encodes all paths to allow for any kind of characters
logger - the logger to be used by this store

VirtualAdminCommandsFileResourceManager

public VirtualAdminCommandsFileResourceManager(String storeDir,
                                               String workDir,
                                               boolean urlEncodePath,
                                               LoggerFacade logger,
                                               boolean debug)
Creates a new resource manager operation on the specified directories.

Parameters:
storeDir - directory where main data should go after commit
workDir - directory where transactions store temporary data
urlEncodePath - if set to true encodes all paths to allow for any kind of characters
logger - the logger to be used by this store
debug - if set to true logs all locking information to "transaction.log" for debugging inspection

VirtualAdminCommandsFileResourceManager

public VirtualAdminCommandsFileResourceManager(String storeDir,
                                               String workDir,
                                               ResourceIdToPathMapper idMapper,
                                               LoggerFacade logger,
                                               boolean debug)
Creates a new resource manager operation on the specified directories. This constructor is reintroduced for backwards API compatibility and is used by jakarta-slide.

Parameters:
storeDir - directory where main data should go after commit
workDir - directory where transactions store temporary data
idMapper - mapper for resourceId to path
logger - the logger to be used by this store
debug - if set to true logs all locking information to "transaction.log" for debugging inspection

VirtualAdminCommandsFileResourceManager

public VirtualAdminCommandsFileResourceManager(String storeDir,
                                               String workDir,
                                               ResourceIdToPathMapper idMapper,
                                               TransactionIdToPathMapper txIdMapper,
                                               LoggerFacade logger,
                                               boolean debug)
Creates a new resource manager operation on the specified directories.

Parameters:
storeDir - directory where main data should go after commit
workDir - directory where transactions store temporary data
idMapper - mapper for resourceId to path
txIdMapper - mapper for transaction id to path
logger - the logger to be used by this store
debug - if set to true logs all locking information to "transaction.log" for debugging inspection
Method Detail

getVirtualAdminPath

public String getVirtualAdminPath()

setVirtualAdminPath

public void setVirtualAdminPath(String virutalAdminPath)

resourceExists

public boolean resourceExists(Object resourceId)
                       throws ResourceManagerException
Description copied from interface: ResourceManager
Checks if a resource exists wihtout being in a transaction. This means only take into account resources already globally commited.

Specified by:
resourceExists in interface ResourceManager
Overrides:
resourceExists in class FileResourceManager
Parameters:
resourceId - identifier for the resource to check for
Returns:
true if the resource exists
Throws:
ResourceManagerException - if an error occured

resourceExists

public boolean resourceExists(Object txId,
                              Object resourceId)
                       throws ResourceManagerException
Description copied from interface: ResourceManager
Checks if a resource exists.

Specified by:
resourceExists in interface ResourceManager
Overrides:
resourceExists in class FileResourceManager
Parameters:
txId - identifier for the transaction in which the resource is to be checked for
resourceId - identifier for the resource to check for
Returns:
true if the resource exists
Throws:
ResourceManagerException - if an error occured

deleteResource

public void deleteResource(Object txId,
                           Object resourceId)
                    throws ResourceManagerException
Description copied from interface: ResourceManager
Deletes a resource.

Specified by:
deleteResource in interface ResourceManager
Overrides:
deleteResource in class FileResourceManager
Parameters:
txId - identifier for the transaction in which the resource is to be deleted
resourceId - identifier for the resource to be deleted
Throws:
ResourceManagerException - if the resource does not exist or any other error occured

deleteResource

public void deleteResource(Object txId,
                           Object resourceId,
                           boolean assureOnly)
                    throws ResourceManagerException
Description copied from interface: ResourceManager
Deletes a resource.

Specified by:
deleteResource in interface ResourceManager
Overrides:
deleteResource in class FileResourceManager
Parameters:
txId - identifier for the transaction in which the resource is to be deleted
resourceId - identifier for the resource to be deleted
assureOnly - if set to true this method will not throw an exception when the resource does not exist
Throws:
ResourceManagerException - if the resource does not exist and assureOnly was not set to true or any other error occured

createResource

public void createResource(Object txId,
                           Object resourceId)
                    throws ResourceManagerException
Description copied from interface: ResourceManager
Creates a resource.

Specified by:
createResource in interface ResourceManager
Overrides:
createResource in class FileResourceManager
Parameters:
txId - identifier for the transaction in which the resource is to be created
resourceId - identifier for the resource to be created
Throws:
ResourceManagerException - if the resource already exist or any other error occured

createResource

public void createResource(Object txId,
                           Object resourceId,
                           boolean assureOnly)
                    throws ResourceManagerException
Description copied from interface: ResourceManager
Creates a resource.

Specified by:
createResource in interface ResourceManager
Overrides:
createResource in class FileResourceManager
Parameters:
txId - identifier for the transaction in which the resource is to be created
resourceId - identifier for the resource to be created
assureOnly - if set to true this method will not throw an exception when the resource already exists
Throws:
ResourceManagerException - if the resource already exists and assureOnly was not set to true or any other error occured

copyResource

public void copyResource(Object txId,
                         Object fromResourceId,
                         Object toResourceId,
                         boolean overwrite)
                  throws ResourceManagerException
Overrides:
copyResource in class FileResourceManager
Throws:
ResourceManagerException

moveResource

public void moveResource(Object txId,
                         Object fromResourceId,
                         Object toResourceId,
                         boolean overwrite)
                  throws ResourceManagerException
Overrides:
moveResource in class FileResourceManager
Throws:
ResourceManagerException

readResource

public InputStream readResource(Object resourceId)
                         throws ResourceManagerException
Description copied from interface: ResourceManager
Opens a streamable resource for a single reading request not inside the scope of a transaction.

Important: By contract, the application is responsible for closing the stream after its work is finished.

Specified by:
readResource in interface ResourceManager
Overrides:
readResource in class FileResourceManager
Parameters:
resourceId - identifier for the streamable resource to be opened
Returns:
stream to read from
Throws:
ResourceManagerException - if the resource does not exist or any other error occured

readResource

public InputStream readResource(Object txId,
                                Object resourceId)
                         throws ResourceManagerException
Description copied from interface: ResourceManager
Opens a streamable resource for reading.

Important: By contract, the application is responsible for closing the stream after its work is finished.

Specified by:
readResource in interface ResourceManager
Overrides:
readResource in class FileResourceManager
Parameters:
txId - identifier for the transaction in which the streamable resource is to be openend
resourceId - identifier for the streamable resource to be opened
Returns:
stream to read from
Throws:
ResourceManagerException - if the resource does not exist or any other error occured

checkForVirtualAdminCommand

protected void checkForVirtualAdminCommand(Object resourceId)
                                    throws ResourceManagerException
Throws:
ResourceManagerException

isVirtualAdminId

protected boolean isVirtualAdminId(Object resourceId)

executeAdminCommand

protected InputStream executeAdminCommand(Object resourceId)

isAKnowCommand

protected boolean isAKnowCommand(String command)

writeResource

public OutputStream writeResource(Object txId,
                                  Object resourceId,
                                  boolean append)
                           throws ResourceManagerException
Overrides:
writeResource in class FileResourceManager
Throws:
ResourceManagerException


Copyright © 2004-2009 Apache Software Foundation. All Rights Reserved.