Search in sources :

Example 56 with Mediator

use of org.apache.synapse.Mediator in project wso2-synapse by wso2.

the class InboundEndpointDebugUtil method registerInboundSequenceMediationFlowBreakPoint.

/**
 * Registers/Un-registers a breakpoint, point where mediation flow get suspended
 *
 * @param synCfg Synapse configuration
 * @param sequenceType 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 registerInboundSequenceMediationFlowBreakPoint(SynapseConfiguration synCfg, String sequenceType, String inboundKey, int[] position, boolean registerMode) {
    SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(sequenceType.toUpperCase());
    SequenceMediationFlowPoint breakPoint = new SequenceMediationFlowPoint();
    breakPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
    breakPoint.setKey(inboundKey);
    breakPoint.setMediatorPosition(position);
    breakPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_INBOUND);
    breakPoint.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 " + breakPoint.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) {
            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 Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    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 Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    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 Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    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 Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    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 Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.getSynapseSequenceType().toString());
                }
                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 Inbound Endpoint key " + breakPoint.getKey() + " sequence " + breakPoint.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 breakpoint. Non existing sequence " + breakPoint.getSynapseSequenceType().toString() + " for Inbound Endpoint 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 " + breakPoint.getSynapseSequenceType().toString() + " for Inbound Endpoint key " + breakPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        }
    }
}
Also used : SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) InboundEndpoint(org.apache.synapse.inbound.InboundEndpoint) SynapseSequenceType(org.apache.synapse.debug.constructs.SynapseSequenceType) AbstractMediator(org.apache.synapse.mediators.AbstractMediator) Mediator(org.apache.synapse.Mediator) AbstractMediator(org.apache.synapse.mediators.AbstractMediator)

Example 57 with Mediator

use of org.apache.synapse.Mediator in project wso2-synapse by wso2.

the class MediatorTreeTraverseUtil method getMediatorReference.

/**
 * Returns mediator referece associated with position while traversing the mediator tree.
 *
 * @param synCfg      synapse configuration reference
 * @param seqMediator sequence mediator which traverse happens
 * @param position    array of tree nodes specifying position integer with respect to it's parent node
 *                    starting from the root parent.
 * @return Mediator reference
 */
