rmp-common-library/src/main/java/org/gcube/resourcemanagement/support/utils/persistence/TestPersistence.java

47 lines
1.1 KiB
Java

package org.gcube.resourcemanagement.support.utils.persistence;
import java.io.File;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.resourcemanagement.support.managers.scope.ScopeManager;
import org.gcube.resourcemanagement.support.utils.ServerConsole;
public class TestPersistence {
/**
* @param args
*/
public static void main(final String[] args) {
PersistentItem<GCUBEScope[]> persistentScopes = new PersistentItem<GCUBEScope[]>("data.xml", 10000) {
// Builds the data to persist
private void refreshData() {
try {
GCUBEScope[] toStore =
ScopeManager.getAvailableScopes().values().toArray(new GCUBEScope[]{});
this.setData(toStore);
} catch (Exception e) {
ServerConsole.error(LOG_PREFIX, e);
}
}
public void onLoad() {
ScopeManager.setScopeConfigFile("test-suite" + File.separator + "scopes" + File.separator + "scopedata_admin.xml");
this.refreshData();
}
public void onRefresh() {
this.refreshData();
GCUBEScope[] scopes = this.getData();
System.out.println(scopes);
}
public void onDestroy() {
this.setData(null);
}
};
}
}