use of org.apache.synapse.debug.constructs.ConnectorMediationFlowPoint in project wso2-synapse by wso2.
the class ConnectorDebugUtil method registerConnectorMediationFlowSkip.
/**
* Registers/Un-registers a skip, point where mediator disables from mediation flow
*
* @param synCfg Synapse configuration
* @param connectorMethod method name of the template
* @param connectorKey name of the Connector
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerConnectorMediationFlowSkip(SynapseConfiguration synCfg, String connectorKey, String connectorMethod, int[] position, boolean registerMode) {
ConnectorMediationFlowPoint skipPoint = new ConnectorMediationFlowPoint();
skipPoint.setSynapseMediationComponent(SynapseMediationComponent.CONNECTOR);
skipPoint.setKey(connectorKey);
skipPoint.setConnectorMediationComponentMethod(connectorMethod);
skipPoint.setMediatorPosition(position);
Mediator templateMediator = null;
String template_key = SynapseDebugManagerConstants.CONNECTOR_PACKAGE + "." + connectorKey + "." + connectorMethod;
templateMediator = synCfg.getSequenceTemplate(template_key);
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 Connector key " + skipPoint.getKey() + " method " + skipPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + skipPoint.getKey() + " method " + skipPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + skipPoint.getKey() + " method " + skipPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + skipPoint.getKey() + " method " + skipPoint.getConnectorMediationComponentMethod());
}
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 " + logMediatorPosition(skipPoint) + " for Connector key " + skipPoint.getKey() + " method " + skipPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + skipPoint.getKey() + " method " + skipPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + skipPoint.getKey() + " method " + skipPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + skipPoint.getKey() + " method " + skipPoint.getConnectorMediationComponentMethod());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_TEMPLATE).toString());
}
}
}
use of org.apache.synapse.debug.constructs.ConnectorMediationFlowPoint in project wso2-synapse by wso2.
the class ConnectorDebugUtil method registerConnectorMediationFlowBreakPoint.
/**
* Registers/Un-registers a breakpoint, point where mediation flow get suspended
*
* @param synCfg Synapse configuration
* @param connectorMethod method name of the template
* @param connectorKey name of the Connector
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerConnectorMediationFlowBreakPoint(SynapseConfiguration synCfg, String connectorKey, String connectorMethod, int[] position, boolean registerMode) {
ConnectorMediationFlowPoint breakPoint = new ConnectorMediationFlowPoint();
breakPoint.setSynapseMediationComponent(SynapseMediationComponent.CONNECTOR);
breakPoint.setKey(connectorKey);
breakPoint.setConnectorMediationComponentMethod(connectorMethod);
breakPoint.setMediatorPosition(position);
Mediator templateMediator = null;
String template_key = SynapseDebugManagerConstants.CONNECTOR_PACKAGE + "." + connectorKey + "." + connectorMethod;
templateMediator = synCfg.getSequenceTemplate(template_key);
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 Connector key " + breakPoint.getKey() + " method " + breakPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + breakPoint.getKey() + " method " + breakPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + breakPoint.getKey() + " method " + breakPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + breakPoint.getKey() + " method " + breakPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + breakPoint.getKey() + " method " + breakPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + breakPoint.getKey() + " method " + breakPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + breakPoint.getKey() + " method " + breakPoint.getConnectorMediationComponentMethod());
}
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 Connector key " + breakPoint.getKey() + " method " + breakPoint.getConnectorMediationComponentMethod());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_TEMPLATE).toString());
}
}
}
Aggregations