public void globallyEngageCaching(CachingConfigData confData) throws AxisFault,
CachingComponentException {
// Retrieves caching module.
AxisModule cachingModule = axisConfig.getModule(CachingComponentConstants.CACHING_MODULE);
// Engage caching only if it is not engaged already.
String resourcePath = getModuleResourcePath(cachingModule);
try {
configRegistry.beginTransaction();
String globalPath = PersistenceUtils.getResourcePath(cachingModule);
if (configRegistry.resourceExists(globalPath)) {
Resource resource = configRegistry.get(globalPath);
if (!Boolean.parseBoolean(resource
.getProperty(GLOBALLY_ENGAGED_CUSTOM))) {
resource.removeProperty(GLOBALLY_ENGAGED_CUSTOM);
resource.addProperty(GLOBALLY_ENGAGED_CUSTOM, "true");
configRegistry.put(globalPath, resource);
}
} else {
Resource globalResource = configRegistry.newResource();
globalResource.addProperty(GLOBALLY_ENGAGED_CUSTOM, "true");
configRegistry.put(globalPath, globalResource);
}
// Gets a Policy object representing the configuration data.
Policy policy = confData.toPolicy();
// Add new policy to module
this.handleNewPolicyAddition(policy, cachingModule.getPolicySubject(), confData);
// Save the policy in the configRegistry.
Resource policyResource = configRegistry.newResource();
policyResource.setProperty(RegistryResources.ModuleProperties.POLICY_TYPE,
"" + PolicyInclude.AXIS_MODULE_POLICY);
policyResource.setProperty(RegistryResources.ModuleProperties.POLICY_UUID,
policy.getId());
policyResource.setProperty(RegistryResources.ModuleProperties.VERSION,
cachingModule.getVersion().toString());
cachingPolicyUtils.persistPoliciesToService(policy, resourcePath, null,
policyResource);
if (log.isDebugEnabled()) {
log.debug("Caching policy is saved in the configRegistry");
}
cachingModule.addParameter(new Parameter(GLOBALLY_ENGAGED_PARAM_NAME, "true"));
//engage the module for every service which is not an admin service
for (Iterator serviceIter = this.axisConfig.getServices().values().iterator();
serviceIter.hasNext();) {
AxisService service = (AxisService) serviceIter.next();