private <T> ClientRequest createClientRequest(String method,
Class<T> responseEntity,
Type responseEntityType,
Object requestEntity) {
ClientRequest request = new ClientRequestImpl();
request.setEntity(requestEntity);
URI requestURI = uriBuilder.build();
request.setURI(requestURI);
request.setMethod(method);
request.getHeaders().putAll(headers);
if (logger.isDebugEnabled()) {
Integer requestEntityInfo =
(requestEntity == null) ? null : System.identityHashCode(requestEntity);
logger.debug(Messages.getMessage("clientIssueRequest", new Object[] {method, //$NON-NLS-1$
requestURI, requestEntityInfo, headers.keySet()}));
}
if (headers.getFirst(HttpHeaders.USER_AGENT) == null) {
request.getHeaders().add(HttpHeaders.USER_AGENT, USER_AGENT);
}
request.getAttributes().putAll(attributes);
request.setAttribute(ProvidersRegistry.class, providersRegistry);
request.setAttribute(WinkConfiguration.class, config);
// for legacy, if third-party code is calling getAttribute with ClientConfig.class as key
request.setAttribute(ClientConfig.class, config);
request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_GENERIC_TYPE,
responseEntityType);
request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_CLASS_TYPE, responseEntity);
return request;
}