Java Doc for Transaction.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.data 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.geotools.data.Transaction

All known Subclasses:   org.geotools.data.DefaultTransaction,  org.geotools.arcsde.data.ArcTransactionState,  org.geotools.data.AutoCommitTransaction,
Transaction
public interface Transaction (Code)
The controller for Transaction with FeatureStore.

Shapefiles, databases, etc. are safely modified with the assistance of this interface. Transactions are also to provide authorization when working with locked features.

All operations are considered to be working against a Transaction. Transaction.AUTO_COMMIT is used to represent an immidiate mode where requests are immidately commited.

For more information please see DataStore and FeatureStore.

Example Use:


 Transaction t = new DefaultTransaction("handle");
 t.putProperty( "hint", new Integer(7) );
 try {
 FeatureStore road = (FeatureStore) store.getFeatureSource("road");
 FeatureStore river = (FeatureStore) store.getFeatureSource("river");
 road.setTransaction( t );
 river.setTransaction( t );
 t.addAuthorization( lockID );  // provide authoriztion
 road.removeFeatures( filter ); // operate against transaction
 river.removeFeature( filter ); // operate against transaction
 t.commit(); // commit operations
 }
 catch (IOException io){
 t.rollback(); // cancel operations
 }
 finally {
 t.close(); // free resources
 }
 

Example code walkthrough (from the perspective of Transaction):

  1. A new transaction is created (an instanceof DefaultTransaction with a handle)
  2. A hint is provided using Transaction.putProperty( key, value )
  3. Transaction is provided to two FeatureStores, this may result in Transaction.State instances being registered
    • TransactionStateDiff (stored by DataStore): Used for in memory locking is used by many DataStore's (like ShapefileDataStore). Lazy creation by AbstractDataStore.state(transaction).
    • JDBCTransactionState (stored by ConnectionPool): Used to manage connection rollback/commit. Lazy creation as part of JDBCDataStore.getConnection(transaction).
    • InProcessLockingManager.FeatureLock (stored by LockingManger): Used for per transaction FeatureLocks, used to free locked features on Transaction commit/rollback.
    These instances of Transaction state may make use of any hint provided to Transaction.putProperty( key, value ) when they are connected with Transaction.State.setTransaction( transaction ).
  4. t.addAuthorization(lockID) is called, each Transaction.State has its addAuthroization(String) callback invoked with the value of lockID
  5. FeatureStore.removeFeatures methods are called on the two DataStores.
    • PostgisFeatureStore.removeFeatures(fitler) handles operation without delegation.
    • Most removeFeature(filter) implementations use the implementation provided by AbstractFeatureStore which delegates to FeatureWriter.
    Any of these operations may make use of the Transaction.putProperty( key, value ).
  6. The transaction is commited, all of the Transaction.State methods have there Transaction.State.commit() methods called gicing them a chance to applyDiff maps, or commit various connections.
  7. The transaction is closed, all of the Transaction.State methods have there Transaction.State.setTransaction( null ) called, giving them a chance to clean up diffMaps, or return connections to the pool.

author:
   Jody Garnett
author:
   Chris Holmes, TOPP
version:
   $Id: Transaction.java 23258 2006-12-06 19:30:14Z tmarti $

Inner Class :public static interface State

Field Summary
final static  TransactionAUTO_COMMIT
    


Method Summary
 voidaddAuthorization(String authID)
     Provides an Authorization ID for this Transaction.
 voidclose()
     Provides an opportunity for a Transaction to free an State it maintains.
 voidcommit()
     Makes all transactions made since the previous commit/rollback permanent.

FeatureSources will need to issue any changes notifications using a FeatureEvent.FEATURES_CHANGED to all FeatureSources with the same typeName and a different Transaction.

 SetgetAuthorizations()
     List of Authorizations IDs held by this transaction.
 ObjectgetProperty(Object key)
     Retrive a Transaction property held by this transaction.
 StategetState(Object key)
     Allows DataStores to squirel away information( and callbacks ) for later.
 voidputProperty(Object key, Object value)
     Provides a Transaction property for this Transasction.
 voidputState(Object key, State state)
     Allows FeatureSource to squirel away information( and callbacks ) for later.
 voidremoveState(Object key)
     Allows FeatureSources to clean up information ( and callbacks ) they earlier provided.
 voidrollback()
     Undoes all transactions made since the last commit or rollback.

