transactionManager.setRollbackOnly();
} catch ( Exception e ) {
//FIXME: Use LogStrings.properties
_logger.log(Level.FINEST, "", e);
}
throw new TransactionRolledbackLocalException("", ex);
}
// If the client's tx is going to rollback, it is fruitless
// to invoke the EJB, so throw an exception back to client.
if ( status == Status.STATUS_MARKED_ROLLBACK
|| status == Status.STATUS_ROLLEDBACK
|| status == Status.STATUS_ROLLING_BACK ) {
throw new TransactionRolledbackLocalException("Client's transaction aborted");
}
container.validateEMForClientTx(inv, (JavaEETransaction) clientTx);
if ( prevTx == null || prevStatus == Status.STATUS_NO_TRANSACTION ) {
// First time the bean is running in this new client Tx
EJBContextImpl context = (EJBContextImpl)inv.context;
//Must change this for singleton
if (! container.isSingleton) {
context.setTransaction(clientTx);
}
try {
transactionManager.enlistComponentResources();
if ( !container.isStatelessSession && !container.isMessageDriven && !container.isSingleton) {
// Create a Synchronization object.
// Not needed for stateless beans or message-driven beans
// or singletons because they cant have Synchronization callbacks,
// and they cant be associated with a tx across
// invocations.
// Register sync for methods other than finders/home methods
if ( !inv.invocationInfo.isHomeFinder ) {
ejbContainerUtilImpl.getContainerSync(clientTx).addBean(
context);
}
container.afterBegin(context);
}
} catch (Exception ex) {
try {
transactionManager.setRollbackOnly();
} catch ( Exception e ) {
//FIXME: Use LogStrings.properties
_logger.log(Level.FINEST, "", e);
}
throw new TransactionRolledbackLocalException("", ex);
}
} else { // Bean already has a transaction associated with it.
if ( !prevTx.equals(clientTx) ) {
// There is already a different Tx in progress !!
// Note: this can only happen for stateful SessionBeans.
// EntityBeans will get a different context for every Tx.
if ( container.isSession ) {
// Row 2 in Table E
throw new IllegalStateException(
"EJB is already associated with an incomplete transaction");
}
} else { // Bean was invoked again with the same transaction
// This allows the TM to enlist resources used by the EJB
// with the transaction
try {
transactionManager.enlistComponentResources();
} catch (Exception ex) {
try {
transactionManager.setRollbackOnly();
} catch ( Exception e ) {
//FIXME: Use LogStrings.properties
_logger.log(Level.FINEST, "", e);
}
throw new TransactionRolledbackLocalException("", ex);
}
}
}
}