diff --git a/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java b/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java index 7938412717..74e3dbcbdc 100644 --- a/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java +++ b/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java @@ -50,8 +50,6 @@ import org.apache.synapse.eventing.SynapseEventSource; import org.apache.synapse.task.*; import org.wso2.securevault.secret.handler.SharedSecretCallbackHandlerCache; -import org.apache.synapse.util.xpath.ext.SynapseXpathFunctionContextProvider; -import org.apache.synapse.util.xpath.ext.SynapseXpathVariableResolver; import org.apache.synapse.util.xpath.ext.XpathExtensionUtil; import java.io.File; @@ -396,7 +394,7 @@ public SynapseEnvironment createSynapseEnvironment() { } //we initialize xpath extensions here since synapse environment is available - initXpathExtensions(synapseEnvironment); + XpathExtensionUtil.initXpathExtensions(synapseEnvironment); try { deployMediationLibraryArtifacts(); @@ -417,34 +415,6 @@ public SynapseEnvironment createSynapseEnvironment() { return synapseEnvironment; } - /** - * This method initializes Xpath Extensions available through synapse.properties file. - * Xpath Extensions can be defined in Variable Context Extensions + Function Context Extensions - * synapse.xpath.var.extensions --> Variable Extensions - * synapse.xpath.func.extensions --> Function Extensions - * - * @param synapseEnvironment SynapseEnvironment - */ - private void initXpathExtensions(SynapseEnvironment synapseEnvironment) { - Axis2SynapseEnvironment axis2SynapseEnvironment = (Axis2SynapseEnvironment) synapseEnvironment; - - /*Initialize Function Context extensions for xpath - */ - List functionExtensions = - XpathExtensionUtil.getRegisteredFunctionExtensions(); - for (SynapseXpathFunctionContextProvider functionExtension : functionExtensions) { - axis2SynapseEnvironment.setXpathFunctionExtensions(functionExtension); - } - - /*Initialize Variable Context extensions for xpath - */ - List variableExtensions = - XpathExtensionUtil.getRegisteredVariableExtensions(); - for (SynapseXpathVariableResolver variableExtension : variableExtensions) { - axis2SynapseEnvironment.setXpathVariableExtensions(variableExtension); - } - } - /** * The mediation library deployer will handling the process of deploying the * libararyArtifacts, this is required since the library specific artifacts diff --git a/modules/core/src/main/java/org/apache/synapse/unittest/ConfigurationDeployer.java b/modules/core/src/main/java/org/apache/synapse/unittest/ConfigurationDeployer.java index e2ed318a18..6b38edb455 100755 --- a/modules/core/src/main/java/org/apache/synapse/unittest/ConfigurationDeployer.java +++ b/modules/core/src/main/java/org/apache/synapse/unittest/ConfigurationDeployer.java @@ -32,6 +32,7 @@ import org.apache.synapse.deployers.ProxyServiceDeployer; import org.apache.synapse.deployers.SequenceDeployer; import org.apache.synapse.deployers.TemplateDeployer; +import org.apache.synapse.util.xpath.ext.XpathExtensionUtil; import java.util.AbstractMap; import java.util.Map; @@ -209,6 +210,7 @@ private ConfigurationContext createConfigurationContext(SynapseConfiguration syn axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment)); axisConfiguration.addParameter(new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration)); configurationContext.setAxisConfiguration(axisConfiguration); + XpathExtensionUtil.initXpathExtensions(synapseEnvironment); return configurationContext; } diff --git a/modules/core/src/main/java/org/apache/synapse/util/xpath/ext/XpathExtensionUtil.java b/modules/core/src/main/java/org/apache/synapse/util/xpath/ext/XpathExtensionUtil.java index d8325b499b..adb4203cca 100644 --- a/modules/core/src/main/java/org/apache/synapse/util/xpath/ext/XpathExtensionUtil.java +++ b/modules/core/src/main/java/org/apache/synapse/util/xpath/ext/XpathExtensionUtil.java @@ -24,6 +24,7 @@ import org.apache.synapse.SynapseException; import org.apache.synapse.config.SynapsePropertiesLoader; import org.apache.synapse.core.SynapseEnvironment; +import org.apache.synapse.core.axis2.Axis2SynapseEnvironment; import org.jaxen.Function; import java.util.ArrayList; @@ -50,6 +51,32 @@ public class XpathExtensionUtil { private static final Log log = LogFactory.getLog(XpathExtensionUtil.class); + /** + * This method initializes Xpath Extensions available through synapse.properties file. + * Xpath Extensions can be defined in Variable Context Extensions + Function Context Extensions + * synapse.xpath.var.extensions --> Variable Extensions + * synapse.xpath.func.extensions --> Function Extensions + * + * @param synapseEnvironment SynapseEnvironment + */ + public static void initXpathExtensions(SynapseEnvironment synapseEnvironment) { + Axis2SynapseEnvironment axis2SynapseEnvironment = (Axis2SynapseEnvironment) synapseEnvironment; + + /*Initialize Function Context extensions for xpath + */ + List functionExtensions = getRegisteredFunctionExtensions(); + for (SynapseXpathFunctionContextProvider functionExtension : functionExtensions) { + axis2SynapseEnvironment.setXpathFunctionExtensions(functionExtension); + } + + /*Initialize Variable Context extensions for xpath + */ + List variableExtensions = getRegisteredVariableExtensions(); + for (SynapseXpathVariableResolver variableExtension : variableExtensions) { + axis2SynapseEnvironment.setXpathVariableExtensions(variableExtension); + } + } + /** * Get all registered variable context extensions. Synapse will look for synapse.properties * property synapse.xpath.var.extensions