Search in sources :

Example 6 with ContextTransfer

use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.

the class CallInvokeInterceptor method getContextTransfer.

@Override
protected ContextTransfer getContextTransfer(final Advice advice) {
    return new ContextTransfer() {

        public void transfer(String key, String value) {
            Call call = (Call) advice.getTarget();
            MimeHeaders headers = call.getMessageContext().getMessage().getMimeHeaders();
            headers.addHeader(key, value);
        }
    };
}
Also used : Call(org.apache.axis.client.Call) MimeHeaders(javax.xml.soap.MimeHeaders) ContextTransfer(com.pamirs.pradar.interceptor.ContextTransfer)

Example 7 with ContextTransfer

use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.

the class InvokeInterceptor method getContextTransfer.

@Override
protected ContextTransfer getContextTransfer(final Advice advice) {
    return new ContextTransfer() {

        public void transfer(String key, String value) {
            final Message message = (Message) advice.getParameterArray()[1];
            Map<String, List> headers = (Map) message.get(Message.PROTOCOL_HEADERS);
            if (headers == null) {
                headers = new HashMap();
            }
            ((Map) headers).put(key, Collections.singletonList(value));
            message.put(Message.PROTOCOL_HEADERS, headers);
        }
    };
}
Also used : Message(org.apache.cxf.message.Message) ContextTransfer(com.pamirs.pradar.interceptor.ContextTransfer) HashMap(java.util.HashMap) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with ContextTransfer

use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.

the class AbstractRefererCallInterceptor method getContextTransfer.

@Override
protected ContextTransfer getContextTransfer(Advice advice) {
    Object[] args = advice.getParameterArray();
    final Request request = (Request) args[0];
    return new ContextTransfer() {

        @Override
        public void transfer(String key, String value) {
            request.setAttachment(key, value);
        }
    };
}
Also used : ContextTransfer(com.pamirs.pradar.interceptor.ContextTransfer) Request(com.weibo.api.motan.rpc.Request)

Example 9 with ContextTransfer

use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.

the class ProducerSendInterceptor method getContextTransfer.

@Override
protected ContextTransfer getContextTransfer(Advice advice) {
    Object[] args = advice.getParameterArray();
    final ProducerRecord producerRecord = (ProducerRecord) args[0];
    if (PradarSwitcher.isKafkaMessageHeadersEnabled() && !isHeadReadOnly(producerRecord)) {
        return new ContextTransfer() {

            @Override
            public void transfer(String key, String value) {
                HeaderProcessor headerProcessor = HeaderProvider.getHeaderProcessor(producerRecord);
                headerProcessor.setHeader(producerRecord, key, value);
            }
        };
    }
    return null;
}
Also used : ContextTransfer(com.pamirs.pradar.interceptor.ContextTransfer) HeaderProcessor(com.pamirs.attach.plugin.apache.kafka.header.HeaderProcessor) ProducerRecord(org.apache.kafka.clients.producer.ProducerRecord)

Example 10 with ContextTransfer

use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.

the class ClientInterceptor method getContextTransfer.

@Override
protected ContextTransfer getContextTransfer(Advice advice) {
    Object[] args = advice.getParameterArray();
    if (!(args[0] instanceof ClientRequest)) {
        return null;
    }
    final ClientRequest clientRequest = (ClientRequest) args[0];
    final MultivaluedMap<String, Object> headers = clientRequest.getHeaders();
    return new ContextTransfer() {

        @Override
        public void transfer(String key, String value) {
            headers.put(key, Collections.<Object>singletonList(value));
        }
    };
}
Also used : ContextTransfer(com.pamirs.pradar.interceptor.ContextTransfer) ClientRequest(org.glassfish.jersey.client.ClientRequest)

Aggregations

ContextTransfer (com.pamirs.pradar.interceptor.ContextTransfer)11 JSONObject (com.alibaba.fastjson.JSONObject)2 HttpHeaders (com.google.api.client.http.HttpHeaders)1 HttpRequest (com.google.api.client.http.HttpRequest)1 HeaderProcessor (com.pamirs.attach.plugin.apache.kafka.header.HeaderProcessor)1 InvokeContext (com.pamirs.pradar.InvokeContext)1 Request (com.weibo.api.motan.rpc.Request)1 Metadata (io.grpc.Metadata)1 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)1 HttpMessage (io.netty.handler.codec.http.HttpMessage)1 HttpURLConnection (java.net.HttpURLConnection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 MimeHeaders (javax.xml.soap.MimeHeaders)1 Call (org.apache.axis.client.Call)1 HttpMethod (org.apache.commons.httpclient.HttpMethod)1 Message (org.apache.cxf.message.Message)1 ClassicHttpRequest (org.apache.hc.core5.http.ClassicHttpRequest)1 HttpHost (org.apache.hc.core5.http.HttpHost)1