@GET @Timed public Response getUris(@Context UriInfo uriInfo, @Context ResourceContext rc) { URI fibonacciNosURI = uriInfo.getBaseUriBuilder().path(FibonacciResource.class).build(); Object fibonacciNosResponse = rc.getResource(FibonacciResource.class).getFibNos(Optional.of(100L)).getEntity(); return Response.created(fibonacciNosURI).entity(fibonacciNosResponse).build(); }
@GET @Produces(MediaType.APPLICATION_JSON) @Path("/swagger") @ApiOperation(value = "The swagger definition in JSON", hidden = true) public Response getListingJsonBare( @Context Application app, @Context ServletConfig sc, @Context HttpHeaders headers, @Context UriInfo uriInfo, @Context ResourceContext rc) { ApiListingResource apiListingResource = rc.getResource(ApiListingResource.class); return apiListingResource.getListingJson(app, sc, headers, uriInfo); }
/** * Create a {@code TemplateModelProcessor} instance. * * @param resourceContext (injected) resource context. * @param extendedUriInfoProvider (injected) extended uri info provider. */ @Inject TemplateModelProcessor(final ResourceContext resourceContext, final Provider<ConfiguredValidator> validatorProvider, final Provider<ExtendedUriInfo> extendedUriInfoProvider) { this.resourceContext = resourceContext; this.validatorProvider = validatorProvider; this.extendedUriInfoProvider = extendedUriInfoProvider; }
public static Object findThreadLocal(final Class<?> type) { if (Request.class.equals(type)) { return REQUEST; } else if (UriInfo.class.equals(type)) { return URI_INFO; } else if (HttpHeaders.class.equals(type)) { return HTTP_HEADERS; } else if (SecurityContext.class.equals(type)) { return SECURITY_CONTEXT; } else if (ContextResolver.class.equals(type)) { return CONTEXT_RESOLVER; } else if (Providers.class.equals(type)) { return PROVIDERS; } else if (ServletRequest.class.equals(type)) { return SERVLET_REQUEST; } else if (HttpServletRequest.class.equals(type)) { return HTTP_SERVLET_REQUEST; } else if (HttpServletResponse.class.equals(type)) { return HTTP_SERVLET_RESPONSE; } else if (ServletConfig.class.equals(type)) { return SERVLET_CONFIG; } else if (ServletContext.class.equals(type)) { return SERVLET_CONTEXT; } else if (ResourceInfo.class.equals(type)) { return RESOURCE_INFO; } else if (ResourceContext.class.equals(type)) { return RESOURCE_CONTEXT; } else if (Application.class.equals(type)) { return APPLICATION; } else if (Configuration.class.equals(type)) { return CONFIGURATION; } return null; }
@GET @Path("/{cartId:[0-9]*}") public Customer getById(@Context ResourceContext rc) { //Customer customer = new Customer(cartId); //return customer; return rc.getResource(Customer.class); }
@Override @SuppressWarnings("unchecked") public T getContext(final Class<?> c) { final MinijaxRequestContext context = MinijaxRequestContext.getThreadLocal(); // 9.2.1 if (c == Application.class) { return (T) context.getApplication(); } // 9.2.2 if (c == UriInfo.class) { return (T) context.getUriInfo(); } // 9.2.3 if (c == HttpHeaders.class) { return (T) context.getHttpHeaders(); } // 9.2.4 if (c == Request.class) { return null; } // 9.2.5 if (c == SecurityContext.class) { return (T) context.getSecurityContext(); } // 9.2.6 if (c == Providers.class) { return (T) context.getApplication().getProviders(); } // 9.2.7 if (c == ResourceContext.class) { return null; } // 9.2.8 if (c == Configuration.class) { return (T) context.getApplication().getConfiguration(); } // 10.1 if (c == ServletConfig.class) { return null; } // 10.1 if (c == ServletContext.class) { return (T) context.getServletRequest().getServletContext(); } // 10.1 if (c == HttpServletRequest.class) { return (T) context.getServletRequest(); } // 10.1 if (c == HttpServletResponse.class) { return (T) context.getServletResponse(); } throw new IllegalArgumentException("Unrecognized @Context parameter: " + c); }
@GET @Path("/resourcecontext") public static String getResourceContext(@Context final ResourceContext resourceContext) { return "ok"; }
@Inject public ValidationConfigurationContextResolver(ResourceContext resourceContext) { this.resourceContext = resourceContext; }
public Object method() { ResourceContext rc = null; if ("".equals("")) return rc.getResource(AnotherSubResource.class); return rc.getResource(SubResource.class); }
public SubResource method() { ResourceContext rc = null; return rc.getResource(SubResource.class); }
public Object method() { ResourceContext rc = null; final Object resource = rc.getResource(SubResource.class); return resource; }
public Object method() { ResourceContext rc = null; return rc.getResource(SubResource.class); }
@Provides @RequestScoped public ResourceContext providesResourceContext() { return filter.getResourceContext(); }
@Provides @RequestScoped public ResourceContext getResourceContext() { return ResteasyProviderFactory.getContextData(ResourceContext.class); }
private void contextCDIIntegration(final WebBeansContext wbc) { if (!enabled) { return; } final BeanManagerImpl beanManagerImpl = wbc.getBeanManagerImpl(); if (!beanManagerImpl.getAdditionalQualifiers().contains(Context.class)) { beanManagerImpl.addAdditionalQualifier(Context.class); } if (!hasBean(beanManagerImpl, SecurityContext.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(SecurityContext.class, ThreadLocalContextManager.SECURITY_CONTEXT)); } if (!hasBean(beanManagerImpl, UriInfo.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(UriInfo.class, ThreadLocalContextManager.URI_INFO)); } if (!hasBean(beanManagerImpl, HttpServletResponse.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(HttpServletResponse.class, ThreadLocalContextManager.HTTP_SERVLET_RESPONSE)); } if (!hasBean(beanManagerImpl, HttpHeaders.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(HttpHeaders.class, ThreadLocalContextManager.HTTP_HEADERS)); } if (!hasBean(beanManagerImpl, Request.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(Request.class, ThreadLocalContextManager.REQUEST)); } if (!hasBean(beanManagerImpl, ServletConfig.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(ServletConfig.class, ThreadLocalContextManager.SERVLET_CONFIG)); } if (!hasBean(beanManagerImpl, Providers.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(Providers.class, ThreadLocalContextManager.PROVIDERS)); } if (!hasBean(beanManagerImpl, ContextResolver.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(ContextResolver.class, ThreadLocalContextManager.CONTEXT_RESOLVER)); } if (!hasBean(beanManagerImpl, ResourceInfo.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(ResourceInfo.class, ThreadLocalContextManager.RESOURCE_INFO)); } if (!hasBean(beanManagerImpl, ResourceContext.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(ResourceContext.class, ThreadLocalContextManager.RESOURCE_CONTEXT)); } if (!hasBean(beanManagerImpl, HttpServletRequest.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(HttpServletRequest.class, ThreadLocalContextManager.HTTP_SERVLET_REQUEST)); } if (!hasBean(beanManagerImpl, ServletRequest.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(ServletRequest.class, ThreadLocalContextManager.SERVLET_REQUEST)); } if (!hasBean(beanManagerImpl, ServletContext.class)) { beanManagerImpl.addInternalBean(new ContextBean<>(ServletContext.class, ThreadLocalContextManager.SERVLET_CONTEXT)); } beanManagerImpl.getInjectionResolver().clearCaches(); // hasBean() usage can have cached several things }
protected ThreadLocalResourceContext() { super(ResourceContext.class); }