use of org.apache.synapse.config.xml.XMLToTemplateMapper 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.XMLToTemplateMapper in project wso2-synapse by wso2.
the class SynapseConfiguration method getSequenceTemplate.
/**
* Return the template specified with the given key
*
* @param key the key being referenced for the template
* @return the template referenced by the key from local/remote registry
*/
public TemplateMediator getSequenceTemplate(String key) {
Object o = getEntry(key);
if (o instanceof TemplateMediator) {
return (TemplateMediator) 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 TemplateMediator) {
localRegistry.put(key, entry);
return (TemplateMediator) o;
} else if (o instanceof OMNode) {
TemplateMediator m = (TemplateMediator) new TemplateMediatorFactory().createMediator((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 TemplateMediator) {
entry.setValue(object);
return (TemplateMediator) object;
}
}
}
// load from available libraries
TemplateMediator templateFromLib = LibDeployerUtils.getLibArtifact(synapseLibraries, key, TemplateMediator.class);
if (templateFromLib != null) {
return templateFromLib;
}
return null;
}
Aggregations