public void init(SynapseEnvironment se) {
OSGIServiceLocator osgiServiceLocator = OSGIServiceLocator.getInstance();
RuleServerManagerService ruleServerManager;
InputOutputAdaptersService inputOutputAdaptersService;
if (osgiServiceLocator.isInitialized()) {
ruleServerManager =
(RuleServerManagerService) osgiServiceLocator.locateService(
RuleServerManagerService.class.getName());
inputOutputAdaptersService =
(InputOutputAdaptersService) osgiServiceLocator.locateService(
InputOutputAdaptersService.class.getName());
} else {
log.info("Cannot find RuleServerManagerService, Using the default RuleServerManager" +
" implementation ");
OMElement defaultConf = OMElementHelper.getInstance().toOM("<RuleServer/>");
RuleServerConfiguration ruleServerConfiguration =
RuleServerConfigurationFactory.create(defaultConf, new SynapseXPathFactory());
ruleServerManager = new RuleServerManager();
((RuleServerManager) ruleServerManager).init(ruleServerConfiguration);
OMElement defaultAdaptersConf =
OMElementHelper.getInstance().toOM("<InputOutputManager/>");
InputOutputAdaptersConfiguration configuration =
InputOutputAdaptersConfigurationFactory.create(defaultAdaptersConf,
new SynapseXPathFactory());
inputOutputAdaptersService = new InputOutputAdaptersServiceImpl(configuration);
}
ResourceDescription mediatorAsFact = new ResourceDescription();
mediatorAsFact.setType(MediatorResourceAdapter.TYPE);
mediatorAsFact.setValue(MediatorResourceAdapter.class.getName());
InputAdapterFactory inputAdapterFactory = inputOutputAdaptersService.getFactAdapterFactory();
if (!inputAdapterFactory.containsInputAdapter(MediatorResourceAdapter.TYPE)) {
inputAdapterFactory.addInputAdapter(mediatorAsFact);
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = this.getClass().getClassLoader();
}
RuleSetDescription ruleSetDescription = ruleMediatorDescription.getRuleSetDescription();
ruleEngine = ruleServerManager.createRuleEngine(classLoader);
if (ruleSetDescription.getRuleSource() != null) {
String bindURI = ruleEngine.addRuleSet(ruleSetDescription);
SessionDescription sessionDescription = ruleMediatorDescription.getSessionDescription();
sessionDescription.setRuleSetURI(bindURI);
} else {
registryKey = ruleSetDescription.getKey();
}
inputManager = inputOutputAdaptersService.createInputManager(
ruleMediatorDescription.getFacts(),
interceptor);
outputManager = inputOutputAdaptersService.createOutputManager(
ruleMediatorDescription.getResults(),
interceptor);
super.init(se);
}