refs #200: Create accouting-lib library
https://support.d4science.org/issues/200 Setting path for fallback git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115392 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
eabfa1c9ff
commit
4beb233a62
|
@ -30,7 +30,6 @@ public abstract class Persistence {
|
|||
protected static Persistence persistence;
|
||||
protected static FallbackPersistence fallback;
|
||||
|
||||
|
||||
private static File file(File file) throws IllegalArgumentException {
|
||||
|
||||
if (file.isDirectory())
|
||||
|
@ -44,21 +43,18 @@ public abstract class Persistence {
|
|||
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
File file;
|
||||
/*
|
||||
try {
|
||||
ContainerContext containerContext = ProviderFactory.provider().containerContext();
|
||||
org.gcube.smartgears.persistence.Persistence smartgearPersistence = containerContext.persistence();
|
||||
file = smartgearPersistence.writefile(ACCOUTING_FALLBACK_FILENAME);
|
||||
} catch(Exception e){
|
||||
file = file(new File(".", ACCOUTING_FALLBACK_FILENAME).getAbsolutePath());
|
||||
public synchronized static void setFallbackLocation(String path){
|
||||
if(fallback == null){
|
||||
if(path==null){
|
||||
path = ".";
|
||||
}
|
||||
*/
|
||||
|
||||
file = file(new File(".", ACCOUTING_FALLBACK_FILENAME));
|
||||
File file = file(new File(path, ACCOUTING_FALLBACK_FILENAME));
|
||||
fallback = new FallbackPersistence(file);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void init() {
|
||||
setFallbackLocation(null);
|
||||
try {
|
||||
/*
|
||||
ServiceLoader<Persistence> serviceLoader = ServiceLoader.load(Persistence.class);
|
||||
|
@ -95,11 +91,11 @@ public abstract class Persistence {
|
|||
|
||||
serviceUsageRecord.setResourceScope("/gcube/devsec");
|
||||
|
||||
Calendar creatingTime = new GregorianCalendar();
|
||||
Calendar creationTime = new GregorianCalendar();
|
||||
//Calendar startTime = new GregorianCalendar();
|
||||
//Calendar endTime = new GregorianCalendar();
|
||||
|
||||
serviceUsageRecord.setCreationTime(creatingTime);
|
||||
serviceUsageRecord.setCreationTime(creationTime);
|
||||
//usageRecord.setStartTime(startTime);
|
||||
//usageRecord.setEndTime(endTime);
|
||||
|
||||
|
@ -129,6 +125,9 @@ public abstract class Persistence {
|
|||
* @throws Exception if fails
|
||||
*/
|
||||
public static Persistence getInstance() {
|
||||
if(persistence==null){
|
||||
init();
|
||||
}
|
||||
return persistence;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue