use of org.apache.synapse.config.xml.endpoints.TemplateFactory in project wso2-synapse by wso2.
the class SynapseConfiguration method getEndpointTemplate.
public Template getEndpointTemplate(String key) {
Object o = getEntry(key);
if (o instanceof Template) {
return (Template) o;
}
Entry entry = null;
if (o == null) {
entry = new Entry(key);
entry.setType(Entry.REMOTE_ENTRY);
} else {
Object object = localRegistry.get(key);
if (object instanceof Entry) {
entry = (Entry) object;
}
}
assertEntryNull(entry, key);
// noinspection ConstantConditions
if (entry.getMapper() == null) {
entry.setMapper(new XMLToTemplateMapper());
}
if (entry.getType() == Entry.REMOTE_ENTRY) {
if (registry != null) {
o = registry.getResource(entry, getProperties());
if (o != null && o instanceof Template) {
localRegistry.put(key, entry);
return (Template) o;
} else if (o instanceof OMNode) {
Template m = new TemplateFactory().createEndpointTemplate((OMElement) o, properties);
if (m != null) {
entry.setValue(m);
return m;
}
}
}
} else {
Object value = entry.getValue();
if (value instanceof OMNode) {
Object object = entry.getMapper().getObjectFromOMNode((OMNode) value, getProperties());
if (object instanceof Template) {
entry.setValue(object);
return (Template) object;
}
}
}
// load from available libraries
Template templateFromLib = LibDeployerUtils.getLibArtifact(synapseLibraries, key, Template.class);
if (templateFromLib != null) {
return templateFromLib;
}
return null;
}
use of org.apache.synapse.config.xml.endpoints.TemplateFactory in project wso2-synapse by wso2.
the class SynapseXMLConfigurationFactory method defineEndpointTemplate.
public static Template defineEndpointTemplate(SynapseConfiguration config, OMElement elem, Properties properties) {
TemplateFactory templateFactory = new TemplateFactory();
String name = elem.getAttributeValue(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
try {
Template template = templateFactory.createEndpointTemplate(elem, properties);
if (template != null) {
config.addEndpointTemplate(template.getName(), template);
}
return template;
} catch (Exception e) {
String msg = "Endpoint Template: " + name + "configuration cannot be built";
handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_TEMPLATES, msg, e);
}
return null;
}
use of org.apache.synapse.config.xml.endpoints.TemplateFactory in project wso2-synapse by wso2.
the class XMLToTemplateMapper method getObjectFromOMNode.
public Object getObjectFromOMNode(OMNode om, Properties properties) {
if (!(om instanceof OMElement)) {
throw new SynapseException("Configuration is not in proper format.");
}
OMElement elem = (OMElement) om;
OMElement element = elem.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "sequence"));
if (element != null) {
return MediatorFactoryFinder.getInstance().getMediator(elem, properties);
}
element = elem.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "endpoint"));
if (element != null) {
TemplateFactory templateFactory = new TemplateFactory();
return templateFactory.createEndpointTemplate(elem, properties);
}
return null;
}
Aggregations