use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.
the class HessianMessageBuilderTest method testProcessDocumentFaultWithSynEnv.
public void testProcessDocumentFaultWithSynEnv() throws IOException {
SynapseEnvironment synEnv = new Axis2SynapseEnvironment(new ConfigurationContext(new AxisConfiguration()), new SynapseConfiguration());
testProcessDocumentFault(synEnv);
}
use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.
the class MultiXMLConfigurationBuilder method createConfigurationFromSynapseXML.
private static SynapseConfiguration createConfigurationFromSynapseXML(String rootDirPath, Properties properties) {
File synapseXML = new File(rootDirPath, SynapseConstants.SYNAPSE_XML);
if (!synapseXML.exists() || !synapseXML.isFile()) {
return null;
}
FileInputStream is;
SynapseConfiguration config = null;
try {
is = FileUtils.openInputStream(synapseXML);
} catch (IOException e) {
handleException("Error while opening the file: " + synapseXML.getName(), e);
return null;
}
try {
config = XMLConfigurationBuilder.getConfiguration(is, properties);
is.close();
} catch (XMLStreamException e) {
handleException("Error while loading the Synapse configuration from the " + synapseXML.getName() + " file", e);
} catch (IOException e) {
log.warn("Error while closing the input stream from file: " + synapseXML.getName(), e);
}
return config;
}
use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.
the class SynapseXMLConfigurationFactory method getConfiguration.
public SynapseConfiguration getConfiguration(OMElement definitions, Properties properties) {
if (!definitions.getQName().equals(XMLConfigConstants.DEFINITIONS_ELT)) {
throw new SynapseException("Wrong QName for this configuration factory " + definitions.getQName());
}
SynapseConfiguration config = SynapseConfigUtils.newConfiguration();
config.setDefaultQName(definitions.getQName());
Iterator itr = definitions.getChildren();
while (itr.hasNext()) {
Object o = itr.next();
if (o instanceof OMElement) {
OMElement elt = (OMElement) o;
if (XMLConfigConstants.SEQUENCE_ELT.equals(elt.getQName())) {
String key = elt.getAttributeValue(new QName(XMLConfigConstants.NULL_NAMESPACE, "key"));
// this could be a sequence def or a referred sequence
if (key != null) {
handleException("Referred sequences are not allowed at the top level");
} else {
defineSequence(config, elt, properties);
}
} else if (XMLConfigConstants.TEMPLATE_ELT.equals(elt.getQName())) {
defineTemplate(config, elt, properties);
} else if (XMLConfigConstants.IMPORT_ELT.equals(elt.getQName())) {
defineImport(config, elt, properties);
} else if (XMLConfigConstants.ENDPOINT_ELT.equals(elt.getQName())) {
defineEndpoint(config, elt, properties);
} else if (XMLConfigConstants.ENTRY_ELT.equals(elt.getQName())) {
defineEntry(config, elt, properties);
} else if (XMLConfigConstants.PROXY_ELT.equals(elt.getQName())) {
defineProxy(config, elt, properties);
} else if (XMLConfigConstants.REGISTRY_ELT.equals(elt.getQName())) {
defineRegistry(config, elt, properties);
} else if (XMLConfigConstants.EVENT_SOURCE_ELT.equals(elt.getQName())) {
defineEventSource(config, elt, properties);
} else if (XMLConfigConstants.EXECUTOR_ELT.equals(elt.getQName())) {
defineExecutor(config, elt, properties);
} else if (XMLConfigConstants.MESSAGE_STORE_ELT.equals(elt.getQName())) {
defineMessageStore(config, elt, properties);
} else if (XMLConfigConstants.TASK_MANAGER_ELT.equals(elt.getQName())) {
defineTaskManager(config, elt, properties);
} else if (XMLConfigConstants.MESSAGE_PROCESSOR_ELT.equals(elt.getQName())) {
defineMessageProcessor(config, elt, properties);
} else if (StartupFinder.getInstance().isStartup(elt.getQName())) {
defineStartup(config, elt, properties);
} else if (XMLConfigConstants.API_ELT.equals(elt.getQName())) {
defineAPI(config, elt, properties);
} else if (XMLConfigConstants.DESCRIPTION_ELT.equals(elt.getQName())) {
config.setDescription(elt.getText());
} else if (XMLConfigConstants.INBOUND_ENDPOINT_ELT.equals(elt.getQName())) {
defineInboundEndpoint(config, elt, properties);
} else {
handleException("Invalid configuration element at the top level, one of \'sequence\', " + "\'endpoint\', \'proxy\', \'eventSource\', \'localEntry\', \'priorityExecutor\'" + ", \'registry\' or \'inboundEndpoint\' is expected");
}
} else if (o instanceof OMComment) {
OMComment commentNode = (OMComment) o;
defineComments(config, commentNode);
}
}
return config;
}
use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.
the class MessageContextCreatorForAxis2 method getSynapseConfiguration.
private static SynapseConfiguration getSynapseConfiguration(org.apache.axis2.context.MessageContext axisMsgCtx) {
AxisConfiguration axisCfg = axisMsgCtx.getConfigurationContext().getAxisConfiguration();
Parameter param = axisCfg.getParameter(SynapseConstants.SYNAPSE_CONFIG);
if (param != null) {
return (SynapseConfiguration) param.getValue();
}
return null;
}
use of org.apache.synapse.config.SynapseConfiguration in project wso2-synapse by wso2.
the class MessageContextCreatorForAxis2 method getSynapseMessageContext.
public static MessageContext getSynapseMessageContext(org.apache.axis2.context.MessageContext axisMsgCtx) throws AxisFault {
if (synCfg == null || synEnv == null) {
String msg = "Synapse environment has not initialized properly..";
log.fatal(msg);
throw new SynapseException(msg);
}
// we should try to get the synapse configuration and environment from
// the axis2 configuration.
SynapseEnvironment synapseEnvironment = getSynapseEnvironment(axisMsgCtx);
SynapseConfiguration synapseConfiguration = getSynapseConfiguration(axisMsgCtx);
if (synapseConfiguration != null && synapseEnvironment != null) {
return new Axis2MessageContext(axisMsgCtx, synapseConfiguration, synapseEnvironment);
} else {
return new Axis2MessageContext(axisMsgCtx, synCfg, synEnv);
}
}
Aggregations