// initialize the module
public void init(ConfigurationContext configContext,
AxisModule module) throws AxisFault {
if(log.isDebugEnabled()) log.debug("Entry: SandeshaModule::init, " + configContext);
AxisConfiguration config = configContext.getAxisConfiguration();
//storing the Sandesha module as a parameter.
Parameter parameter = new Parameter(Sandesha2Constants.MODULE_CLASS_LOADER,module.getModuleClassLoader());
config.addParameter(parameter);
//init the i18n messages
SandeshaMessageHelper.innit();
//storing the module as a static variable
SandeshaUtil.setAxisModule(module);
// continueUncompletedSequences (storageManager,configCtx);
SandeshaPolicyBean constantPropertyBean = PropertyManager.loadPropertiesFromDefaultValues();
SandeshaPolicyBean propertyBean = PropertyManager.loadPropertiesFromModuleDescPolicy(module,constantPropertyBean);
if (propertyBean==null) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotLoadModulePolicies);
log.error (message);
propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
} else {
if (log.isDebugEnabled()) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.modulePoliciesLoaded);
log.info (message);
}
}
parameter = new Parameter (Sandesha2Constants.SANDESHA_PROPERTY_BEAN, propertyBean);
config.addParameter(parameter);
// Reset both storage managers
parameter = config.getParameter(Sandesha2Constants.INMEMORY_STORAGE_MANAGER);
if(parameter != null) config.removeParameter(parameter);
parameter = config.getParameter(Sandesha2Constants.PERMANENT_STORAGE_MANAGER);
if(parameter != null) config.removeParameter(parameter);
try {
StorageManager inMemorytorageManager = SandeshaUtil.getInMemoryStorageManager(configContext);
inMemorytorageManager.initStorage(module);
} catch (SandeshaStorageException e) {
String message = SandeshaMessageHelper.getMessage(
SandeshaMessageKeys.cannotInitInMemoryStorageManager,
e.toString());
log.debug(message,e);
}
try {
StorageManager permanentStorageManager = SandeshaUtil.getPermanentStorageManager(configContext);
permanentStorageManager.initStorage(module);
} catch (SandeshaStorageException e) {
String message = SandeshaMessageHelper.getMessage(
SandeshaMessageKeys.cannotInitPersistentStorageManager,
e.toString());
log.debug(message,e);
}
// Reset the security manager, and then load it
parameter = config.getParameter(Sandesha2Constants.SECURITY_MANAGER);
if(parameter != null) config.removeParameter(parameter);
SecurityManager util = SandeshaUtil.getSecurityManager(configContext);
util.initSecurity(module);
// Mark the config context so that we can run sync 2-way interations over
// RM, but at the same time switch it off for unreliable messages.
configContext.setProperty(Constants.Configuration.USE_ASYNC_OPERATIONS, Boolean.TRUE);
configContext.getAxisConfiguration().addTargetResolver(
new TargetResolver() {
public void resolveTarget(MessageContext messageContext) {
//if Sandesha2 is not engaged we can set the property straight away
boolean engaged = false;
//checking weather the module is engaged at the System level
AxisConfiguration axisConfiguration = messageContext.getConfigurationContext().getAxisConfiguration();
if (axisConfiguration!=null) {
Collection modules = axisConfiguration.getEngagedModules();
for (Iterator iter = modules.iterator();iter.hasNext();) {
String moduleName = (String) iter.next();
if (moduleName!=null && moduleName.startsWith (Sandesha2Constants.MODULE_NAME)) {
engaged = true;
}