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);
}
};
}
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);
}
};
}
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);
}
};
}
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;
}
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));
}
};
}
Aggregations