Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support invalidating connections when related local entry changed #2115

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading