use of org.wso2.carbon.apimgt.persistence.utils.RegistryLCManager in project carbon-apimgt by wso2.
the class LCManagerFactory method getLCManager.
public RegistryLCManager getLCManager() throws PersistenceException {
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String cacheName = tenantDomain + "_" + APIConstants.LC_CACHE_NAME;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
Cache lcCache = Caching.getCacheManager(APIConstants.API_MANAGER_CACHE_MANAGER).getCache(APIConstants.LC_CACHE_NAME);
RegistryLCManager lcManager = (RegistryLCManager) lcCache.get(cacheName);
if (lcManager != null) {
log.debug("Lifecycle info servered from Cache.");
return lcManager;
} else {
try {
log.debug("Lifecycle info not found in Cache.");
lcManager = new RegistryLCManager(tenantId);
lcCache.put(cacheName, lcManager);
return lcManager;
} catch (RegistryException | XMLStreamException | ParserConfigurationException | SAXException | IOException e) {
throw new PersistenceException("Error while accessing the lifecycle resource ", e);
}
}
}
Aggregations