use of com.genexus.db.InProcessCache in project JavaClasses by genexuslabs.
the class CacheFactory method getInstance.
public static ICacheService getInstance() {
if (instance == null) {
synchronized (syncRoot) {
if (instance == null) {
GXService providerService = Application.getGXServices().get(GXServices.CACHE_SERVICE);
if (providerService != null) {
String warnMsg = "Couldn't create CACHE_PROVIDER as ICacheService: " + providerService.getClassName();
try {
logger.info("Loading providerService:" + providerService.getClassName());
Class<?> type = Class.forName(providerService.getClassName());
if (type != null) {
ICacheService cacheInstance = (ICacheService) type.getDeclaredConstructor().newInstance();
if (cacheInstance != null) {
instance = cacheInstance;
if (providerService.getProperties().containsKey(FORCE_HIGHEST_TIME_TO_LIVE)) {
if (Integer.parseInt(providerService.getProperties().get(FORCE_HIGHEST_TIME_TO_LIVE)) == 1) {
forceHighestTimetoLive = true;
}
}
} else {
logger.error(warnMsg);
System.err.println(warnMsg);
}
}
} catch (Exception ex) {
logger.error(warnMsg, ex);
System.err.println(warnMsg);
ex.printStackTrace();
}
}
if (instance == null) {
instance = new InProcessCache();
}
LoadTTLFromPreferences();
}
}
}
return instance;
}
Aggregations