From 8a2d672b6d2ac981376b9f427e934c4d3c12250f Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 1 Mar 2016 15:20:48 +0000 Subject: [PATCH] refs #2358: Remove reflections dependency from accounting-lib https://support.d4science.org/issues/2358 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@124717 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../persistence/AccountingPersistenceFactory.java | 8 ++++++-- src/test/java/org/gcube/testutility/TestUsageRecord.java | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java index 6798def..ce1cad8 100644 --- a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java +++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceFactory.java @@ -22,12 +22,16 @@ public class AccountingPersistenceFactory { protected final static Map persistences; - static { - persistences = new HashMap(); + public static void initAccountingPackages(){ PersistenceBackendFactory.addRecordPackage(ServiceUsageRecord.class.getPackage()); PersistenceBackendFactory.addRecordPackage(AggregatedServiceUsageRecord.class.getPackage()); } + static { + persistences = new HashMap(); + initAccountingPackages(); + } + public static void setFallbackLocation(String path){ PersistenceBackendFactory.setFallbackLocation(path); } diff --git a/src/test/java/org/gcube/testutility/TestUsageRecord.java b/src/test/java/org/gcube/testutility/TestUsageRecord.java index f495ed3..354a260 100644 --- a/src/test/java/org/gcube/testutility/TestUsageRecord.java +++ b/src/test/java/org/gcube/testutility/TestUsageRecord.java @@ -17,6 +17,7 @@ import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord; import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord; import org.gcube.accounting.datamodel.usagerecords.TaskUsageRecord; +import org.gcube.accounting.persistence.AccountingPersistenceFactory; import org.gcube.documentstore.exception.InvalidValueException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,6 +60,10 @@ public class TestUsageRecord { private final static long MIN_DURATION = 60; // millisec private final static long MAX_DURATION = 1000; // millisec + static { + AccountingPersistenceFactory.initAccountingPackages(); + } + /** * Generate A Random long in a range between min and max. * This function is internally used to set random duration.