Skip to content

Commit

Permalink
Merge pull request #2115 from malakaganga/fix_localentry
Browse files Browse the repository at this point in the history
Support invalidating connections when related local entry changed
  • Loading branch information
malakaganga authored Nov 10, 2023
2 parents 41ccbee + 42f4101 commit d4e884f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ public class InvokeMediator extends AbstractMediator implements
private Map<String, Value> 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
Expand Down Expand Up @@ -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);

Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ public class TemplateContext {
* refers to the parameters of the function
*/
private Collection<TemplateParam> 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<TemplateParam> parameters) {
this.fName = name;
Expand All @@ -68,6 +73,9 @@ public TemplateContext(String name, Collection<TemplateParam> 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<TemplateParam> paramNames = parameters.iterator();
while (paramNames.hasNext()) {
TemplateParam parameter = paramNames.next();
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TemplateParam> paramNames) {
this.templateParams = paramNames;
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit d4e884f

Please sign in to comment.