public static Mediator getMediatorReference(SynapseConfiguration synCfg, Mediator seqMediator, int[] position) {
    Mediator current_mediator = null;
    for (int counter = 0; counter < position.length; counter++) {
        if (counter == 0) {
            int mediatorCount = ((AbstractListMediator) seqMediator).getList().size();
            int correctedPosition = getCorrectedPossition((AbstractListMediator) seqMediator, position[counter]);
            if (mediatorCount > correctedPosition) {
                current_mediator = ((AbstractListMediator) seqMediator).getChild(correctedPosition);
            } else {
                log.warn("Mediator position requested is larger than last index : " + position[counter]);
            }
        }
        if (current_mediator != null && counter != 0) {
            if (current_mediator instanceof InvokeMediator) {
                current_mediator = synCfg.getSequenceTemplate(((InvokeMediator) current_mediator).getTargetTemplate());
            } else if (current_mediator instanceof FilterMediator) {
                if (position[counter] == 0) {
                    if (((FilterMediator) current_mediator).getElseMediator() != null) {
                        current_mediator = ((FilterMediator) current_mediator).getElseMediator();
                    } else if (((FilterMediator) current_mediator).getElseKey() != null) {
                        current_mediator = synCfg.getSequence(((FilterMediator) current_mediator).getElseKey());
                    }
                    continue;
                } else if (position[counter] == 1) {
                    if (((FilterMediator) current_mediator).getThenKey() != null) {
                        current_mediator = synCfg.getSequence(((FilterMediator) current_mediator).getThenKey());
                    } else {
                        counter = counter + 1;
                        if (counter < position.length) {
                            int mediatorCount = ((AbstractListMediator) current_mediator).getList().size();
                            int correctedPosition = getCorrectedPossition((AbstractListMediator) current_mediator, position[counter]);
                            if (mediatorCount > correctedPosition) {
                                current_mediator = ((AbstractListMediator) current_mediator).getChild(correctedPosition);
                            } else {
                                log.warn("Mediator position requested is larger than last index : " + position[counter]);
                            }
                        }
                    }
                    continue;
                }
            } else if (current_mediator instanceof SwitchMediator) {
                if (position[counter] == 0) {
                    SwitchCase switchCase = ((SwitchMediator) current_mediator).getDefaultCase();
                    if (switchCase != null) {
                        current_mediator = switchCase.getCaseMediator();
                    } else {
                        current_mediator = null;
                    }
                } else {
                    SwitchCase switchCase = ((SwitchMediator) current_mediator).getCases().get(position[counter] - 1);
                    if (switchCase != null) {
                        current_mediator = switchCase.getCaseMediator();
                    } else {
                        current_mediator = null;
                    }
                }
                continue;
            } else if (current_mediator instanceof AggregateMediator) {
                if (((AggregateMediator) current_mediator).getOnCompleteSequence() != null) {
                    current_mediator = ((AggregateMediator) current_mediator).getOnCompleteSequence();
                } else if (((AggregateMediator) current_mediator).getOnCompleteSequenceRef() != null) {
                    current_mediator = synCfg.getSequence(((AggregateMediator) current_mediator).getOnCompleteSequenceRef());
                }
            } else if (current_mediator instanceof ForEachMediator) {
                if (((ForEachMediator) current_mediator).getSequence() != null) {
                    current_mediator = ((ForEachMediator) current_mediator).getSequence();
                } else if (((ForEachMediator) current_mediator).getSequenceRef() != null) {
                    current_mediator = synCfg.getSequence(((ForEachMediator) current_mediator).getSequenceRef());
                }
            } else if (current_mediator instanceof IterateMediator) {
                if (((IterateMediator) current_mediator).getTarget().getSequence() != null) {
                    current_mediator = ((IterateMediator) current_mediator).getTarget().getSequence();
                } else if (((IterateMediator) current_mediator).getTarget().getSequenceRef() != null) {
                    current_mediator = synCfg.getSequence(((IterateMediator) current_mediator).getTarget().getSequenceRef());
                }
            } else if (current_mediator instanceof CloneMediator) {
                if (((CloneMediator) current_mediator).getTargets().get(position[counter]).getSequence() != null) {
                    current_mediator = ((CloneMediator) current_mediator).getTargets().get(position[counter]).getSequence();
                } else if (((CloneMediator) current_mediator).getTargets().get(position[counter]).getSequenceRef() != null) {
                    current_mediator = synCfg.getSequence(((CloneMediator) current_mediator).getTargets().get(position[counter]).getSequenceRef());
                }
                continue;
            } else if (current_mediator.getType().equals("ThrottleMediator")) {
                current_mediator = ((EnclosedInlinedSequence) current_mediator).getInlineSequence(synCfg, position[counter]);
                continue;
            } else if (current_mediator.getType().equals("EntitlementMediator")) {
                current_mediator = ((EnclosedInlinedSequence) current_mediator).getInlineSequence(synCfg, position[counter]);
                continue;
            } else if (current_mediator.getType().equals("CacheMediator")) {
                current_mediator = ((EnclosedInlinedSequence) current_mediator).getInlineSequence(synCfg, 0);
            }
            if (current_mediator != null && (current_mediator instanceof AbstractListMediator)) {
                int mediatorCount = ((AbstractListMediator) current_mediator).getList().size();
                int correctedPosition = getCorrectedPossition((AbstractListMediator) current_mediator, position[counter]);
                if (mediatorCount > correctedPosition) {
                    current_mediator = ((AbstractListMediator) current_mediator).getChild(correctedPosition);
                } else {
                    log.warn("Mediator position requested is larger than last index : " + position[counter]);
                }
            } else {
                current_mediator = null;
                break;
            }
        }
    }
    return current_mediator;
}
Also used : AbstractListMediator(org.apache.synapse.mediators.AbstractListMediator) SwitchCase(org.apache.synapse.config.xml.SwitchCase) AggregateMediator(org.apache.synapse.mediators.eip.aggregator.AggregateMediator) ForEachMediator(org.apache.synapse.mediators.builtin.ForEachMediator) EnclosedInlinedSequence(org.apache.synapse.debug.constructs.EnclosedInlinedSequence) InvokeMediator(org.apache.synapse.mediators.template.InvokeMediator) FilterMediator(org.apache.synapse.mediators.filters.FilterMediator) SwitchMediator(org.apache.synapse.mediators.filters.SwitchMediator) InvokeMediator(org.apache.synapse.mediators.template.InvokeMediator) ForEachMediator(org.apache.synapse.mediators.builtin.ForEachMediator) IterateMediator(org.apache.synapse.mediators.eip.splitter.IterateMediator) CommentMediator(org.apache.synapse.mediators.builtin.CommentMediator) FilterMediator(org.apache.synapse.mediators.filters.FilterMediator) CloneMediator(org.apache.synapse.mediators.eip.splitter.CloneMediator) Mediator(org.apache.synapse.Mediator) AggregateMediator(org.apache.synapse.mediators.eip.aggregator.AggregateMediator) AbstractListMediator(org.apache.synapse.mediators.AbstractListMediator) SwitchMediator(org.apache.synapse.mediators.filters.SwitchMediator) IterateMediator(org.apache.synapse.mediators.eip.splitter.IterateMediator) CloneMediator(org.apache.synapse.mediators.eip.splitter.CloneMediator)