FeatureSources will need to issue any changes notifications using a FeatureEvent.FEATURES_CHANGED.


Field Detail
AUTO_COMMIT
final static Transaction AUTO_COMMIT(Code)
Represents AUTO_COMMIT Mode





Method Detail
addAuthorization
void addAuthorization(String authID) throws IOException(Code)
Provides an Authorization ID for this Transaction.

All proceeding modifyFeatures,removeFeature, unLockFeatures, refreshLock and ReleaseLock operations will make use of the provided authorization.

Authorization is only maintained until the this Transaction is commited or rolledback.

That is operations will only succeed if affected features either:

  • not locked
  • locked with the provided authID

Authorization ID is provided as a String, rather than a FeatureLock, to account for across process lock use.


Parameters:
  authID -



close
void close() throws IOException(Code)
Provides an opportunity for a Transaction to free an State it maintains.

This method should call State.setTransaction( null ) on all State it maintains.

It is hoped that FeatureStore implementations that have externalized their State with the transaction take the opportunity to revert to Transction.AUTO_COMMIT.


throws:
  IOException -



commit
void commit() throws IOException(Code)
Makes all transactions made since the previous commit/rollback permanent.

FeatureSources will need to issue any changes notifications using a FeatureEvent.FEATURES_CHANGED to all FeatureSources with the same typeName and a different Transaction. FeatureSources with the same Transaction will of been notified of changes as the FeaureWriter made them.


throws:
  DataSourceException - if there are any datasource errors.
See Also:   Transaction.setAutoCommit(boolean)



getAuthorizations
Set getAuthorizations()(Code)
List of Authorizations IDs held by this transaction.

This list is reset by the next call to commit() or rollback().

Authorization IDs are used to provide FeatureLock support.

List of Authorization IDs



getProperty
Object getProperty(Object key)(Code)
Retrive a Transaction property held by this transaction.

This may be used to provide hints to DataStore implementations, it operates as a blackboard for client, FeatureSource communication.

If this proves successful addAuthorization/getAuthorization will be replaced with this mechanism.




getState
State getState(Object key)(Code)
Allows DataStores to squirel away information( and callbacks ) for later.

The most common example is a JDBC DataStore saving the required connection for later operations.

Current State externalized by key, or null if notfound



putProperty
void putProperty(Object key, Object value) throws IOException(Code)
Provides a Transaction property for this Transasction.

All proceeding FeatureSource (for FeatureReader/Writer) operations may make use of the provided property.




putState
void putState(Object key, State state)(Code)
Allows FeatureSource to squirel away information( and callbacks ) for later.

The most common example is a JDBC DataStore saving the required connection for later operations.


 ConnectionState implements State {
 public Connection conn;
 public addAuthorization() {}
 public commit(){ conn.commit(); }
 public rollback(){ conn.rollback(); }
 }
 

putState will call State.setTransaction( transaction ) to allow State a chance to configure itself.


Parameters:
  key - Key used to externalize State
Parameters:
  state - Externalized State



removeState
void removeState(Object key)(Code)
Allows FeatureSources to clean up information ( and callbacks ) they earlier provided.

Care should be taken when using shared State to not remove State required by another FeatureSources.

removeState will call State.setTransaction( null ) to allow State a chance cleanup after itself.


Parameters:
  key - Key that was used to externalize State



rollback
void rollback() throws IOException(Code)
Undoes all transactions made since the last commit or rollback.

FeatureSources will need to issue any changes notifications using a FeatureEvent.FEATURES_CHANGED. This will need to be issued to all FeatureSources with the same typeName and Transaction.


throws:
  DataSourceException - if there are problems with the datasource.
throws:
  UnsupportedOperationException - if the rollback method is notsupported by this datasource.
See Also:   Transaction.setAutoCommit(boolean)



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.