Methods Summary |
---|
public void | afterCompletion(int status)This method will be called during transaction completion. No resource
access is allowed.
This method in turn calls each registered instance afterCompletion
method. After this method completes,
instances must register again in the new transaction, but
the synchronization manager remains bound to the persistence manager
transaction instance.
int size = synchronizations.size();
StringBuffer sb = null;
for (int i = 0; i < size; ++i) {
Synchronization instance = (Synchronization) synchronizations.get(i);
try {
instance.afterCompletion(status);
} catch (Exception e) {
if (sb == null) {
sb = new StringBuffer();
}
sb.append(e.getMessage()).append('\n"); // NOI18N
}
}
synchronizations.clear();
if (sb != null) {
throw new JDOUserException(sb.toString());
}
|
public void | beforeCompletion()This method will be called during transaction completion. Resource
access is allowed.
This method in turn calls each registered instance beforeCompletion
method.
int size = synchronizations.size();
for (int i = 0; i < size; ++i) {
Synchronization instance = (Synchronization) synchronizations.get(i);
instance.beforeCompletion();
}
|
protected static com.sun.jdo.api.persistence.support.SynchronizationManager | getSynchronizationManager(PersistenceManager pm)Get the synchronization manager already registered with this persistence manager.
If the synchronization instance is not of the proper class, then replace it with
a new instance of the synchronization manager, and register the previous synchronization
with the newly created synchronization manager.
Transaction tx = pm.currentTransaction();
Synchronization oldsync = tx.getSynchronization();
if (oldsync instanceof SynchronizationManager) {
// This is the one we want.
return (SynchronizationManager) oldsync;
} else {
// We need a new one. The constructor automatically registers it
// with the persistence manager.
SynchronizationManager newsync = new SynchronizationManager(pm);
if (oldsync != null) {
// There is an existing Synchronization to register with the new one
newsync.registerSynchronization(oldsync);
}
return newsync;
}
|
public static void | registerSynchronization(javax.transaction.Synchronization instance, PersistenceManager pm)Register a new Synchronization with the current transaction.
SynchronizationManager synchronizationManager = getSynchronizationManager(pm);
synchronizationManager.registerSynchronization(instance);
|
protected void | registerSynchronization(javax.transaction.Synchronization instance)Register an instance with this synchronization manager.
Note that this is not thread-safe. If multiple threads call this method
at the same time, the synchronizations List might become corrupt.
The correct way to fix this is to ask the PersistenceManager for the
Multithreaded flag and perform a synchronized add if the flag is true.
We currently do not have the Multithreaded flag implemented.
synchronizations.add(instance);
|
public static void | setDefaultCapacity(int capacity)Specify the default capacity of the list of Synchronizations.
defaultCapacity = capacity;
|