Package org.apache.wink.client

Examples of org.apache.wink.client.ClientRequest


    private ClientResponse invoke(String method,
                                  Class<?> responseEntity,
                                  Type responseEntityType,
                                  Object requestEntity) {
        ClientRequest request =
            createClientRequest(method, responseEntity, responseEntityType, requestEntity);
        HandlerContext context = createHandlerContext();
        try {
            ClientResponse response = context.doChain(request);
            if (ClientUtils.isErrorCode(response.getStatusCode())) {
View Full Code Here


    private <T> ClientRequest createClientRequest(String method,
                                                  Class<T> responseEntity,
                                                  Type responseEntityType,
                                                  Object requestEntity) {
        ClientRequest request = new ClientRequestImpl();
        request.setEntity(requestEntity);
        request.setURI(uriBuilder.build());
        request.setMethod(method);
        request.getHeaders().putAll(headers);
        if (headers.getFirst(HttpHeaders.ACCEPT) == null) {
            request.getHeaders().add(HttpHeaders.ACCEPT, MediaType.WILDCARD);
        }
        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(ClientConfig.class, config);
        request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_GENERIC_TYPE,
                                    responseEntityType);
        request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_CLASS_TYPE, responseEntity);
        return request;
    }
View Full Code Here

    private ClientResponse invoke(String method,
                                  Class<?> responseEntity,
                                  Type responseEntityType,
                                  Object requestEntity) {

        ClientRequest request =
            createClientRequest(method, responseEntity, responseEntityType, requestEntity);
        HandlerContext context = createHandlerContext();

        ProvidersRegistry providersRegistry = request.getAttribute(ProvidersRegistry.class);
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);

        try {
View Full Code Here

    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.isInfoEnabled()) {
            Class<?> requestEntityClass = (requestEntity == null) ? null : requestEntity.getClass();
            logger.info(Messages.getMessage("clientIssueRequest"), new Object[] {method,
                requestURI, requestEntityClass, headers});
        }
        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(ClientConfig.class, config);
        request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_GENERIC_TYPE,
                                    responseEntityType);
        request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_CLASS_TYPE, responseEntity);
        return request;
    }
View Full Code Here

    private ClientResponse invoke(String method,
                                  Class<?> responseEntity,
                                  Type responseEntityType,
                                  Object requestEntity) {

        ClientRequest request =
            createClientRequest(method, responseEntity, responseEntityType, requestEntity);
        HandlerContext context = createHandlerContext();

        ProvidersRegistry providersRegistry = request.getAttribute(ProvidersRegistry.class);
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);

        try {
View Full Code Here

    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(ClientConfig.class, config);
        request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_GENERIC_TYPE,
                                    responseEntityType);
        request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_CLASS_TYPE, responseEntity);
        return request;
    }
View Full Code Here

    private ClientResponse invoke(String method,
                                  Class<?> responseEntity,
                                  Type responseEntityType,
                                  Object requestEntity) {

        ClientRequest request =
            createClientRequest(method, responseEntity, responseEntityType, requestEntity);
        HandlerContext context = createHandlerContext();

        ProvidersRegistry providersRegistry = request.getAttribute(ProvidersRegistry.class);
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);

        try {
View Full Code Here

    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.isTraceEnabled()) {
            Integer requestEntityInfo =
                (requestEntity == null) ? null : System.identityHashCode(requestEntity);
            logger.trace(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);
        request.setAttribute(ClientConfig.class, config); // legacy
        request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_GENERIC_TYPE,
                                    responseEntityType);
        request.getAttributes().put(ClientRequestImpl.RESPONSE_ENTITY_CLASS_TYPE, responseEntity);
        return request;
    }
View Full Code Here

    private ClientResponse invoke(String method,
                                  Class<?> responseEntity,
                                  Type responseEntityType,
                                  Object requestEntity) {

        ClientRequest request =
            createClientRequest(method, responseEntity, responseEntityType, requestEntity);
        HandlerContext context = createHandlerContext();

        ProvidersRegistry providersRegistry = request.getAttribute(ProvidersRegistry.class);
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);

        try {
View Full Code Here

    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;
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.client.ClientRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.