Example 58 with Mediator

use of org.apache.synapse.Mediator in project wso2-synapse by wso2.

the class ProxyDebugUtil method registerProxySequenceMediationFlowSkip.

/**
 * Registers/Un-registers a skip, point where mediator disables from medation flow
 *
 * @param synCfg Synapse configuration
 * @param seqType Synapse sequence type
 * @param proxyKey name of the Proxy Service
 * @param position array of integers that uniquely specifies a point in mediation route
 * @param registerMode specify whether register or un register
 */
public static void registerProxySequenceMediationFlowSkip(SynapseConfiguration synCfg, String seqType, String proxyKey, int[] position, boolean registerMode) {
    SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(seqType.toUpperCase());
    SequenceMediationFlowPoint skipPoint = new SequenceMediationFlowPoint();
    skipPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
    skipPoint.setKey(proxyKey);
    skipPoint.setMediatorPosition(position);
    skipPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY);
    skipPoint.setSynapseSequenceType(synapseSequenceType);
    Mediator seqMediator = null;
    ProxyService proxy = null;
    proxy = synCfg.getProxyService(proxyKey);
    if (proxy != null) {
        if (synapseSequenceType.equals(SynapseSequenceType.PROXY_INSEQ)) {
            seqMediator = proxy.getTargetInLineInSequence();
        } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_OUTSEQ)) {
            seqMediator = proxy.getTargetInLineOutSequence();
        } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_FAULTSEQ)) {
            seqMediator = proxy.getTargetInLineFaultSequence();
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Non existing Proxy for key " + skipPoint.getKey());
        }
        debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROXY_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 Proxy 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 Proxy 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 Proxy 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 Proxy 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 Proxy 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 Proxy 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 Proxy 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 Proxy key " + skipPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        }
    }
}
Also used : SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) SynapseSequenceType(org.apache.synapse.debug.constructs.SynapseSequenceType) ProxyService(org.apache.synapse.core.axis2.ProxyService) AbstractMediator(org.apache.synapse.mediators.AbstractMediator) Mediator(org.apache.synapse.Mediator) AbstractMediator(org.apache.synapse.mediators.AbstractMediator)

Example 59 with Mediator

use of org.apache.synapse.Mediator in project wso2-synapse by wso2.

the class ProxyDebugUtil method registerProxySequenceMediationFlowBreakPoint.

/**
 * Registers/Un-registers a breakpoint, point where mediation flow get suspended
 *
 * @param synCfg Synapse configuration
 * @param sequenceType Synapse sequence type
 * @param proxyKey name of the Proxy Service
 * @param position array of integers that uniquely specifies a point in mediation route
 * @param registerMode specify whether register or un register
 */
public static void registerProxySequenceMediationFlowBreakPoint(SynapseConfiguration synCfg, String sequenceType, String proxyKey, int[] position, boolean registerMode) {
    SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(sequenceType.toUpperCase());
    SequenceMediationFlowPoint breakPoint = new SequenceMediationFlowPoint();
    breakPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
    breakPoint.setKey(proxyKey);
    breakPoint.setMediatorPosition(position);
    breakPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY);
    breakPoint.setSynapseSequenceType(synapseSequenceType);
    Mediator seqMediator = null;
    ProxyService proxy = null;
    proxy = synCfg.getProxyService(proxyKey);
    if (proxy != null) {
        if (synapseSequenceType.equals(SynapseSequenceType.PROXY_INSEQ)) {
            seqMediator = proxy.getTargetInLineInSequence();
        } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_OUTSEQ)) {
            seqMediator = proxy.getTargetInLineOutSequence();
        } else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_FAULTSEQ)) {
            seqMediator = proxy.getTargetInLineFaultSequence();
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Non existing Proxy for the key " + breakPoint.getKey());
        }
        debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROXY_NOT_FOUND).toString());
        return;
    }
    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 Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    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 Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    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 Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    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 Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                    }
                    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 Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
                }
                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 Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.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 breakpoint. Non existing sequence " + breakPoint.getSynapseSequenceType().toString() + " for Proxy 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 " + breakPoint.getSynapseSequenceType().toString() + " for Proxy key " + breakPoint.getKey());
            }
            debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
        }
    }
}
Also used : SequenceMediationFlowPoint(org.apache.synapse.debug.constructs.SequenceMediationFlowPoint) SynapseSequenceType(org.apache.synapse.debug.constructs.SynapseSequenceType) ProxyService(org.apache.synapse.core.axis2.ProxyService) AbstractMediator(org.apache.synapse.mediators.AbstractMediator) Mediator(org.apache.synapse.Mediator) AbstractMediator(org.apache.synapse.mediators.AbstractMediator)

Example 60 with Mediator

use of org.apache.synapse.Mediator in project wso2-synapse by wso2.

the class MultiXMLConfigurationBuilder method createSequences.

private static void createSequences(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) {
    File sequencesDir = new File(rootDirPath, SEQUENCES_DIR);
    if (sequencesDir.exists()) {
        if (log.isDebugEnabled()) {
            log.debug("Loading sequences from : " + sequencesDir.getPath());
        }
        Iterator sequences = FileUtils.iterateFiles(sequencesDir, extensions, false);
        while (sequences.hasNext()) {
            File file = (File) sequences.next();
            try {
                OMElement document = getOMElement(file);
                Mediator seq = SynapseXMLConfigurationFactory.defineSequence(synapseConfig, document, properties);
                if (seq != null && seq instanceof SequenceMediator) {
                    SequenceMediator sequence = (SequenceMediator) seq;
                    sequence.setFileName(file.getName());
                    synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), sequence.getName());
                }
            } catch (Exception e) {
                String msg = "Sequence configuration cannot be built from : " + file.getName();
                handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_SEQUENCES, msg, e);
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) OMElement(org.apache.axiom.om.OMElement) TemplateMediator(org.apache.synapse.mediators.template.TemplateMediator) Mediator(org.apache.synapse.Mediator) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) SequenceMediator(org.apache.synapse.mediators.base.SequenceMediator) XMLStreamException(javax.xml.stream.XMLStreamException) SynapseException(org.apache.synapse.SynapseException)

Aggregations

Mediator (org.apache.synapse.Mediator)108 Properties (java.util.Properties)30 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)24 OMElement (org.apache.axiom.om.OMElement)22 AbstractMediator (org.apache.synapse.mediators.AbstractMediator)22 MessageContext (org.apache.synapse.MessageContext)16 SynapseLog (org.apache.synapse.SynapseLog)16 FlowContinuableMediator (org.apache.synapse.mediators.FlowContinuableMediator)13 SynapseException (org.apache.synapse.SynapseException)12 TestMessageContext (org.apache.synapse.TestMessageContext)12 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)12 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)12 TemplateMediator (org.apache.synapse.mediators.template.TemplateMediator)12 Test (org.junit.Test)10 AbstractListMediator (org.apache.synapse.mediators.AbstractListMediator)9 SynapseSequenceType (org.apache.synapse.debug.constructs.SynapseSequenceType)8 SequenceMediationFlowPoint (org.apache.synapse.debug.constructs.SequenceMediationFlowPoint)6 ForEachMediatorFactory (org.apache.synapse.config.xml.ForEachMediatorFactory)5 MediatorFactory (org.apache.synapse.config.xml.MediatorFactory)5 MediatorFaultHandler (org.apache.synapse.mediators.MediatorFaultHandler)5