Search in sources :

Example 1 with AspectConfigurable

use of org.apache.synapse.aspects.AspectConfigurable in project wso2-synapse by wso2.

the class AbstractMediatorFactory method processAuditStatus.

/**
 * This is to Initialize the mediator regarding tracing and statistics.
 *
 * @param mediator of which trace state has to be set
 * @param mediatorOmElement from which the trace state is extracted
 *
 * @since 2.0
 */
protected void processAuditStatus(Mediator mediator, OMElement mediatorOmElement) {
    String name = null;
    if (mediator instanceof Nameable) {
        name = ((Nameable) mediator).getName();
    }
    if (name == null || "".equals(name)) {
        name = SynapseConstants.ANONYMOUS_SEQUENCE;
    }
    if (mediator instanceof AspectConfigurable) {
        AspectConfiguration configuration = new AspectConfiguration(name);
        ((AspectConfigurable) mediator).configure(configuration);
        OMAttribute statistics = mediatorOmElement.getAttribute(ATT_STATS);
        if (statistics != null) {
            String statisticsValue = statistics.getAttributeValue();
            if (statisticsValue != null) {
                if (XMLConfigConstants.STATISTICS_ENABLE.equals(statisticsValue)) {
                    configuration.enableStatistics();
                }
            }
        }
        OMAttribute trace = mediatorOmElement.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.TRACE_ATTRIB_NAME));
        if (trace != null) {
            String traceValue = trace.getAttributeValue();
            if (traceValue != null) {
                if (traceValue.equals(XMLConfigConstants.TRACE_ENABLE)) {
                    configuration.enableTracing();
                }
            }
        }
    }
}
Also used : Nameable(org.apache.synapse.Nameable) AspectConfigurable(org.apache.synapse.aspects.AspectConfigurable) QName(javax.xml.namespace.QName) AspectConfiguration(org.apache.synapse.aspects.AspectConfiguration) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 2 with AspectConfigurable

use of org.apache.synapse.aspects.AspectConfigurable in project wso2-synapse by wso2.

the class AbstractMediatorSerializer method saveTracingState.

/**
 * Perform common functions and finalize the mediator serialization.
 * i.e. process any common attributes
 *
 * @param mediatorOmElement the OMElement being created
 * @param mediator the Mediator instance being serialized
 */
protected static void saveTracingState(OMElement mediatorOmElement, Mediator mediator) {
    int traceState = mediator.getTraceState();
    String traceValue = null;
    if (traceState == org.apache.synapse.SynapseConstants.TRACING_ON) {
        traceValue = XMLConfigConstants.TRACE_ENABLE;
    } else if (traceState == org.apache.synapse.SynapseConstants.TRACING_OFF) {
        traceValue = XMLConfigConstants.TRACE_DISABLE;
    }
    if (traceValue != null) {
        mediatorOmElement.addAttribute(fac.createOMAttribute(XMLConfigConstants.TRACE_ATTRIB_NAME, nullNS, traceValue));
    }
    if (mediator instanceof AspectConfigurable) {
        StatisticsConfigurable statisticsConfigurable = ((AspectConfigurable) mediator).getAspectConfiguration();
        if (statisticsConfigurable != null && statisticsConfigurable.isStatisticsEnable()) {
            mediatorOmElement.addAttribute(fac.createOMAttribute(XMLConfigConstants.STATISTICS_ATTRIB_NAME, nullNS, XMLConfigConstants.STATISTICS_ENABLE));
        }
        if (statisticsConfigurable != null && statisticsConfigurable.isTracingEnabled()) {
            mediatorOmElement.addAttribute(fac.createOMAttribute(XMLConfigConstants.TRACE_ATTRIB_NAME, nullNS, XMLConfigConstants.TRACE_ENABLE));
        }
    }
}
Also used : AspectConfigurable(org.apache.synapse.aspects.AspectConfigurable) StatisticsConfigurable(org.apache.synapse.aspects.statistics.StatisticsConfigurable)

Aggregations

AspectConfigurable (org.apache.synapse.aspects.AspectConfigurable)2 QName (javax.xml.namespace.QName)1 OMAttribute (org.apache.axiom.om.OMAttribute)1 Nameable (org.apache.synapse.Nameable)1 AspectConfiguration (org.apache.synapse.aspects.AspectConfiguration)1 StatisticsConfigurable (org.apache.synapse.aspects.statistics.StatisticsConfigurable)1