/** * Creates a new Target from the OMElement * @param attributeName Name of the attribute where the property name/ XPath expression is * stored. * @param element OMElement where the the XPath expression and the namespaces are stored. */ public Target(String attributeName, OMElement element) { this.value = new ValueFactory().createValue(attributeName, element); }
boolean hasEscape = isEscapedExpression(textValue); if (!hasEscape && isDynamicKey(textValue)) { SynapseJsonPath synJsonPath = createSynJsonPath(textValue); key = new Value(synJsonPath); } else { SynapseXPath synXpath = createSynXpath(elem, textValue); key = new Value(synXpath); key = new Value(getEscapedExpression(textValue)); key.setNamespaces(elem); } else { handleException("Text value is required for the element '" + elem.getLocalName() + "'");
private void buildParameters(OMElement elem) { Iterator subElements = elem.getChildElements(); while (subElements.hasNext()) { OMElement child = (OMElement) subElements.next(); Value paramValue = new ValueFactory().createTextValue(child); invoker.addExpressionForParamName(child.getLocalName(), paramValue); } } }
/** * Create synapse xpath expression * {} type user input is used to create real xpath expression * * @param elem the element * @param key xpath expression with {} * @return SynapseXpath */ public SynapseXPath createSynXpath(OMElement elem, String key) { //derive XPath Expression from key String xpathExpr = key.trim().substring(1, key.length() - 1); SynapseXPath synapseXPath = null; try { synapseXPath = SynapseXPathFactory.getSynapseXPath(elem, xpathExpr); } catch (JaxenException e) { handleException("Can not create Synapse Xpath from given key"); } return synapseXPath; }
/** * Create synapse jsonpath expression * * @param key jsonpath expression eg: json-eval($.info) * @return SynapseJsonPath */ public SynapseJsonPath createSynJsonPath(String key) { // Derive JsonPath Expression from key removing "json-eval(" & ")" String jsonPathExpr = key.trim().substring(10, key.length() - 1); SynapseJsonPath synapseJsonPath = null; try { synapseJsonPath = SynapseJsonPathFactory.getSynapseJsonPath(jsonPathExpr); } catch (JaxenException e) { handleException("Can not create SynapseJsonPath from given: " + key); } return synapseJsonPath; }
/** * Creates a new Target from the OMElement * @param attributeName Name of the attribute where the property name/ XPath expression is * stored. * @param element OMElement where the the XPath expression and the namespaces are stored. */ public Target(String attributeName, OMElement element) { this.value = new ValueFactory().createValue(attributeName, element); }
/** * Create a key instance * * @param elem OMElement * @return Key */ public Value createValue(String name, OMElement elem) { Value key = null; OMAttribute attKey = elem.getAttribute(new QName(name)); if (attKey != null) { String attributeValue = attKey.getAttributeValue(); boolean hasEscape = isEscapedExpression(attributeValue); if (!hasEscape && isDynamicKey(attributeValue)) { /** dynamic key */ SynapseXPath synXpath = createSynXpath(elem, attributeValue); key = new Value(synXpath); } else if (hasEscape) { /** escaped expr */ key = new Value(getEscapedExpression(attributeValue)); key.setNamespaces(elem); } else { /** static key */ key = new Value(attributeValue); } } else { handleException("The '" + name + "' attribute is required on the " + elem.getLocalName() + " element"); } return key; }
private void buildParamteres(OMElement connectorElem, InvokeMediator invokeMediator) { Iterator parameters = connectorElem.getChildElements(); while (parameters.hasNext()) { OMNode paramNode = (OMNode) parameters.next(); if (paramNode instanceof OMElement) { String paramName = ((OMElement) paramNode).getLocalName(); //((OMElement) paramNode).getAttributeValue(new QName("name")); String paramValueStr = ((OMElement) paramNode).getText();//((OMElement) paramNode).getAttributeValue(new QName("value")); if (paramName != null && !paramName.equals("") && paramValueStr != null && !paramValueStr.equals("")) { Value paramValue = new ValueFactory().createTextValue((OMElement) paramNode); invokeMediator.addExpressionForParamName(paramName, paramValue); } } } } }
/** * Create synapse xpath expression * {} type user input is used to create real xpath expression * * @param elem the element * @param key xpath expression with {} * @return SynapseXpath */ public SynapseXPath createSynXpath(OMElement elem, String key) { //derive XPath Expression from key String xpathExpr = key.trim().substring(1, key.length() - 1); SynapseXPath synapseXPath = null; try { synapseXPath = SynapseXPathFactory.getSynapseXPath(elem, xpathExpr); } catch (JaxenException e) { handleException("Can not create Synapse Xpath from given key"); } return synapseXPath; }
private void buildParameters(OMElement elem) { Iterator subElements = elem.getChildElements(); while (subElements.hasNext()) { OMElement child = (OMElement) subElements.next(); if (child.getQName().equals(WITH_PARAM_Q)) { OMAttribute paramNameAttr = child.getAttribute(ATT_NAME); if (paramNameAttr != null) { //set parameter value Value paramValue = new ValueFactory().createValue("value", child); invoker.addExpressionForParamName(paramNameAttr.getAttributeValue(), paramValue); } } } }
boolean hasEscape = isEscapedExpression(attributeValue); if (!hasEscape && isDynamicKey(attributeValue)) { SynapseJsonPath synJsonPath = createSynJsonPath(attributeValue); key = new Value(synJsonPath); } else { SynapseXPath synXpath = createSynXpath(elem, attributeValue); key = new Value(synXpath); key = new Value(getEscapedExpression(attributeValue)); key.setNamespaces(elem); } else { handleException("The '" + name + "' attribute is required for the element '" + elem.getLocalName() + "'");
private Map<Value, Object> getIncludeKeysMap(OMElement elem) { // get <include /> scripts // map key = registry entry key, value = script source // at this time map values are null, later loaded // from void ScriptMediator.prepareExternalScript(MessageContext synCtx) // TreeMap used to keep given scripts order if needed Map<Value, Object> includeKeysMap = new LinkedHashMap<Value, Object>(); Iterator itr = elem.getChildrenWithName(INCLUDE_Q); while (itr.hasNext()) { OMElement includeElem = (OMElement) itr.next(); OMAttribute key = includeElem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key")); // ValueFactory for creating dynamic or static Value ValueFactory keyFac = new ValueFactory(); // create dynamic or static key based on OMElement Value generatedKey = keyFac.createValue(XMLConfigConstants.KEY, includeElem); if (key == null) { throw new SynapseException("Cannot use 'include' element without 'key'" + " attribute for a script mediator"); } includeKeysMap.put(generatedKey, null); } return includeKeysMap; }
private Map<Value, Object> getIncludeKeysMap(OMElement elem) { // get <include /> scripts // map key = registry entry key, value = script source // at this time map values are null, later loaded // from void ScriptMediator.prepareExternalScript(MessageContext synCtx) // TreeMap used to keep given scripts order if needed Map<Value, Object> includeKeysMap = new LinkedHashMap<Value, Object>(); Iterator itr = elem.getChildrenWithName(INCLUDE_Q); while (itr.hasNext()) { OMElement includeElem = (OMElement) itr.next(); OMAttribute key = includeElem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key")); // ValueFactory for creating dynamic or static Value ValueFactory keyFac = new ValueFactory(); // create dynamic or static key based on OMElement Value generatedKey = keyFac.createValue(XMLConfigConstants.KEY, includeElem); if (key == null) { throw new SynapseException("Cannot use 'include' element without 'key'" + " attribute for a script mediator"); } includeKeysMap.put(generatedKey, null); } return includeKeysMap; }
private void populateSetPropertyCase(BeanMediator mediator, OMElement elem) { mediator.setAction(BeanMediator.Action.SET_PROPERTY); populatePropertyName(mediator, elem); if (elem.getAttributeValue(ATT_VALUE) != null) { mediator.setValue(new ValueFactory().createValue(BeanConstants.VALUE, elem)); } else { handleException("'value' attribute of Bean mediator is required when 'SET_PROPERTY' " + "action is set."); } }
private void populateSetPropertyCase(BeanMediator mediator, OMElement elem) { mediator.setAction(BeanMediator.Action.SET_PROPERTY); populatePropertyName(mediator, elem); if (elem.getAttributeValue(ATT_VALUE) != null) { mediator.setValue(new ValueFactory().createValue(BeanConstants.VALUE, elem)); } else { handleException("'value' attribute of Bean mediator is required when 'SET_PROPERTY' " + "action is set."); } }
private void buildParameters(OMElement elem) { Iterator subElements = elem.getChildElements(); while (subElements.hasNext()) { OMElement child = (OMElement) subElements.next(); if (child.getQName().equals(WITH_PARAM_Q)) { OMAttribute paramNameAttr = child.getAttribute(ATT_NAME); Value paramValue = new ValueFactory().createValue("value", child); if (paramNameAttr != null) { if (StringUtils.isNotEmpty(paramNameAttr.getAttributeValue())) { //set parameter value invoker.addExpressionForParamName(paramNameAttr.getAttributeValue(), paramValue); } else { String msg = "Call template mediator parameters should have non empty name."; log.error(msg); throw new SynapseException(msg); } } } } }
public Mediator createSpecificMediator(OMElement elem, Properties properties) { SendMediator sm = new SendMediator(); // after successfully creating the mediator // set its common attributes such as tracing etc processAuditStatus(sm,elem); OMElement epElement = elem.getFirstChildWithName(ENDPOINT_Q); if (epElement != null) { // create the endpoint and set it in the send mediator Endpoint endpoint = EndpointFactory.getEndpointFromElement(epElement, true, properties); if (endpoint != null) { sm.setEndpoint(endpoint); } } String receivingSequence = elem.getAttributeValue(RECEIVING_SEQUENCE); if (receivingSequence != null) { ValueFactory valueFactory = new ValueFactory(); Value value = valueFactory.createValue(XMLConfigConstants.RECEIVE, elem); sm.setReceivingSequence(value); } return sm; }
public InvokeMediator getDynamicInvokeMediator(OMElement connectorElem, String libraryName) { InvokeMediator invokeMediator = new InvokeMediator(); if (connectorElem.getLocalName() != null && libraryName != null && !libraryName.equals("")) { invokeMediator.setTargetTemplate(libraryName + "." + connectorElem.getLocalName()); } // load configuration based references for the given connector OMAttribute config_key = connectorElem.getAttribute(new QName(XMLConfigConstants.CONFIG_REF)); if (config_key != null) { // ValueFactory for creating dynamic or static Value ValueFactory keyFac = new ValueFactory(); // create dynamic or static key based on OMElement Value generatedKey = keyFac.createValue(XMLConfigConstants.CONFIG_REF, connectorElem); // setKey invokeMediator.setKey(generatedKey); } buildParamteres(connectorElem, invokeMediator); invokeMediator.setPackageName(libraryName); invokeMediator.setDynamicMediator(true); return invokeMediator; }
log.warn(msg); } else { Value paramValue = new ValueFactory().createValue("default", paramEle); param.setDefaultValue(paramValue);
ValueFactory keyFac = new ValueFactory(); Value generatedKey = keyFac.createValue(XMLConfigConstants.KEY, elem);