use of org.apache.synapse.debug.constructs.SynapseMediationFlowPoint in project wso2-synapse by wso2.
the class SynapseDebugManager method logMediatorPosition.
protected String logMediatorPosition(SynapseMediationFlowPoint flowPoint) {
String log = "";
String position = "";
for (int count = 0; count < flowPoint.getMediatorPosition().length; count++) {
if (count != 0) {
position = position.concat("-->");
}
position = position.concat("(" + String.valueOf(flowPoint.getMediatorPosition()[count]) + ")");
}
log = log.concat("mediator position " + position);
if (flowPoint instanceof SequenceMediationFlowPoint) {
log = log.concat(" " + ((SequenceMediationFlowPoint) flowPoint).getSequenceBaseType().toString() + " " + flowPoint.getKey());
log = log.concat(" sequence " + ((SequenceMediationFlowPoint) flowPoint).getSynapseSequenceType().toString().toLowerCase());
} else {
log = log.concat(" " + flowPoint.getSynapseMediationComponent().toString().toLowerCase() + " " + flowPoint.getKey());
}
return log;
}
use of org.apache.synapse.debug.constructs.SynapseMediationFlowPoint in project wso2-synapse by wso2.
the class SequenceDebugUtil method registerSequenceMediationFlowBreakPoint.
/**
* Registers/Un-registers a skip, point where mediator disables from mediation flow
*
* @param synCfg Synapse configuration
* @param sequenceType Synapse sequence type
* @param seqKey name of the Sequence
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerSequenceMediationFlowBreakPoint(SynapseConfiguration synCfg, String sequenceType, String seqKey, int[] position, boolean registerMode) {
SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(sequenceType.toUpperCase());
SynapseMediationFlowPoint breakPoint = new SequenceMediationFlowPoint();
breakPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
breakPoint.setKey(seqKey);
breakPoint.setMediatorPosition(position);
((SequenceMediationFlowPoint) breakPoint).setSynapseSequenceType(synapseSequenceType);
((SequenceMediationFlowPoint) breakPoint).setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE);
Mediator seqMediator = null;
if (synapseSequenceType.equals(SynapseSequenceType.NAMED)) {
seqMediator = synCfg.getSequence(seqKey);
}
if (seqMediator != null) {
Mediator current_mediator = null;
current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, seqMediator, position);
if (current_mediator != null) {
breakPoint.setMediatorReference(current_mediator);
if (registerMode) {
if (!((AbstractMediator) current_mediator).isBreakPoint()) {
((AbstractMediator) current_mediator).setBreakPoint(true);
((AbstractMediator) current_mediator).registerMediationFlowPoint(breakPoint);
if (log.isDebugEnabled()) {
log.debug("Registered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Sequence " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Already breakpoint enabled at mediator position " + logMediatorPosition(breakPoint) + " for Sequence " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_ENABLED).toString());
}
} else {
if (((AbstractMediator) current_mediator).isBreakPoint()) {
((AbstractMediator) current_mediator).unregisterMediationFlowPoint();
((AbstractMediator) current_mediator).setBreakPoint(false);
if (log.isDebugEnabled()) {
log.debug("Unregistered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Sequence " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Already breakpoint disabled at mediator position " + logMediatorPosition(breakPoint) + " for Sequence " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_DISABLED).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Sequence " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Sequence " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Non existing sequence for key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Non existing sequence for key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
}
}
}
use of org.apache.synapse.debug.constructs.SynapseMediationFlowPoint in project wso2-synapse by wso2.
the class TemplateDebugUtil method registerTemplateMediationFlowSkip.
/**
* Registers/Un-registers a skip, point where mediator disables from mediation flow
*
* @param synCfg Synapse configuration
* @param templateKey name of the Template
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerTemplateMediationFlowSkip(SynapseConfiguration synCfg, String templateKey, int[] position, boolean registerMode) {
SynapseMediationFlowPoint skipPoint = new SynapseMediationFlowPoint();
skipPoint.setSynapseMediationComponent(SynapseMediationComponent.TEMPLATE);
skipPoint.setKey(templateKey);
skipPoint.setMediatorPosition(position);
Mediator templateMediator = null;
templateMediator = synCfg.getSequenceTemplate(templateKey);
if (templateMediator != null) {
Mediator current_mediator = null;
current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, templateMediator, position);
if (current_mediator != null) {
skipPoint.setMediatorReference(current_mediator);
if (registerMode) {
if (!((AbstractMediator) current_mediator).isSkipEnabled()) {
((AbstractMediator) current_mediator).setSkipEnabled(true);
((AbstractMediator) current_mediator).registerMediationFlowPoint(skipPoint);
if (log.isDebugEnabled()) {
log.debug("Registered skip at mediator position " + logMediatorPosition(skipPoint) + " for Template key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed register skip. Already skip enabled at mediator position " + logMediatorPosition(skipPoint) + " for Template key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_SKIP_ENABLED).toString());
}
} else {
if (((AbstractMediator) current_mediator).isSkipEnabled()) {
((AbstractMediator) current_mediator).unregisterMediationFlowPoint();
((AbstractMediator) current_mediator).setSkipEnabled(false);
if (log.isDebugEnabled()) {
log.debug("Unregistered skip at mediator position " + logMediatorPosition(skipPoint) + " for Template key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister skip. Already skip disabled at mediator position " + logMediatorPosition(skipPoint) + " for Template key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_SKIP_DISABLED).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register skip. Non existing mediator position at " + logMediatorPosition(skipPoint) + " for Template key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister skip. Non existing mediator position at " + logMediatorPosition(skipPoint) + " for Template key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register skip. Non existing template for key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_TEMPLATE).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister skip. Non existing template for key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_TEMPLATE).toString());
}
}
}
use of org.apache.synapse.debug.constructs.SynapseMediationFlowPoint in project wso2-synapse by wso2.
the class TemplateDebugUtil method registerTemplateMediationFlowBreakPoint.
/**
* Registers/Un-registers a breakpoint, point where mediation flow gets suspended
*
* @param synCfg Synapse configuration
* @param templateKey name of the Template
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerTemplateMediationFlowBreakPoint(SynapseConfiguration synCfg, String templateKey, int[] position, boolean registerMode) {
SynapseMediationFlowPoint breakPoint = new SynapseMediationFlowPoint();
breakPoint.setSynapseMediationComponent(SynapseMediationComponent.TEMPLATE);
breakPoint.setKey(templateKey);
breakPoint.setMediatorPosition(position);
Mediator templateMediator = null;
templateMediator = synCfg.getSequenceTemplate(templateKey);
if (templateMediator != null) {
Mediator current_mediator = null;
current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, templateMediator, position);
if (current_mediator != null) {
breakPoint.setMediatorReference(current_mediator);
if (registerMode) {
if (!((AbstractMediator) current_mediator).isBreakPoint()) {
((AbstractMediator) current_mediator).setBreakPoint(true);
((AbstractMediator) current_mediator).registerMediationFlowPoint(breakPoint);
if (log.isDebugEnabled()) {
log.debug("Registered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Template key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Already breakpoint enabled at mediator position " + logMediatorPosition(breakPoint) + " for Template key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_ENABLED).toString());
}
} else {
if (((AbstractMediator) current_mediator).isBreakPoint()) {
((AbstractMediator) current_mediator).unregisterMediationFlowPoint();
((AbstractMediator) current_mediator).setBreakPoint(false);
if (log.isDebugEnabled()) {
log.debug("Unregistered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Template key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Already breakpoint disabled at mediator position " + logMediatorPosition(breakPoint) + " for Template key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_DISABLED).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Template key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Template key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Non existing template for key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_TEMPLATE).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Non existing template for key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_TEMPLATE).toString());
}
}
}
Aggregations