use of org.apache.synapse.mediators.AbstractMediator in project wso2-synapse by wso2.
the class DebugManagerTest method testDebugManagerProcessCommandClearBreakPointProxyOutSequence.
public void testDebugManagerProcessCommandClearBreakPointProxyOutSequence() throws Exception {
ProxyService ps = new ProxyService("test_proxy_4");
TestMediator in1 = new TestMediator();
TestMediator in2 = new TestMediator();
TestMediator in3 = new TestMediator();
SequenceMediator inSeq = new SequenceMediator();
inSeq.addChild(in1);
inSeq.addChild(in2);
inSeq.addChild(in3);
TestMediator out1 = new TestMediator();
TestMediator out2 = new TestMediator();
TestMediator out3 = new TestMediator();
SequenceMediator outSeq = new SequenceMediator();
outSeq.addChild(out1);
outSeq.addChild(out2);
outSeq.addChild(out3);
ps.setTargetInLineInSequence(inSeq);
ps.setTargetInLineOutSequence(inSeq);
synConfig.addProxyService(ps.getName(), ps);
String debug_command = "{\"command\":\"set\",\"command-argument\":\"breakpoint\",\"mediation-component\":\"sequence\"," + "\"sequence\":{\"proxy\":{\"proxy-key\":\"test_proxy_4\",\"sequence-type\":\"proxy_outseq\"," + "\"mediator-position\":\"0\"}}}";
dm.processDebugCommand(debug_command);
debug_command = "{\"command\":\"clear\",\"command-argument\":\"breakpoint\",\"mediation-component\":\"sequence\"," + "\"sequence\":{\"proxy\":{\"proxy-key\":\"test_proxy_4\",\"sequence-type\":\"proxy_outseq\"," + "\"mediator-position\":\"0\"}}}";
dm.processDebugCommand(debug_command);
assertTrue(!((AbstractMediator) ps.getTargetInLineOutSequence().getChild(0)).isBreakPoint());
}
use of org.apache.synapse.mediators.AbstractMediator in project wso2-synapse by wso2.
the class InboundEndpointDebugUtil method registerInboundSequenceMediationFlowSkip.
/**
* Registers/Un-registers a skip, point where mediator disables from mediation flow
*
* @param synCfg Synapse configuration
* @param seqType Synapse sequence type
* @param inboundKey name of the Inbound Endpoint
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerInboundSequenceMediationFlowSkip(SynapseConfiguration synCfg, String seqType, String inboundKey, int[] position, boolean registerMode) {
SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(seqType.toUpperCase());
SequenceMediationFlowPoint skipPoint = new SequenceMediationFlowPoint();
skipPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
skipPoint.setKey(inboundKey);
skipPoint.setMediatorPosition(position);
skipPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_INBOUND);
skipPoint.setSynapseSequenceType(synapseSequenceType);
Mediator seqMediator = null;
InboundEndpoint inbound = null;
inbound = synCfg.getInboundEndpoint(inboundKey);
if (inbound != null) {
if (synapseSequenceType.equals(SynapseSequenceType.INBOUND_SEQ)) {
seqMediator = synCfg.getSequence(inbound.getInjectingSeq());
} else if (synapseSequenceType.equals(SynapseSequenceType.INBOUND_FAULTSEQ)) {
seqMediator = synCfg.getSequence(inbound.getOnErrorSeq());
}
} else {
if (log.isDebugEnabled()) {
log.debug("Non existing Inbound Endpoint for key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_INBOUND_NOT_FOUND).toString());
return;
}
if (seqMediator != null) {
Mediator current_mediator = null;
current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, seqMediator, 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 Inbound Endpoint key " + skipPoint.getKey() + " sequence " + skipPoint.getSynapseSequenceType().toString());
}
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 Inbound Endpoint key " + skipPoint.getKey() + " sequence " + skipPoint.getSynapseSequenceType().toString());
}
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 Inbound Endpoint key " + skipPoint.getKey() + " sequence " + skipPoint.getSynapseSequenceType().toString());
}
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 Inbound Endpoint key " + skipPoint.getKey() + " sequence " + skipPoint.getSynapseSequenceType().toString());
}
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 Inbound Endpoint key " + skipPoint.getKey() + " sequence " + skipPoint.getSynapseSequenceType().toString());
}
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 Inbound Endpoint key " + skipPoint.getKey() + " sequence " + skipPoint.getSynapseSequenceType().toString());
}
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 sequence " + skipPoint.getSynapseSequenceType().toString() + " for Inbound Endpoint key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister skip. Non existing sequence " + skipPoint.getSynapseSequenceType().toString() + " for Inbound Endpoint key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
}
}
}
use of org.apache.synapse.mediators.AbstractMediator 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.mediators.AbstractMediator in project wso2-synapse by wso2.
the class SequenceDebugUtil method registerSequenceMediationFlowSkip.
/**
* Registers/Un-registers a breakpoint, point where mediation flow get suspended
*
* @param synCfg Synapse configuration
* @param seqType 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 registerSequenceMediationFlowSkip(SynapseConfiguration synCfg, String seqType, String seqKey, int[] position, boolean registerMode) {
SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(seqType.toUpperCase());
SequenceMediationFlowPoint skipPoint = new SequenceMediationFlowPoint();
skipPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
skipPoint.setKey(seqKey);
skipPoint.setMediatorPosition(position);
skipPoint.setSynapseSequenceType(synapseSequenceType);
skipPoint.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) {
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 Sequence " + 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 Sequence " + 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 Sequence " + 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 Sequence " + 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 Sequence " + 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 Sequence " + 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 sequence for key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister skip. Non existing sequence for key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
}
}
}
use of org.apache.synapse.mediators.AbstractMediator 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