org.geotools.data
Class DefaultTransaction

Object
  extended by DefaultTransaction
All Implemented Interfaces:
Transaction

public class DefaultTransaction
extends Object
implements Transaction

Quick implementation of Transaction api.

Please see Transaction interface for an outline of what this class is all about.

Author:
Jody Garnett, Refractions Research

Nested Class Summary
 
Nested classes/interfaces inherited from interface Transaction
Transaction.State
 
Field Summary
protected static Logger LOGGER
          The logger for the data module.
 
Fields inherited from interface Transaction
AUTO_COMMIT
 
Constructor Summary
DefaultTransaction()
           
DefaultTransaction(String handle)
           
 
Method Summary
 void addAuthorization(String authID)
          Provides an authorization ID allowing access to locked Features.
 void close()
          Frees all State held by this Transaction.
 void commit()
          Commits all modifications against this Transaction.
protected  void finalize()
           
 Set getAuthorizations()
          The current set of Authorization IDs held by this Transaction.
 Object getProperty(Object key)
          Implementation of getProperty.
 Transaction.State getState(Object key)
          Returns externalized state or null if not available.
 void putProperty(Object key, Object value)
          Implementation of addProperty.
 void putState(Object key, Transaction.State state)
          Remembers Externalized State for a DataSource.
 void removeState(Object key)
          Removes state from DefaultTransaction's care.
 void rollback()
          Rollsback all modifications against this Transaction.
 String toString()
           
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER
The logger for the data module.

Constructor Detail

DefaultTransaction

public DefaultTransaction()

DefaultTransaction

public DefaultTransaction(String handle)
Method Detail

putState

public void putState(Object key,
                     Transaction.State state)
Remembers Externalized State for a DataSource.

This is the GOF Momento pattern: a SimpleFeatureSource is able to externalize its internal State required for Transaction support and have this class manage it. It may retrieve this State with getState( key ).

In addition several SimpleFeatureSource implementations may share State, a common example is JDBCDataSources keeping a shared JDBC connection using the JDBC URL as a key.

Specified by:
putState in interface Transaction
Parameters:
key - Key used to externalize State
state - Externalized State (Momeneto)
Throws:
IllegalArgumentException - When Transaction already using key
See Also:
Transaction.putState(java.lang.Object, org.geotools.data.Transaction.State)

removeState

public void removeState(Object key)
Removes state from DefaultTransaction's care.

Currently does not complain if there is no State associated with key to remove - this may change in the future.

Specified by:
removeState in interface Transaction
Parameters:
key -
Throws:
IllegalArgumentException - If no State was maintained for supplied key
See Also:
Transaction.removeState(java.lang.Object)

getState

public Transaction.State getState(Object key)
Returns externalized state or null if not available.

Used by DataStore implementations to externalize information required for Transaction support using the GOF Momento pattern.

Specified by:
getState in interface Transaction
Parameters:
key -
Returns:
Previously externalized State.
See Also:
Transaction.getState(java.lang.Object)

commit

public void commit()
            throws IOException
Commits all modifications against this Transaction.

This implementation will call commit() on all State managed by this Transaction. This allows DataStores to provide their own implementation of commit().

Specified by:
commit in interface Transaction
Throws:
IOException - Encountered problem maintaining transaction state
DataSourceException - See IOException
See Also:
Transaction.commit()

rollback

public void rollback()
              throws IOException
Rollsback all modifications against this Transaction.

This implementation will call rollback() on all State managed by this Transaction. This allows DataStores to provide their own implementation of rollback().

Specified by:
rollback in interface Transaction
Throws:
IOException - Encountered problem maintaining transaction State
DataSourceException - IOException
See Also:
Transaction.rollback()

close

public void close()
Frees all State held by this Transaction.

Specified by:
close in interface Transaction

getAuthorizations

public Set getAuthorizations()
The current set of Authorization IDs held by this Transaction.

This set is reset by the next call to commit or rollback.

Specified by:
getAuthorizations in interface Transaction
Returns:
Set of Authorization IDs

addAuthorization

public void addAuthorization(String authID)
                      throws IOException
Provides an authorization ID allowing access to locked Features.

Remember authorizations are cleared after every commit/rollback.

Specified by:
addAuthorization in interface Transaction
Parameters:
authID - Provided Authorization ID
Throws:
IOException - Encountered problems maintaing Transaction State
DataSourceException - See IOException
See Also:
org.geotools.data.Transaction#setAuthorization(java.lang.String)

toString

public String toString()
Overrides:
toString in class Object

getProperty

public Object getProperty(Object key)
Implementation of getProperty.

Specified by:
getProperty in interface Transaction
Parameters:
key -
See Also:
Transaction.getProperty(java.lang.Object)

putProperty

public void putProperty(Object key,
                        Object value)
                 throws IOException
Implementation of addProperty.

Specified by:
putProperty in interface Transaction
Parameters:
key -
value -
Throws:
IOException
See Also:
org.geotools.data.Transaction#addProperty(java.lang.Object, java.lang.Object)

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 1996-2014 Geotools. All Rights Reserved.