Package org.apache.wink.common

Examples of org.apache.wink.common.RuntimeContext


        }
        if (ClientResponse.class.equals(type)) {
            return (T)this;
        }
        ProvidersRegistry providersRegistry = getAttribute(ProvidersRegistry.class);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContextTLS.setRuntimeContext(runtimeContext);
        try {
            String contentType = getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
            if (contentType == null || contentType.length() == 0) {
View Full Code Here


            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 {
            ClientResponse response = context.doChain(request);
            int statusCode = response.getStatusCode();
View Full Code Here

            return;
        }

        ProvidersRegistry providersRegistry = request.getAttribute(ProvidersRegistry.class);
        ClientRuntimeContext runtimeContext = new ClientRuntimeContext(providersRegistry);
        RuntimeContext saved = RuntimeContextTLS.getRuntimeContext();
        RuntimeContextTLS.setRuntimeContext(runtimeContext);
        try {
            Class<?> type = entity.getClass();
            Type genericType = type;
            if (entity instanceof GenericEntity) {
View Full Code Here

    public MediaType setDefaultCharsetOnMediaTypeHeader(MultivaluedMap<String, Object> httpHeaders,
                                                        MediaType mediaType) {
        logger.debug("setDefaultCharsetOnMediaTypeHeader({}, {}) entry", httpHeaders, mediaType); //$NON-NLS-1$

        RuntimeContext context = RuntimeContextTLS.getRuntimeContext();
        DeploymentConfiguration config = context.getAttribute(DeploymentConfiguration.class);
        if (config.isDefaultResponseCharset() || config.isUseAcceptCharset()) {
            if (httpHeaders != null && (httpHeaders.isEmpty() || httpHeaders
                    .get(HttpHeaders.CONTENT_TYPE) == null)) {
                // only correct the MediaType if the MediaType was not explicitly
                // set
                logger.debug("Media Type not explicitly set on Response so going to correct charset parameter if necessary"); //$NON-NLS-1$
                if (ProviderUtils.getCharsetOrNull(mediaType) == null) { //$NON-NLS-1$
                    try {
                        String charsetValue = "UTF-8";
                        if (config.isUseAcceptCharset()) {
                            // configuration says to inspect and use the Accept-Charset header to determine response charset
                            HttpHeaders requestHeaders = null;
                            if (context != null) {
                                requestHeaders = context.getHttpHeaders();
                            }
                            charsetValue = ProviderUtils.getCharset(mediaType, requestHeaders);
                        }
                        String newMediaTypeStr = mediaType.toString() + ";charset=" + charsetValue;
                        mediaType = MediaType.valueOf(newMediaTypeStr);
View Full Code Here

                                                         // AbstractJAXBProviderTest
                                                         // class
            event = reader.next();
            if (event == XMLStreamReader.DTD) {

                RuntimeContext runtimeContext = RuntimeContextTLS.getRuntimeContext();
                WinkConfiguration winkConfig = runtimeContext.getAttribute(WinkConfiguration.class);
                if (winkConfig != null) {
                    Properties props = winkConfig.getProperties();
                    if (props != null) {
                        // use valueOf method to require the word "true"
                        supportDTD =
View Full Code Here

                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException, WebApplicationException {
        RuntimeContext context = getRuntimeContext();
        // instantiate parameters of the asset method
        Object[] args =
            InjectableFactory.getInstance().instantiate(method.getFormalParameters(), context);
        try {
            // invoke the asset method to produce the object to write
View Full Code Here

                           Type genericType,
                           Annotation[] annotations,
                           MediaType mediaType,
                           MultivaluedMap<String, String> httpHeaders,
                           InputStream entityStream) throws IOException, WebApplicationException {
        RuntimeContext context = getRuntimeContext();
        // instantiate parameters of the asset method.
        // since the formal parameters contain an Entity parameter, it is
        // populated
        // during the call to the instantiate method. there is no need to
        // manually call
View Full Code Here

                                      new InvocationHandler() {
                                          public Object invoke(Object proxy,
                                                               Method method,
                                                               Object[] args) throws Throwable {
                                              // use runtimeContext from TLS
                                              RuntimeContext runtimeContext =
                                                  RuntimeContextTLS.getRuntimeContext();
                                              if (runtimeContext == null) {
                                                  if("toString".equals(method.getName()) && (args == null || args.length == 0)) {
                                                      return "Proxy for " + contextClass.getName();
                                                  }
                                                  throw new IllegalStateException();
                                              }
                                              // get the real context from the
                                              // RuntimeContext
                                              Object context =
                                                  runtimeContext.getAttribute(contextClass);
                                              // invoke the method on the real
                                              // context
                                              return method.invoke(context, args);
                                          }
                                      });
View Full Code Here

            }
            handleRequestWithoutFaultBarrier(request, response);
        } catch (Throwable t) {
            // exception was not handled properly
            ApplicationExceptionAttribute appEx = null;
            RuntimeContext runtimeContext = RuntimeContextTLS.getRuntimeContext();
            if (runtimeContext != null) {
                appEx = runtimeContext.getAttribute(ApplicationExceptionAttribute.class);
            }
            if (appEx != null && (appEx.getDebugMsg() != null)) {
                // This exception originated from an application class, such as a resource or provider
                // See unittest class DebugResourceThrowsExceptionTest.
                if (logger.isDebugEnabled()) {
View Full Code Here

            } catch (Exception e) {
                logger.trace("Caught exception when releasing resource object", e);
                throw e;
            }
        } catch (Throwable t) {
            RuntimeContext originalContext = RuntimeContextTLS.getRuntimeContext();
            ServerMessageContext msgContext = null;
            try {
                logException(t, request);
                msgContext = createMessageContext(request, response);
                RuntimeContextTLS.setRuntimeContext(msgContext);
View Full Code Here

TOP

Related Classes of org.apache.wink.common.RuntimeContext

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.