diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistence.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistence.java index c79696a..cc25f23 100644 --- a/src/main/java/org/gcube/accounting/persistence/AccountingPersistence.java +++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistence.java @@ -21,7 +21,7 @@ public class AccountingPersistence { this.context = context; } - private PersistenceBackend getAccountingPersistence(){ + private PersistenceBackend getPersistenceBackend(){ return PersistenceBackendFactory.getPersistenceBackend(this.context); } @@ -36,14 +36,14 @@ public class AccountingPersistence { */ public void account(final Record record) throws InvalidValueException { try { - getAccountingPersistence().account(record); + getPersistenceBackend().account(record); } catch (org.gcube.documentstore.exception.InvalidValueException e) { throw new InvalidValueException(e); } } public void flush() throws Exception { - getAccountingPersistence().flush(); + getPersistenceBackend().flush(); } /** @@ -58,11 +58,11 @@ public class AccountingPersistence { } public void close() throws Exception{ - getAccountingPersistence().close(); + getPersistenceBackend().close(); } public boolean isConnectionActive() throws Exception { - return getAccountingPersistence().isConnectionActive(); + return getPersistenceBackend().isConnectionActive(); } } diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java index a474f2b..6964fc2 100644 --- a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java +++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java @@ -41,6 +41,7 @@ public class AccountingPersistenceFactory { AccountingPersistence accountingPersistence = persistences.get(context); if(accountingPersistence==null){ accountingPersistence = new AccountingPersistence(context); + persistences.put(context, accountingPersistence); } return accountingPersistence; }