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 Persistence persistence;
|
||||||
protected static FallbackPersistence fallback;
|
protected static FallbackPersistence fallback;
|
||||||
|
|
||||||
|
|
||||||
private static File file(File file) throws IllegalArgumentException {
|
private static File file(File file) throws IllegalArgumentException {
|
||||||
|
|
||||||
if (file.isDirectory())
|
if (file.isDirectory())
|
||||||
|
@ -44,21 +43,18 @@ public abstract class Persistence {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
public synchronized static void setFallbackLocation(String path){
|
||||||
|
if(fallback == null){
|
||||||
File file;
|
if(path==null){
|
||||||
/*
|
path = ".";
|
||||||
try {
|
}
|
||||||
ContainerContext containerContext = ProviderFactory.provider().containerContext();
|
File file = file(new File(path, ACCOUTING_FALLBACK_FILENAME));
|
||||||
org.gcube.smartgears.persistence.Persistence smartgearPersistence = containerContext.persistence();
|
fallback = new FallbackPersistence(file);
|
||||||
file = smartgearPersistence.writefile(ACCOUTING_FALLBACK_FILENAME);
|
|
||||||
} catch(Exception e){
|
|
||||||
file = file(new File(".", ACCOUTING_FALLBACK_FILENAME).getAbsolutePath());
|
|
||||||
}
|
}
|
||||||
*/
|
}
|
||||||
|
|
||||||
file = file(new File(".", ACCOUTING_FALLBACK_FILENAME));
|
protected static void init() {
|
||||||
fallback = new FallbackPersistence(file);
|
setFallbackLocation(null);
|
||||||
try {
|
try {
|
||||||
/*
|
/*
|
||||||
ServiceLoader<Persistence> serviceLoader = ServiceLoader.load(Persistence.class);
|
ServiceLoader<Persistence> serviceLoader = ServiceLoader.load(Persistence.class);
|
||||||
|
@ -95,11 +91,11 @@ public abstract class Persistence {
|
||||||
|
|
||||||
serviceUsageRecord.setResourceScope("/gcube/devsec");
|
serviceUsageRecord.setResourceScope("/gcube/devsec");
|
||||||
|
|
||||||
Calendar creatingTime = new GregorianCalendar();
|
Calendar creationTime = new GregorianCalendar();
|
||||||
//Calendar startTime = new GregorianCalendar();
|
//Calendar startTime = new GregorianCalendar();
|
||||||
//Calendar endTime = new GregorianCalendar();
|
//Calendar endTime = new GregorianCalendar();
|
||||||
|
|
||||||
serviceUsageRecord.setCreationTime(creatingTime);
|
serviceUsageRecord.setCreationTime(creationTime);
|
||||||
//usageRecord.setStartTime(startTime);
|
//usageRecord.setStartTime(startTime);
|
||||||
//usageRecord.setEndTime(endTime);
|
//usageRecord.setEndTime(endTime);
|
||||||
|
|
||||||
|
@ -129,6 +125,9 @@ public abstract class Persistence {
|
||||||
* @throws Exception if fails
|
* @throws Exception if fails
|
||||||
*/
|
*/
|
||||||
public static Persistence getInstance() {
|
public static Persistence getInstance() {
|
||||||
|
if(persistence==null){
|
||||||
|
init();
|
||||||
|
}
|
||||||
return persistence;
|
return persistence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue