Search in sources :

Example 1 with ExchangeMetrics

use of org.apache.cxf.metrics.ExchangeMetrics in project cxf by apache.

the class AbstractMetricsInterceptor method getExchangeMetrics.

protected ExchangeMetrics getExchangeMetrics(Message m, boolean create) {
    ExchangeMetrics ctx = m.getExchange().get(ExchangeMetrics.class);
    if (ctx == null && create) {
        ctx = new ExchangeMetrics(m.getExchange());
        m.getExchange().put(ExchangeMetrics.class, ctx);
        addEndpointMetrics(ctx, m);
    }
    return ctx;
}
Also used : ExchangeMetrics(org.apache.cxf.metrics.ExchangeMetrics)

Example 2 with ExchangeMetrics

use of org.apache.cxf.metrics.ExchangeMetrics in project cxf by apache.

the class MetricsMessageClientOutInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    if (isRequestor(message)) {
        ExchangeMetrics ctx = getExchangeMetrics(message, true);
        InputStream in = message.getContent(InputStream.class);
        if (in != null) {
            CountingInputStream newIn = new CountingInputStream(in);
            message.setContent(InputStream.class, newIn);
            message.getExchange().put(CountingInputStream.class, newIn);
        }
        addOperationMetrics(ctx, message, message.getExchange().getBindingOperationInfo());
        ctx.start();
    }
}
Also used : InputStream(java.io.InputStream) ExchangeMetrics(org.apache.cxf.metrics.ExchangeMetrics)

Example 3 with ExchangeMetrics

use of org.apache.cxf.metrics.ExchangeMetrics in project cxf by apache.

the class MetricsMessageInPreInvokeInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    if (!isRequestor(message)) {
        Exchange ex = message.getExchange();
        // we now know the operation, start metrics for it
        ExchangeMetrics ctx = getExchangeMetrics(message, false);
        if (ctx != null) {
            addOperationMetrics(ctx, message, ex.getBindingOperationInfo());
        }
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) ExchangeMetrics(org.apache.cxf.metrics.ExchangeMetrics)

Example 4 with ExchangeMetrics

use of org.apache.cxf.metrics.ExchangeMetrics in project cxf by apache.

the class CustomerMetricsInterceptor method handleMessage.

@Override
public void handleMessage(Message message) throws Fault {
    ExchangeMetrics m = message.getExchange().get(ExchangeMetrics.class);
    if (m != null) {
        Map<String, List<String>> h = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
        String auth = h.get("Authorization").toString();
        auth = auth.substring(auth.indexOf(' ') + 1);
        try {
            auth = new String(Base64Utility.decode(auth));
        } catch (Base64Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        auth = auth.substring(0, auth.indexOf(':'));
        Customer c = customers.get(auth);
        if (c == null) {
            throw new RuntimeException("Not authorized");
        }
        m.addContext(c.getMetricsContext(registry));
        message.getExchange().put(Customer.class, c);
    }
}
Also used : ExchangeMetrics(org.apache.cxf.metrics.ExchangeMetrics) Base64Exception(org.apache.cxf.common.util.Base64Exception) List(java.util.List)

Example 5 with ExchangeMetrics

use of org.apache.cxf.metrics.ExchangeMetrics in project cxf by apache.

the class MetricsMessageInInterceptor method handleMessage.

public void handleMessage(Message message) throws Fault {
    if (!isRequestor(message)) {
        ExchangeMetrics ctx = getExchangeMetrics(message, true);
        InputStream in = message.getContent(InputStream.class);
        if (in != null) {
            CountingInputStream newIn = new CountingInputStream(in);
            message.setContent(InputStream.class, newIn);
            message.getExchange().put(CountingInputStream.class, newIn);
        }
        ctx.start();
    }
}
Also used : InputStream(java.io.InputStream) ExchangeMetrics(org.apache.cxf.metrics.ExchangeMetrics)

Aggregations

ExchangeMetrics (org.apache.cxf.metrics.ExchangeMetrics)5 InputStream (java.io.InputStream)2 List (java.util.List)1 Base64Exception (org.apache.cxf.common.util.Base64Exception)1 Exchange (org.apache.cxf.message.Exchange)1