| |
|
| java.lang.Object net.sf.jmoney.model2.DataManager net.sf.jmoney.isolation.TransactionManager
TransactionManager | public class TransactionManager extends DataManager (Code) | | A transaction manager must be set before the datastore can be modified.
An exception will be throw if an attempt is made to modify the datastore
(setting a property, or creating or deleting an extendable object) when
no transaction manager is set in the session.
Changes to the datastore are stored in the transaction manager. They
are not applied to the underlying datastore until the transaction is
committed. Read accesses (property getters and queries) are passed on
to any transaction manager which will modify the results to reflect
changes stored in the transaction.
author: Nigel Westbury |
Inner Class :class DeletedObject | |
Constructor Summary | |
public | TransactionManager(DataManager baseDataManager) Construct a transaction manager for use with the given session.
The transaction manager does not become the active transaction
manager for the session until it is specifically set as the
active transaction manager. |
Method Summary | |
public void | commit() Apply the changes that are stored in this transaction manager. | public void | commit(String label) This method does the same as the commit() method but the changes
may be undone and redone. | public void | commitTransaction() This method is called when a nested transaction manager has completed
making changes to our data. | public Object | getAdapter(Class adapter) | public E | getCopyInTransaction(E committedObject) Given an instance of an object in the datastore
(i.e. | public Collection<Entry> | getEntries(Account account) | public Session | getSession() | public boolean | hasChanges() Indicate whether there are any uncommitted changes being held
by this transaction manager. | public boolean | hasEntries(Account account) | public void | startTransaction() This method is called when a nested transaction manager is about to apply its
changes to our data. |
allObjects | Map<IObjectKey, ExtendableObject> allObjects(Code) | | Every extendable object that has ever been created in this transaction and passed
to the user is in this map. This is required because all DataManager
objects must guarantee that there is only ever a single instance of an
object in existence.
Objects that were created in this transaction are not in this map.
There is only one instance of such objects in any case, so only that one
instance would be returned.
The object key is the key in the committed datastore. Only objects
that exist in the underlying datastore are in this map, and it is
just easier to use the committed key than to use an uncommitted key.
|
modifiedLists | Set<DeltaListManager> modifiedLists(Code) | | Every list that has been modified by this transaction manager
(objects added to the list or objects removed from the list)
will have an entry in this set. This enables the transaction
manager to easily find the added and deleted objects when committing
the changes.
|
modifiedObjects | Map<IObjectKey, ModifiedObject> modifiedObjects(Code) | | Maps IObjectKey to Map, where IObjectKey is the key in the comitted
datastore and each Map maps PropertyAccessor to the value of that
property. Every object that has been modified by this transaction manager
(a scalar property in the object has been changed) will have an entry in
this map. The map keys are objects from the datastore and will contain
the property values that are currently committed in the datastore. The
map values are objects that contain details of the changes (changed
scalar property values, or an indication that the object has been
deleted).
If a value of a property is a reference to another object then an
UncommittedObjectKey is stored as the value. By doing this, the
referenced object does not need to be materialized unless necessary.
Deleted objects will also have an entry in this map. If an object
contains list properties and the object is deleted then all the objects
in the lists will also be added to this map with a ModifiedObject that
has a 'deleted' indication. This is necessary because this list is used
to determine if an object has been deleted, to ensure that we do not
attempt to modify a property value in an object that has in fact been
deleted.
|
TransactionManager | public TransactionManager(DataManager baseDataManager)(Code) | | Construct a transaction manager for use with the given session.
The transaction manager does not become the active transaction
manager for the session until it is specifically set as the
active transaction manager. By separating the construction of
the transaction manager from the activating of the transaction manager,
a transaction manager can be created and listeners can be set up to
listen to session changes within the transaction manager during an
initialization stage even though the transaction is not made active
until changes are made.
Parameters: session - the session object from the committed datastore |
commit | public void commit()(Code) | | Apply the changes that are stored in this transaction manager.
When changes are committed, they are seen in the datastore
and also in the version of the datastore as seen through other
transaction managers.
All datastore listeners and all listeners which are listening
for changes ......
|
commit | public void commit(String label)(Code) | | This method does the same as the commit() method but the changes
may be undone and redone. This support is available with no
coding needed by the caller other than to pass the label to be
used to describe the operation.
Parameters: label - the label to be used to describe this operationfor undo/redo purposes |
commitTransaction | public void commitTransaction()(Code) | | This method is called when a nested transaction manager has completed
making changes to our data.
|
getCopyInTransaction | public E getCopyInTransaction(E committedObject)(Code) | | Given an instance of an object in the datastore
(i.e. committed), obtain a copy of the object that
is in the version of the datastore managed by this
transaction manager.
Updates to property values in the returned object will
not be applied to the datastore until the changes held
by this transaction manager are committed to the datastore.
Parameters: an - object that exists in the datastore (committed) a copy of the given object, being an uncommitted versionof the object in this transaction, or null if thegiven object has been deleted in this transaction |
getSession | public Session getSession()(Code) | | a session object representing an uncommittedsession object managed by this transaction manager |
hasChanges | public boolean hasChanges()(Code) | | Indicate whether there are any uncommitted changes being held
by this transaction manager. This method is useful when the user
does something like selecting another transaction or closing a
dialog box and it is not clear whether the user wants to commit
or to cancel changes.
true if property values have been changed or objectshave been created or deleted within the context of thistransaction manager since the last commit |
hasEntries | public boolean hasEntries(Account account)(Code) | | Parameters: account - |
startTransaction | public void startTransaction()(Code) | | This method is called when a nested transaction manager is about to apply its
changes to our data.
|
|
|
|