diff --git a/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java b/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java index 7568257aac..4893f3e7c9 100644 --- a/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java +++ b/modules/core/src/main/java/org/apache/synapse/SynapseConstants.java @@ -155,6 +155,8 @@ public static final class Axis2Param { /** The name of the Parameter set on the Axis2Configuration to hold the Synapse Configuration */ public static final String SYNAPSE_CONFIG = "synapse.config"; + /** EIP pattern name */ + public static final String INIT_EIP_PATTERN = "init"; /** The name of the Parameter set on the Axis2Configuration to hold the Synapse Environment */ public static final String SYNAPSE_ENV = "synapse.env"; /** The name of the Parameter set on AxisConfiguration to hold the ServerContextInformation */ diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/template/InvokeMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/template/InvokeMediator.java index 65e416fb7f..5e93d02abb 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/template/InvokeMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/template/InvokeMediator.java @@ -76,12 +76,15 @@ public class InvokeMediator extends AbstractMediator implements private Map pName2ExpressionMap; private boolean dynamicMediator = false; - - /** The local registry key which is used to pick a sequence definition */ + private Value key = null; - /** Reference to the synapse environment */ - private SynapseEnvironment synapseEnv; + private String localEntryKey = null; + + /** + * Reference to the synapse environment + */ + private SynapseEnvironment synapseEnv; public InvokeMediator() { // LinkedHashMap is used to preserve tag order @@ -129,6 +132,10 @@ private boolean mediate(MessageContext synCtx, boolean executePreFetchingSequenc if (executePreFetchingSequence && key != null) { String defaultConfiguration = key.evaluateValue(synCtx); Mediator m = synCtx.getDefaultConfiguration(defaultConfiguration); + if (m instanceof InvokeMediator) { + InvokeMediator invokeMediator = (InvokeMediator) m; + invokeMediator.setLocalEntryKey(defaultConfiguration); + } if (m == null) { handleException("Sequence named " + key + " cannot be found", synCtx); @@ -149,6 +156,9 @@ private boolean mediate(MessageContext synCtx, boolean executePreFetchingSequenc } if (mediator != null && mediator instanceof TemplateMediator) { + if (localEntryKey != null) { + ((TemplateMediator) mediator).setLocalEntryKey(localEntryKey); + } populateParameters(synCtx, ((TemplateMediator) mediator).getName()); if (executePreFetchingSequence) { ContinuationStackManager.addReliantContinuationState(synCtx, @@ -319,6 +329,12 @@ public Value getKey() { public void setKey(Value key) { this.key = key; } + public void setLocalEntryKey(String localEntryKey) { + this.localEntryKey = localEntryKey; + } + public String getLocalEntryKey() { + return localEntryKey; + } public String getPackageName() { return packageName; diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/template/TemplateContext.java b/modules/core/src/main/java/org/apache/synapse/mediators/template/TemplateContext.java index fa27398e5c..9a7b73d24e 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/template/TemplateContext.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/template/TemplateContext.java @@ -51,10 +51,15 @@ public class TemplateContext { * refers to the parameters of the function */ private Collection parameters; + private final String INIT_CONFIG_KEY = "INIT_CONFIG_KEY"; /** * contains a map for parameterNames to evaluated values */ private Map mappedValues; + /** + * The local entry key name + */ + private String localEntryKey = null; public TemplateContext(String name, Collection parameters) { this.fName = name; @@ -68,6 +73,9 @@ public TemplateContext(String name, Collection parameters) { * @param synCtxt Synapse MessageContext */ public void setupParams(MessageContext synCtxt) { + if (SynapseConstants.INIT_EIP_PATTERN.equals(fName) && getLocalEntryKey() != null) { + mappedValues.put(INIT_CONFIG_KEY, getLocalEntryKey()); + } Iterator paramNames = parameters.iterator(); while (paramNames.hasNext()) { TemplateParam parameter = paramNames.next(); @@ -182,6 +190,14 @@ public Map getMappedValues() { return mappedValues; } + public String getLocalEntryKey() { + return localEntryKey; + } + + public void setLocalEntryKey(String localEntryKey) { + this.localEntryKey = localEntryKey; + } + public void setMappedValues(Map map) { this.mappedValues = map; } diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/template/TemplateMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/template/TemplateMediator.java index 801fcc2e3e..a79351b29f 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/template/TemplateMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/template/TemplateMediator.java @@ -55,6 +55,17 @@ public class TemplateMediator extends AbstractListMediator { private String errorHandler = null; + /** The local entry key name */ + private String localEntryKey = null; + + public String getLocalEntryKey() { + return localEntryKey; + } + + public void setLocalEntryKey(String localEntryKey) { + this.localEntryKey = localEntryKey; + } + public void setParameters(Collection paramNames) { this.templateParams = paramNames; } @@ -161,6 +172,9 @@ public boolean mediate(MessageContext synCtx) { */ private void pushFuncContextTo(MessageContext synCtx) { TemplateContext funcContext = new TemplateContext(eipPatternName, templateParams); + if (localEntryKey != null) { + funcContext.setLocalEntryKey(localEntryKey); + } //process the raw parameters parsed in funcContext.setupParams(synCtx);