}
}
public void onEntry() throws SystemException, NotSupportedException {
TransactionManager manager = null;
synchronized (this) {
if (this.manager != null) {
manager = this.manager; // Stack confinement
} else {
return; // Nothing can be done...
}
}
Transaction transaction = manager.getTransaction();
switch (propagation) {
case REQUIRES:
// Are we already in a transaction?
if (transaction == null) {
// No, create one
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
m_owned.put(Thread.currentThread(), manager.getTransaction());
} else {
// Add the transaction to the transaction list
handler.addTransaction(transaction);
}
break;
case MANDATORY:
if (transaction == null) {
// Error
throw new IllegalStateException("The method " + method + " must be called inside a transaction");
} else {
// Add the transaction to the transaction list
handler.addTransaction(transaction);
}
break;
case SUPPORTED:
// if transaction != null, register the callback, else do nothing
if (transaction != null) {
handler.addTransaction(transaction);
} // Else do nothing.
break;
case NOT_SUPPORTED:
// Do nothing.
break;
case NEVER:
if (transaction != null) {
throw new IllegalStateException("The method " + method + " must never be called inside a transaction");
}
break;
case REQUIRES_NEW:
if (transaction == null) {
// No current transaction, Just creates a new one
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
m_owned.put(Thread.currentThread(), manager.getTransaction());
} else {
if (suspended == null) {
suspended = manager.suspend();
if (timeout > 0) {
manager.setTransactionTimeout(timeout);
}
manager.begin();
m_owned.put(Thread.currentThread(), manager.getTransaction());
} else {
throw new IllegalStateException("The method " + method + " requires to suspend a second times a transaction");
}
}
break;