|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@Deprecated @XmlElement(value="Transaction") public interface Transaction
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. The AUTO_COMMIT
constant is used to represent an immediate mode where requests are immediately commited.
Example use:
Transaction t = ... t.putProperty("someHint", someValue); try { FeatureCollection road = store.getFeatures("road"); FeatureCollection river = store.getFeatures("river"); road .setTransaction(t); river.setTransaction(t); // Provides authorization and operates against transaction t.useAuthorization(authorizationID); road .removeAll(road .subCollection(filter)); river.removeAll(river.subCollection(filter)); t.commit(); // Commit operations } catch (IOException exception){ t.rollback(); // Cancel operations throw exception; // Propagate the exception } finally { t.close(); // free resources }
Example code walkthrough from the perspective of transaction:
putProperty(key, value)
FeatureStore
s. This may result in several
Transaction.State
instances being registered. These instances of
transaction state may make use of any hint provided as properties
(in previous step) when they are connected with
State.setTransaction(t)
.t.useAuthorization(authorizationID)
is called.
Each Transaction.State
has its
addAuthorization
callback invoked with the value of authorizationID
.removeAll
methods are called on the two
FeatureCollection
s. Any of these opperations may make use of the
hints provided as properties.
Nested Class Summary | |
---|---|
static interface |
Transaction.State
Deprecated. FeatureStore implementations can use this interface to externalize the
state they require to implement Transaction support. |
Field Summary | |
---|---|
static Transaction |
AUTO_COMMIT
Deprecated. Marker constant used to indicate immidiate response. |
Method Summary | |
---|---|
void |
close()
Deprecated. Provides an opportunity for a transaction to free any State it maintains. |
LockResponse |
commit()
Deprecated. Makes all transactions made since the previous commit/rollback permanent. |
Set<String> |
getAuthorizations()
Deprecated. Returns the set of authorizations IDs held by this transaction. |
Object |
getProperty(Object key)
Deprecated. Retrieves a transaction property held by this transaction. |
Transaction.State |
getState(Object key)
Deprecated. Retrieve a state used to squirel away information (and callbacks) for later. |
void |
putProperty(Object key,
Object value)
Deprecated. Provides a property for this transasction. |
void |
putState(Object key,
Transaction.State state)
Deprecated. Allows FeatureStore to squirel away information (and callbacks) for later. |
void |
removeState(Object key)
Deprecated. Allows FeatureStore s to clean up information (and callbacks) they earlier provided. |
void |
rollback()
Deprecated. Undoes all transactions made since the last commit or rollback. |
void |
useAuthorization(String authorizationID)
Deprecated. Uses an Authorization token with this transaction. |
Field Detail |
---|
static final Transaction AUTO_COMMIT
Method Detail |
---|
void putProperty(Object key, Object value) throws IOException
FeatureStore
operations may make use of the provided property.
IOException
- if there are problems with the feature store.getProperty(java.lang.Object)
Object getProperty(Object key)
FeatureStore
implementations.
It operates as a blackboard for client, FeatureStore
communication.
putProperty(java.lang.Object, java.lang.Object)
void useAuthorization(String authorizationID) throws IOException
All FeatureCollection
s operations can make use of the provided authorization
for the duration of this transaction. Authorization is only maintained until this
transaction is commited or rolled back.
That is operations that modify or delete a feature will only succeed if affected features
either:
authorizationID
You may call this method several times to provide authorization token to multiple feature collections.
authorizationID
- Authorization ID. Should of been obtained from a LockResponse
.
IOException
- if there are problems with the feature store.getAuthorizations()
Set<String> getAuthorizations()
commit()
or rollback()
.
useAuthorization(java.lang.String)
void putState(Object key, Transaction.State state)
FeatureStore
to squirel away information (and callbacks) for later.
The most common example is a JDBC FeatureStore
saving the required
connection for later opperations.
This method will call
State.setTransaction(this)
to allow State
a chance to configure itself.
key
- Key used to externalize Statestate
- Externalized StateremoveState(java.lang.Object)
,
getState(java.lang.Object)
void removeState(Object key)
FeatureStore
s to clean up information (and callbacks) they earlier provided.
Care should be taken when using shared State to not remove State required by another
feature sources.
State.setTransaction(null)
to allow State
a chance cleanup after itself.
key
- Key that was used to externalize StateTransaction.State getState(Object key)
key
- Key that was used to externalize State
null
if not foundLockResponse commit() throws IOException
FeatureStore
s will need to issue any changes notifications using a
FeatureEvent
to all FeatureStore
s with the
same type name and a different transaction. FeatureStore
s with the
same transaction will been notified of changes as the feature writer made
them.
Workflows:
LockRequest
+ Transaction
returns a LockResponse
as the result of any and all lock requests made during the transaction.Transaction
returns LockResponse.NONE
when no lock requests
are made.For a discussion of these workflows please read the package javadocs.
LockResponse.NONE
if no lock requests were made.
IOException
- if there are problems with the feature store.void rollback() throws UnsupportedOperationException, IOException
FeatureStore
s will need to issue any changes notifications using a
FeatureEvent
. This will need to be issued to all
FeatureStore
s with the same type name and transaction.
UnsupportedOperationException
- if the rollback method is not
supported by this datasource.
IOException
- if there are problems with the feature store.void close() throws IOException
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
AUTO_COMMIT
.
IOException
- if there are problems with the feature store.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |