Package org.apache.synapse.mediators.eip.sample

Examples of org.apache.synapse.mediators.eip.sample.SamplingThrottleMediator$MessageProcessor


    protected OMElement serializeSpecificMediator(Mediator mediator) {
        OMElement samplerElem = fac.createOMElement("sampler", synNS);
        saveTracingState(samplerElem, mediator);

        SamplingThrottleMediator samplingThrottleMediator = (SamplingThrottleMediator) mediator;

        if (samplingThrottleMediator.getId() != null) {
            samplerElem.addAttribute("id", samplingThrottleMediator.getId(), nullNS);
        }
        samplerElem.addAttribute("rate",
                Integer.toString(samplingThrottleMediator.getSamplingRate()), nullNS);
        samplerElem.addAttribute("unitTime",
                Long.toString(samplingThrottleMediator.getUnitTime()), nullNS);

        if (samplingThrottleMediator.isMessageQueueExplicitlySet()) {
            OMElement messageQueueElem = fac.createOMElement("messageQueue", synNS);
            messageQueueElem.addAttribute("class",
                    samplingThrottleMediator.getMessageQueue().getClass().getName(), nullNS);
            samplerElem.addChild(messageQueueElem);
        }

        if (samplingThrottleMediator.getTarget() != null) {
            samplerElem.addChild(
                    TargetSerializer.serializeTarget(samplingThrottleMediator.getTarget()));
        } else {
            handleException("Couldn't find the target for the sampler. " +
                    "Target is mandatory for a sampler");
        }
View Full Code Here


    private static final QName CLASS_ATTR
            = new QName(XMLConfigConstants.NULL_NAMESPACE, "class");

    protected Mediator createSpecificMediator(OMElement omElement, Properties properties) {

        SamplingThrottleMediator samplingThrottleMediator = new SamplingThrottleMediator();
        processAuditStatus(samplingThrottleMediator, omElement);

        OMAttribute idAttribute = omElement.getAttribute(ID_ATTR);
        if (idAttribute != null) {
            samplingThrottleMediator.setId(idAttribute.getAttributeValue());
        }

        OMAttribute rateAttribute = omElement.getAttribute(RATE_ATTR);
        if (rateAttribute != null) {
            try {
                samplingThrottleMediator.setSamplingRate(
                        Integer.parseInt(rateAttribute.getAttributeValue()));
            } catch (NumberFormatException nfe) {
                handleException("Sampling rate has to be an integer value, but found : "
                        + rateAttribute.getAttributeValue());
            }
        }

        OMAttribute unitTimeAttribute = omElement.getAttribute(UNIT_TIME_ATTR);
        if (unitTimeAttribute != null) {
            try {
                samplingThrottleMediator.setUnitTime(
                        Long.parseLong(unitTimeAttribute.getAttributeValue()));
            } catch (NumberFormatException nfe) {
                handleException("Sampling unitTime has to be a long value in milliseconds, " +
                        "but found : " + rateAttribute.getAttributeValue());
            }
        }

        OMElement targetElem = omElement.getFirstChildWithName(TARGET_Q);
        if (targetElem != null) {
            Target target = TargetFactory.createTarget(targetElem, properties);
            samplingThrottleMediator.setTarget(target);
        } else {
            handleException("Sampler requires a target for the sampling mediation");
        }

        OMElement messageQueueElem = omElement.getFirstChildWithName(MESSAGE_QUEUE_Q);
        if (messageQueueElem != null && messageQueueElem.getAttribute(CLASS_ATTR) != null) {
            String className = messageQueueElem.getAttributeValue(CLASS_ATTR);
            try {
                Class messageQueueImplClass = Class.forName(className);
                Object obj = messageQueueImplClass.newInstance();
                if (obj instanceof MessageQueue) {
                    samplingThrottleMediator.setMessageQueue((MessageQueue) obj);
                } else {
                    handleException("Provided message queue class : " + className
                            + " doesn't implement the org.apache.synapse.mediators." +
                            "eip.sample.MessageQueue interface");
                }
View Full Code Here

    public OMElement serializeSpecificMediator(Mediator mediator) {
        OMElement samplerElem = fac.createOMElement("sampler", synNS);
        saveTracingState(samplerElem, mediator);

        SamplingThrottleMediator samplingThrottleMediator = (SamplingThrottleMediator) mediator;

        if (samplingThrottleMediator.getId() != null) {
            samplerElem.addAttribute("id", samplingThrottleMediator.getId(), nullNS);
        }
        samplerElem.addAttribute("rate",
                Integer.toString(samplingThrottleMediator.getSamplingRate()), nullNS);
        samplerElem.addAttribute("unitTime",
                Long.toString(samplingThrottleMediator.getUnitTime()), nullNS);

        if (samplingThrottleMediator.isMessageQueueExplicitlySet()) {
            OMElement messageQueueElem = fac.createOMElement("messageQueue", synNS);
            messageQueueElem.addAttribute("class",
                    samplingThrottleMediator.getMessageQueue().getClass().getName(), nullNS);
            samplerElem.addChild(messageQueueElem);
        }

        if (samplingThrottleMediator.getTarget() != null) {
            samplerElem.addChild(
                    TargetSerializer.serializeTarget(samplingThrottleMediator.getTarget()));
        } else {
            handleException("Couldn't find the target for the sampler. " +
                    "Target is mandatory for a sampler");
        }
View Full Code Here

    private static final QName CLASS_ATTR
            = new QName(XMLConfigConstants.NULL_NAMESPACE, "class");

    public Mediator createSpecificMediator(OMElement omElement, Properties properties) {

        SamplingThrottleMediator samplingThrottleMediator = new SamplingThrottleMediator();
        processAuditStatus(samplingThrottleMediator, omElement);

        OMAttribute idAttribute = omElement.getAttribute(ID_ATTR);
        if (idAttribute != null) {
            samplingThrottleMediator.setId(idAttribute.getAttributeValue());
        }

        OMAttribute rateAttribute = omElement.getAttribute(RATE_ATTR);
        if (rateAttribute != null) {
            try {
                samplingThrottleMediator.setSamplingRate(
                        Integer.parseInt(rateAttribute.getAttributeValue()));
            } catch (NumberFormatException nfe) {
                handleException("Sampling rate has to be an integer value, but found : "
                        + rateAttribute.getAttributeValue());
            }
        }

        OMAttribute unitTimeAttribute = omElement.getAttribute(UNIT_TIME_ATTR);
        if (unitTimeAttribute != null) {
            try {
                samplingThrottleMediator.setUnitTime(
                        Long.parseLong(unitTimeAttribute.getAttributeValue()));
            } catch (NumberFormatException nfe) {
                handleException("Sampling unitTime has to be a long value in milliseconds, " +
                        "but found : " + rateAttribute.getAttributeValue());
            }
        }

        OMElement targetElem = omElement.getFirstChildWithName(TARGET_Q);
        if (targetElem != null) {
            Target target = TargetFactory.createTarget(targetElem, properties);
            samplingThrottleMediator.setTarget(target);
        } else {
            handleException("Sampler requires a target for the sampling mediation");
        }

        OMElement messageQueueElem = omElement.getFirstChildWithName(MESSAGE_QUEUE_Q);
        if (messageQueueElem != null && messageQueueElem.getAttribute(CLASS_ATTR) != null) {
            String className = messageQueueElem.getAttributeValue(CLASS_ATTR);
            try {
                Class messageQueueImplClass = Class.forName(className);
                Object obj = messageQueueImplClass.newInstance();
                if (obj instanceof MessageQueue) {
                    samplingThrottleMediator.setMessageQueue((MessageQueue) obj);
                } else {
                    handleException("Provided message queue class : " + className
                            + " doesn't implement the org.apache.synapse.mediators." +
                            "eip.sample.MessageQueue interface");
                }
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.eip.sample.SamplingThrottleMediator$MessageProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.