@Override public void setSecurityContext(SecurityContext context) { ResteasyContext.pushContext(SecurityContext.class, context); }
private void popProvidersContext(Providers current) { ResteasyContext.popContextData(Providers.class); if (current != null) ResteasyContext.pushContext(Providers.class, current); }
private Providers pushProvidersContext() { Providers current = ResteasyContext.getContextData(Providers.class); ResteasyContext.pushContext(Providers.class, configuration); return current; }
protected CompletionStage<Object> invokeOnTargetDryRun(HttpRequest request, HttpResponse response, Object target) { ResteasyContext.pushContext(ResourceInfo.class, resourceInfo); // we don't pop so writer interceptors can get at this CompletionStage<Object> rtn = null; try { rtn = internalInvokeOnTarget(request, response, target); } catch (RuntimeException ex) { throw new ProcessingException(ex); } return rtn; }
@SuppressWarnings({"rawtypes", "unchecked"}) public static byte[] toByteArray(Object token, ResteasyProviderFactory factory) throws IOException { MessageBodyWriter writer = factory.getMessageBodyWriter(token.getClass(), null, null, MediaType.APPLICATION_JSON_TYPE); if (writer == null) throw new NullPointerException(Messages.MESSAGES.couldNotFindMessageBodyWriterForJSON()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Providers old = ResteasyContext.getContextData(Providers.class); ResteasyContext.pushContext(Providers.class, factory); try { writer.writeTo(token, token.getClass(), null, null, MediaType.APPLICATION_JSON_TYPE, new MultivaluedHashMap<String, Object>(), baos); return baos.toByteArray(); } finally { ResteasyContext.popContextData(Providers.class); if (old != null) ResteasyContext.pushContext(Providers.class, old); } }
public T handle(ResteasyRequestWrapper requestWrapper, HttpServletResponse httpServletResponse) throws Exception { T result = null; HttpResponse response = new HttpServletResponseWrapper(httpServletResponse, factory); HttpServletRequest servletRequest = requestWrapper.getHttpServletRequest(); try { ResteasyContext.pushContext(HttpServletRequest.class, servletRequest); ResteasyContext.pushContext(HttpServletResponse.class, httpServletResponse); ResteasyContext.pushContext(SecurityContext.class, new ServletSecurityContext(servletRequest)); result = handle(requestWrapper, response); } finally { ResteasyContext.clearContextData(); } return result; }
public static Application createApplication(String applicationClass, Dispatcher dispatcher, ResteasyProviderFactory providerFactory) { Class<?> clazz = null; try { clazz = Thread.currentThread().getContextClassLoader().loadClass(applicationClass); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } Application app = (Application)providerFactory.createProviderInstance(clazz); dispatcher.getDefaultContextObjects().put(Application.class, app); ResteasyContext.pushContext(Application.class, app); PropertyInjector propertyInjector = providerFactory.getInjectorFactory().createPropertyInjector(clazz, providerFactory); propertyInjector.inject(app, false); return app; }
public static <T> T fromBytes(Class<T> type, byte[] bytes, ResteasyProviderFactory factory) throws IOException { MessageBodyReader<T> reader = factory.getMessageBodyReader(type, type, null, MediaType.APPLICATION_JSON_TYPE); if (reader == null) throw new NullPointerException(Messages.MESSAGES.couldNotFindMessageBodyReaderForJSON()); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); Providers old = ResteasyContext.getContextData(Providers.class); ResteasyContext.pushContext(Providers.class, factory); try { return reader.readFrom(type, type, null, MediaType.APPLICATION_JSON_TYPE, new MultivaluedHashMap<String, String>(), bais); } finally { ResteasyContext.popContextData(Providers.class); if (old != null) ResteasyContext.pushContext(Providers.class, old); } } }
ResteasyContext.pushContext(SecurityContext.class, securityContext); chain.doFilter(exchange); return;
ResteasyContext.pushContext(SecurityContext.class, securityContext); ResteasyContext.pushContext(Context.class, context); ResteasyContext.pushContext(HttpServerRequest.class, req); ResteasyContext.pushContext(HttpServerResponse.class, resp); ResteasyContext.pushContext(Vertx.class, context.owner()); if (handleNotFound)
ResteasyContext.pushContext(Providers.class, providers); try if (old != null) ResteasyContext.pushContext(Providers.class, old);
ResteasyContext.pushContext(Providers.class, savedProviders);
public ParamConverter getParamConverter(Class clazz, Type genericType, Annotation[] annotations) { try { ResteasyContext.pushContext(ResteasyProviderFactory.class, this); // For MultiValuedParamConverterProvider for (SortedKey<ParamConverterProvider> provider : getSortedParamConverterProviders()) { ParamConverter converter = provider.getObj().getConverter(clazz, genericType, annotations); if (converter != null) return converter; } return null; } finally { ResteasyContext.popContextData(ResteasyProviderFactory.class); } }
ResteasyContext.pushContext(HttpServletRequest.class, request); ResteasyContext.pushContext(HttpServletResponse.class, response); ResteasyContext.pushContext(SecurityContext.class, new ServletSecurityContext(request)); if (handleNotFound)
ResteasyContext.pushContext(SecurityContext.class, securityContext); ResteasyContext.pushContext(ChannelHandlerContext.class, ctx); if (handleNotFound)
ResteasyContext.pushContext(SecurityContext.class, securityContext); ResteasyContext.pushContext(ChannelHandlerContext.class, ctx); if (handleNotFound)
@Override public void setSecurityContext(SecurityContext context) { ResteasyContext.pushContext(SecurityContext.class, context); }
ResteasyContext.pushContext(Providers.class, configuration); Object obj = null; try if (current != null) ResteasyContext.pushContext(Providers.class, current); if (obj instanceof ProvidersContextRetainer)
protected BuiltResponse invokeOnTarget(HttpRequest request, HttpResponse response, Object target) { final RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(request); final long timestamp = tracingLogger.timestamp("METHOD_INVOKE"); try { ResteasyContext.pushContext(ResourceInfo.class, resourceInfo); // we don't pop so writer interceptors can get at this PostMatchContainerRequestContext requestContext = new PostMatchContainerRequestContext(request, this, requestFilters, () -> invokeOnTargetAfterFilter(request, response, target)); // let it handle the continuation return requestContext.filter(); } finally { if (resource instanceof SingletonResource) { tracingLogger.logDuration("METHOD_INVOKE", timestamp, ((SingletonResource) resource).traceInfo(), method.getMethod()); } else { tracingLogger.logDuration("METHOD_INVOKE", timestamp, resource, method.getMethod()); } } }
ResteasyContext.pushContext(HttpExchange.class, httpExchange); ResteasyContext.pushContext(HttpContext.class, httpExchange.getHttpContext()); dispatcher.invoke(request, response); if (!response.isCommitted())