org.geotools.data
Class DefaultTransaction

java.lang.Object
  extended byorg.geotools.data.DefaultTransaction
All Implemented Interfaces:
Transaction

public class DefaultTransaction
extends java.lang.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 inherited from class org.geotools.data.Transaction
Transaction.State
 
Field Summary
 
Fields inherited from interface org.geotools.data.Transaction
AUTO_COMMIT
 
Constructor Summary
DefaultTransaction()
           
DefaultTransaction(java.lang.String handle)
           
 
Method Summary
 void addAuthorization(java.lang.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.
 java.util.Set getAuthorizations()
          The current set of Authorization IDs held by this Transaction.
 java.lang.Object getProperty(java.lang.Object key)
          Implementation of getProperty.
 Transaction.State getState(java.lang.Object key)
          Returns externalized state or null if not available.
 void putProperty(java.lang.Object key, java.lang.Object value)
          Implementation of addProperty.
 void putState(java.lang.Object key, Transaction.State state)
          Remembers Externalized State for a DataSource.
 void removeState(java.lang.Object key)
          Removes state from DefaultTransaction's care.
 void rollback()
          Rollsback all modifications against this Transaction.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultTransaction

public DefaultTransaction()

DefaultTransaction

public DefaultTransaction(java.lang.String handle)
Method Detail

putState

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

This is the GOF Momento pattern: a FeatureSource 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 FeatureSource 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:
java.lang.IllegalArgumentException - When Transaction already using key
See Also:
Transaction.putState(java.lang.Object, org.geotools.data.Transaction.State)

removeState

public void removeState(java.lang.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:
java.lang.IllegalArgumentException - If no State was maintained for supplied key
See Also:
Transaction.removeState(java.lang.Object)

getState

public Transaction.State getState(java.lang.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 java.io.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:
java.io.IOException - Encountered problem maintaining transaction state
DataSourceException - See IOException
See Also:
Transaction.commit()

rollback

public void rollback()
              throws java.io.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:
java.io.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 java.util.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(java.lang.String authID)
                      throws java.io.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:
java.io.IOException - Encountered problems maintaing Transaction State
DataSourceException - See IOException
See Also:
org.geotools.data.Transaction#setAuthorization(java.lang.String)

toString

public java.lang.String toString()

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Implementation of getProperty.

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

putProperty

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

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


Copyright © GeoTools. All Rights Reserved.