public void populateConfig() throws DeploymentException {
try {
OMElement config_element = buildOM();
if (!TAG_AXISCONFIG.equals(config_element.getLocalName())) {
throw new DeploymentException(Messages.getMessage("badelementfound", TAG_AXISCONFIG,
config_element.getLocalName()));
}
// processing Parameters
// Processing service level parameters
Iterator itr = config_element.getChildrenWithName(new QName(TAG_PARAMETER));
processParameters(itr, axisConfig, axisConfig);
// process MessageReceiver
OMElement messageReceiver =
config_element.getFirstChildWithName(new QName(TAG_MESSAGE_RECEIVERS));
if (messageReceiver != null) {
HashMap mrs = processMessageReceivers(messageReceiver);
Iterator keys = mrs.keySet().iterator();
while (keys.hasNext()) {
String key = (String) keys.next();
axisConfig.addMessageReceiver(key, (MessageReceiver) mrs.get(key));
}
}
// Process Module refs
Iterator moduleitr =
config_element.getChildrenWithName(new QName(DeploymentConstants.TAG_MODULE));
processModuleRefs(moduleitr, axisConfig);
// Processing Transport Senders
Iterator trs_senders =
config_element.getChildrenWithName(new QName(TAG_TRANSPORT_SENDER));
processTransportSenders(trs_senders);
// Processing Transport Receivers
Iterator trs_Reivers =
config_element.getChildrenWithName(new QName(TAG_TRANSPORT_RECEIVER));
processTransportReceivers(trs_Reivers);
// Process TargetResolvers
OMElement targetResolvers =
config_element.getFirstChildWithName(new QName(TAG_TARGET_RESOLVERS));
processTargetResolvers(axisConfig, targetResolvers);
// Process ThreadContextMigrators
OMElement threadContextMigrators =
config_element.getFirstChildWithName(new QName(TAG_THREAD_CONTEXT_MIGRATORS));
processThreadContextMigrators(axisConfig, threadContextMigrators);
// Process Observers
Iterator obs_ittr = config_element.getChildrenWithName(new QName(TAG_LISTENER));
processObservers(obs_ittr);
// Processing Phase orders
Iterator phaseorders = config_element.getChildrenWithName(new QName(TAG_PHASE_ORDER));
processPhaseOrders(phaseorders);
Iterator moduleConfigs =
config_element.getChildrenWithName(new QName(TAG_MODULE_CONFIG));
processModuleConfig(moduleConfigs, axisConfig, axisConfig);
// processing < wsp:Policy > .. < /.. > elements
Iterator policyElements = config_element.getChildrenWithName(new QName(POLICY_NS_URI,
TAG_POLICY));
if (policyElements != null && policyElements.hasNext()) {
processPolicyElements(policyElements,
axisConfig.getPolicySubject());
}
// processing < wsp:PolicyReference > .. < /.. > elements
Iterator policyRefElements = config_element.getChildrenWithName(new QName(POLICY_NS_URI,
TAG_POLICY_REF));
if (policyRefElements != null && policyRefElements.hasNext()) {
processPolicyRefElements(policyElements,
axisConfig.getPolicySubject());
}
//to process default module versions
OMElement defaultModuleVerionElement = config_element.getFirstChildWithName(new QName(
TAG_DEFAULT_MODULE_VERSION));
if (defaultModuleVerionElement != null) {
processDefaultModuleVersions(defaultModuleVerionElement);
}
OMElement clusterElement = config_element
.getFirstChildWithName(new QName(TAG_CLUSTER));
if (clusterElement != null) {
ClusterBuilder clusterBuilder = new ClusterBuilder(axisConfig);
clusterBuilder.buildCluster(clusterElement);
}
//Add jta transaction configuration
OMElement transactionElement = config_element
.getFirstChildWithName(new QName(TAG_TRANSACTION));
if (transactionElement != null) {
ParameterInclude transactionParameters = new ParameterIncludeImpl();
Iterator parameters = transactionElement.getChildrenWithName(new QName(TAG_PARAMETER));
processParameters(parameters, transactionParameters, null);
TransactionConfiguration txcfg = new TransactionConfiguration(transactionParameters);
OMAttribute timeoutAttribute = transactionElement.getAttribute(new QName(TAG_TIMEOUT));
if(timeoutAttribute != null) {
txcfg.setTransactionTimeout(Integer.parseInt(timeoutAttribute.getAttributeValue()));
}
axisConfig.setTransactionConfig(txcfg);
}
/*
* Add Axis2 default builders if they are not overidden by the config
*/
axisConfig.addMessageBuilder("multipart/related", new MIMEBuilder());
axisConfig.addMessageBuilder("application/soap+xml", new SOAPBuilder());
axisConfig.addMessageBuilder("text/xml", new SOAPBuilder());
axisConfig.addMessageBuilder("application/xop+xml", new MTOMBuilder());
axisConfig.addMessageBuilder("application/xml", new ApplicationXMLBuilder());
axisConfig.addMessageBuilder("application/x-www-form-urlencoded",
new XFormURLEncodedBuilder());
// process MessageBuilders
OMElement messageBuildersElement =
config_element.getFirstChildWithName(new QName(TAG_MESSAGE_BUILDERS));
if (messageBuildersElement != null) {
HashMap builderSelector = processMessageBuilders(messageBuildersElement);
Iterator keys = builderSelector.keySet().iterator();
while (keys.hasNext()) {
String key = (String) keys.next();
axisConfig.addMessageBuilder(key, (Builder) builderSelector.get(key));
}
}
//process dataLocator configuration
OMElement dataLocatorElement =
config_element
.getFirstChildWithName(new QName(DRConstants.DATA_LOCATOR_ELEMENT));
if (dataLocatorElement != null) {
processDataLocatorConfig(dataLocatorElement);
}
// process roleplayer configuration
OMElement rolePlayerElement =
config_element
.getFirstChildWithName(new QName(Constants.SOAP_ROLE_CONFIGURATION_ELEMENT));
if (rolePlayerElement != null) {
processSOAPRoleConfig(axisConfig, rolePlayerElement);
}
// process MessageFormatters
OMElement messageFormattersElement =
config_element.getFirstChildWithName(new QName(TAG_MESSAGE_FORMATTERS));
if (messageFormattersElement != null) {
HashMap messageFormatters = processMessageFormatters(messageFormattersElement);
Iterator keys = messageFormatters.keySet().iterator();
while (keys.hasNext()) {
String key = (String) keys.next();
axisConfig.addMessageFormatter(key,
(MessageFormatter) messageFormatters.get(key));
}
}
//Processing deployers.
Iterator deployerItr = config_element.getChildrenWithName(new QName(DEPLOYER));
if (deployerItr != null) {
processDeployers(deployerItr);
}
//process Attachments Lifecycle manager configuration
OMElement attachmentsLifecycleManagerElement =
config_element
.getFirstChildWithName(new QName(ATTACHMENTS_LIFECYCLE_MANAGER));
if (attachmentsLifecycleManagerElement != null) {
processAttachmentsLifecycleManager(axisConfig, attachmentsLifecycleManagerElement);
}
} catch (XMLStreamException e) {
throw new DeploymentException(e);
}
}
|