public void finish()

in tx-control-services/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/TransactionContextImpl.java [284:337]


	public void finish() {
		
		if(!resources.isEmpty()) {
			XAResource localResource = new LocalXAResourceImpl();
			try {
				currentTransaction.enlistResource(localResource);
			} catch (Exception e) {
				safeSetRollbackOnly();
				recordFailure(e);
				try {
					localResource.rollback(null);
				} catch (XAException e1) {
					recordFailure(e1);
				}
			}
		}

		try {
			TxListener listener = new TxListener(); 
			try {
				transactionManager.registerInterposedSynchronization(listener);

				if (getRollbackOnly()) {
					// GERONIMO-4449 says that we get no beforeCompletion 
					// callback for rollback :(
					listener.beforeCompletion();
					transactionManager.rollback();
				} else {
					try {
						transactionManager.commit();
					} catch (RollbackException re) {
						if (re.getCause() instanceof SetRollbackOnlyException) {
							// This means that a pre-completion callback called setRollbackOnly
							// which can be safely ignored (i.e. it's not really an exception)
						} else {
							TransactionRolledBackException tre = 
								new TransactionRolledBackException(re.getMessage(), re);
							throw tre;
						}
					}
				}
			} catch (Exception e) {
				TransactionException te = e instanceof TransactionException ? (TransactionException) e :
					new TransactionException("An error occurred in the transaction", e);
				recordFailure(te);
			}
		} finally {
			try {
				transactionManager.resume(oldTran);
			} catch (Exception e) {
				recordFailure(e);
			}
		}
	}