public void close() {
ensureOpened();
ensureThatState(persistenceManager, is(notNullValue()));
try {
final IsisTransaction currentTransaction = getTransactionManager().getTransaction();
if (currentTransaction != null && !currentTransaction.getState().isComplete()) {
if(currentTransaction.getState().canCommit()) {
getTransactionManager().endTransaction();
} else if(currentTransaction.getState().canAbort()) {
getTransactionManager().abortTransaction();
}
}
} finally {
// make sure release everything ok.