Search in sources :

Example 1 with Nameable

use of org.apache.synapse.Nameable 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)

Aggregations

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