use of org.jaffa.loader.IManager in project jaffa-framework by jaffa-projects.
the class ConfigApiHelper method unregisterResources.
/**
* Unregister configuration files in IManager implementations, based on the source of the method call
* @param file The configuration file to be registered or unregistered
* @return Success or failure of the operation
*/
public static boolean unregisterResources(File file, FileContentsHelper fileContents) {
boolean isSuccess = true;
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
for (IManager manager : ManagerRepositoryService.getInstance().getManagerMap().values()) {
Resource resource = getMetaInfResource(file, resolver, manager);
try {
if (resource.getFile().exists()) {
manager.unregisterResource(resource, fileContents.getContextSalience(), fileContents.getVariationSalience());
log.debug(resource.getFilename() + " was successfully unregistered from " + manager);
}
} catch (Exception e) {
isSuccess = false;
log.warn("The resource " + resource.getFilename() + " failed to unregister", e);
}
}
return isSuccess;
}
use of org.jaffa.loader.IManager in project jaffa-framework by jaffa-projects.
the class ConfigApiHelper method registerResources.
/**
* Register configuration files in IManager implementationss, based on the source of the method call
* @param file The configuration file to be registered or unregistered
* @return Success or failure of the operation
*/
public static boolean registerResources(File file, FileContentsHelper fileContents) {
boolean isSuccess = true;
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
for (IManager manager : ManagerRepositoryService.getInstance().getManagerMap().values()) {
Resource resource = getMetaInfResource(file, resolver, manager);
try {
if (resource.getFile().exists()) {
if (manager instanceof RoleManager) {
PolicyManager.clearCache();
}
manager.registerResource(resource, fileContents.getContextSalience(), fileContents.getVariationSalience());
ManagerRepositoryService.getInstance().add(manager.getClass().getSimpleName(), manager);
log.debug(resource.getFilename() + " was successfully registered to " + manager);
}
} catch (Exception e) {
isSuccess = false;
log.error("The resource " + resource.getFilename() + " failed to register", e);
}
}
return isSuccess;
}
Aggregations