javax.ws.rs.ext.Providers Java Examples
The following examples show how to use
javax.ws.rs.ext.Providers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceUtilTest.java From minnal with Apache License 2.0 | 6 votes |
@Test public void shouldInvokeMethodWithArgumentsAndModel() throws Throwable { Map<String, Object> content = new HashMap<String, Object>(); content.put("value", "test123"); content.put("someNumber", 1L); Map<String, Object> values = new HashMap<String, Object>(); values.put("anotherModel", new DummyModel()); DummyModel model = new DummyModel(); byte[] bytes = new byte[10]; MediaType mediaType = mock(MediaType.class); HttpHeaders httpHeaders = mock(HttpHeaders.class); when(httpHeaders.getMediaType()).thenReturn(mediaType); MessageBodyReader reader = mock(MessageBodyReader.class); when(reader.readFrom(eq(Map.class), eq(Map.class), isNull(Annotation[].class), eq(mediaType), isNull(MultivaluedMap.class), any(InputStream.class))).thenReturn(content); Providers providers = mock(Providers.class); when(providers.getMessageBodyReader(Map.class, Map.class, null, mediaType)).thenReturn(reader); assertEquals(ResourceUtil.invokeAction(model, "dummyActionWithArgumentsAndModel", Lists.newArrayList(new ParameterMetaData("anotherModel", "anotherModel", DummyModel.class), new ParameterMetaData("value", "value", String.class), new ParameterMetaData("someNumber", "someNumber", Long.class)), bytes, providers, httpHeaders, values), "dummyActionWithArgumentsAndModel"); }
Example #2
Source File: DOM4JProviderTest.java From cxf with Apache License 2.0 | 6 votes |
private void doTestWriteXML(MediaType ct, boolean convert) throws Exception { org.dom4j.Document dom = readXML(ct, "<a/>"); final Message message = createMessage(false); Providers providers = new ProvidersImpl(message); DOM4JProvider p = new DOM4JProvider() { protected Message getCurrentMessage() { return message; } }; p.setProviders(providers); p.convertToDOMAlways(convert); ByteArrayOutputStream bos = new ByteArrayOutputStream(); p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class, new Annotation[]{}, ct, new MetadataMap<String, Object>(), bos); String str = bos.toString(); if (convert) { assertFalse(str.startsWith("<?xml")); } else { assertTrue(str.startsWith("<?xml")); } assertTrue(str.contains("<a/>") || str.contains("<a></a>")); }
Example #3
Source File: DOM4JProviderTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testWriteXMLSuppressDeclaration() throws Exception { org.dom4j.Document dom = readXML(MediaType.APPLICATION_XML_TYPE, "<a/>"); final Message message = createMessage(true); Providers providers = new ProvidersImpl(message); DOM4JProvider p = new DOM4JProvider() { protected Message getCurrentMessage() { return message; } }; p.setProviders(providers); ByteArrayOutputStream bos = new ByteArrayOutputStream(); p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class, new Annotation[]{}, MediaType.APPLICATION_XML_TYPE, new MetadataMap<String, Object>(), bos); String str = bos.toString(); assertFalse(str.startsWith("<?xml")); assertTrue(str.contains("<a/>") || str.contains("<a></a>")); }
Example #4
Source File: ResourceUtilTest.java From minnal with Apache License 2.0 | 6 votes |
@Test public void shouldGetContentAsList() throws Exception { List<String> list = Lists.newArrayList("test1", "test2", "test3"); byte[] bytes = new byte[10]; MediaType mediaType = mock(MediaType.class); HttpHeaders httpHeaders = mock(HttpHeaders.class); when(httpHeaders.getMediaType()).thenReturn(mediaType); MessageBodyReader reader = mock(MessageBodyReader.class); when(reader.readFrom(eq(String.class), eq(String.class), eq(new Annotation[]{}), eq(mediaType), isNull(MultivaluedMap.class), any(InputStream.class))).thenThrow(IOException.class); when(reader.readFrom(eq(List.class), any(Type.class), eq(new Annotation[]{}), eq(mediaType), isNull(MultivaluedMap.class), any(InputStream.class))).thenReturn(list); Providers providers = mock(Providers.class); when(providers.getMessageBodyReader(String.class, String.class, new Annotation[]{}, mediaType)).thenReturn(reader); when(providers.getMessageBodyReader(List.class, ResourceUtil.listType(String.class).getType(), new Annotation[]{}, mediaType)).thenReturn(reader); Object content = ResourceUtil.getContent(bytes, providers, httpHeaders, String.class); assertTrue(content instanceof List); assertEquals(content, list); }
Example #5
Source File: ResourceUtil.java From minnal with Apache License 2.0 | 6 votes |
/** * Returns the request content as the given type. IF the content is a collection, returns a list of elements of the given type * * @param request * @param type * @return */ public static Object getContent(byte[] raw, Providers providers, HttpHeaders httpHeaders, Class<?> type) { try { return getContent(new ByteArrayInputStream(raw), providers, httpHeaders, type, type, new Annotation[] {}); } catch (MinnalInstrumentationException e) { logger.trace("Failed while getting the content from the request stream", e); Throwable ex = e; while (ex.getCause() != null) { if (ex.getCause() instanceof IOException) { return getContent(new ByteArrayInputStream(raw), providers, httpHeaders, List.class, listType(type).getType(), new Annotation[]{}); } ex = ex.getCause(); } throw e; } }
Example #6
Source File: ResourceUtilTest.java From minnal with Apache License 2.0 | 6 votes |
@Test(expectedExceptions=MinnalInstrumentationException.class) public void shouldThrowExceptionIfMethodNotFound() throws Throwable { Map<String, Object> values = new HashMap<String, Object>(); DummyModel model = new DummyModel(); byte[] bytes = new byte[10]; MediaType mediaType = mock(MediaType.class); HttpHeaders httpHeaders = mock(HttpHeaders.class); when(httpHeaders.getMediaType()).thenReturn(mediaType); MessageBodyReader reader = mock(MessageBodyReader.class); when(reader.readFrom(eq(Map.class), eq(Map.class), isNull(Annotation[].class), eq(mediaType), isNull(MultivaluedMap.class), any(InputStream.class))).thenReturn(values); Providers providers = mock(Providers.class); when(providers.getMessageBodyReader(Map.class, Map.class, null, mediaType)).thenReturn(reader); ResourceUtil.invokeAction(model, "nonExistingMethod", Lists.newArrayList(new ParameterMetaData("anotherModel", "anotherModel", DummyModel.class)), bytes, providers, httpHeaders, values); }
Example #7
Source File: ContextParameterResolver.java From everrest with Eclipse Public License 2.0 | 6 votes |
@Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { Class<?> parameterClass = parameter.getParameterClass(); if (parameterClass == HttpHeaders.class) { return context.getHttpHeaders(); } else if (parameterClass == SecurityContext.class) { return context.getSecurityContext(); } else if (parameterClass == Request.class) { return context.getRequest(); } else if (parameterClass == UriInfo.class) { return context.getUriInfo(); } else if (parameterClass == Providers.class) { return context.getProviders(); } else if (parameterClass == Application.class) { return context.getApplication(); } else if (parameterClass == InitialProperties.class) { return context.getInitialProperties(); } return EnvironmentContext.getCurrent().get(parameter.getParameterClass()); }
Example #8
Source File: ResourceUtilTest.java From minnal with Apache License 2.0 | 6 votes |
@Test(expectedExceptions=IllegalStateException.class) public void shouldThrowExceptionIfMethodThrowsAnyException() throws Throwable { Map<String, Object> values = new HashMap<String, Object>(); DummyModel model = new DummyModel(); byte[] bytes = new byte[10]; MediaType mediaType = mock(MediaType.class); HttpHeaders httpHeaders = mock(HttpHeaders.class); when(httpHeaders.getMediaType()).thenReturn(mediaType); MessageBodyReader reader = mock(MessageBodyReader.class); when(reader.readFrom(eq(Map.class), eq(Map.class), isNull(Annotation[].class), eq(mediaType), isNull(MultivaluedMap.class), any(InputStream.class))).thenReturn(values); Providers providers = mock(Providers.class); when(providers.getMessageBodyReader(Map.class, Map.class, null, mediaType)).thenReturn(reader); ResourceUtil.invokeAction(model, "throwsException", new ArrayList<ParameterMetaData>(), bytes, providers, httpHeaders, values); }
Example #9
Source File: ProjectResource.java From component-runtime with Apache License 2.0 | 6 votes |
private ProjectModel readProjectModel(final String compressedModel, final Providers providers) { final MessageBodyReader<ProjectModel> jsonReader = providers .getMessageBodyReader(ProjectModel.class, ProjectModel.class, NO_ANNOTATION, APPLICATION_JSON_TYPE); final ProjectModel model; try (final InputStream gzipInputStream = new ByteArrayInputStream(debase64(compressedModel))) { model = jsonReader .readFrom(ProjectModel.class, ProjectModel.class, NO_ANNOTATION, APPLICATION_JSON_TYPE, new MultivaluedHashMap<>(), gzipInputStream); } catch (final IOException e) { throw new WebApplicationException(Response .status(Response.Status.INTERNAL_SERVER_ERROR) .entity(new ErrorMessage(e.getMessage())) .type(APPLICATION_JSON_TYPE) .build()); } return model; }
Example #10
Source File: Contexts.java From tomee with Apache License 2.0 | 6 votes |
private static Set<Class<?>> contextClasses() { final Set<Class<?>> classes = new HashSet<>(); classes.add(UriInfo.class); classes.add(SecurityContext.class); classes.add(HttpHeaders.class); classes.add(ContextResolver.class); classes.add(Providers.class); classes.add(Request.class); /* TODO: when we have jaxrs 2 classes.add(ResourceInfo.class); classes.add(ResourceContext.class); */ classes.add(Application.class); classes.add(HttpServletRequest.class); classes.add(HttpServletResponse.class); classes.add(ServletConfig.class); classes.add(ServletContext.class); classes.add(MessageContext.class); return classes; }
Example #11
Source File: ResourceUtilTest.java From minnal with Apache License 2.0 | 6 votes |
@Test public void shouldGetContentAsMap() throws Exception { Map<String, Object> map = new HashMap<String, Object>(); map.put("key1", "value1"); byte[] bytes = new byte[10]; MediaType mediaType = mock(MediaType.class); HttpHeaders httpHeaders = mock(HttpHeaders.class); when(httpHeaders.getMediaType()).thenReturn(mediaType); MessageBodyReader reader = mock(MessageBodyReader.class); when(reader.readFrom(eq(Map.class), eq(Map.class), eq(new Annotation[]{}), eq(mediaType), isNull(MultivaluedMap.class), any(InputStream.class))).thenReturn(map); Providers providers = mock(Providers.class); when(providers.getMessageBodyReader(Map.class, Map.class, new Annotation[]{}, mediaType)).thenReturn(reader); Object content = ResourceUtil.getContent(bytes, providers, httpHeaders, Map.class); assertTrue(content instanceof Map); assertEquals(content, map); }
Example #12
Source File: GuiceBindingsModule.java From dropwizard-guicey with MIT License | 6 votes |
@Override protected void configure() { jerseyToGuiceGlobal(MultivaluedParameterExtractorProvider.class); jerseyToGuiceGlobal(Application.class); jerseyToGuiceGlobal(Providers.class); // request scoped objects jerseyToGuice(UriInfo.class); jerseyToGuice(ResourceInfo.class); jerseyToGuice(HttpHeaders.class); jerseyToGuice(SecurityContext.class); jerseyToGuice(Request.class); jerseyToGuice(ContainerRequest.class); jerseyToGuice(AsyncContext.class); if (!guiceServletSupport) { // bind request and response objects when guice servlet module not registered // but this will work only for resources jerseyToGuice(HttpServletRequest.class); jerseyToGuice(HttpServletResponse.class); } }
Example #13
Source File: MethodParametersInjectionTest.java From everrest with Eclipse Public License 2.0 | 5 votes |
@Test public void injectsProviders() throws Exception { processor.addApplication(new Application() { @Override public Set<Object> getSingletons() { return newHashSet(new ContextParamResource()); } }); ContainerResponse response = launcher.service("POST", "/g/5", "", null, null, null); assertTrue(String.format("Expected %s injected", Providers.class), response.getEntity() instanceof Providers); }
Example #14
Source File: ProjectResource.java From component-runtime with Apache License 2.0 | 5 votes |
@POST @Path("openapi/zip/form") @Produces("application/zip") public Response createOpenAPIZip(@FormParam("project") final String compressedModel, @Context final Providers providers) { final ProjectModel model = readProjectModel(compressedModel, providers); final String filename = ofNullable(model.getArtifact()).orElse("zip") + ".zip"; return Response.ok().entity((StreamingOutput) out -> { generator.generateFromOpenAPI(toRequest(model), out); out.flush(); }).header("Content-Disposition", "inline; filename=" + filename).build(); }
Example #15
Source File: ProvidersUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static <T> T resolveFromContext(Providers providers, Class<T> clazz, MediaType mediaType, Class<?> type) { ContextResolver<T> contextResolver = providers.getContextResolver(clazz, mediaType); if (contextResolver == null) { throw new RestException("No context resolver found for class " + clazz.getName()); } return contextResolver.getContext(type); }
Example #16
Source File: MetricAppBeanOptional.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@GET @Path("/get-context-params") public String getContextParams( final @Context HttpHeaders httpheaders, final @Context Request request, final @Context UriInfo uriInfo, final @Context ResourceContext resourceContext, final @Context Providers providers, final @Context Application application, final @Context SecurityContext securityContext, final @Context Configuration configuration) throws Exception { return "This is a GET request with context parameters"; }
Example #17
Source File: DeploymentProcessor.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void process(Archive<?> archive, TestClass testClass) { JavaArchive extensionsJar = ShrinkWrap.create(JavaArchive.class,"mp-ot-mocktracer-resolver.jar") .addAsServiceProvider(TracerResolver.class, MockTracerResolver.class); extensionsJar.addAsServiceProvider(Providers.class, ExceptionMapper.class); extensionsJar.addClass(MockTracerResolver.class); extensionsJar.addClass(ExceptionMapper.class); extensionsJar.addPackages(true, "io.opentracing.tracerresolver", "io.opentracing.mock"); WebArchive war = WebArchive.class.cast(archive); war.addAsLibraries(extensionsJar); war.setWebXML("web.xml"); }
Example #18
Source File: SseEventBuilder.java From cxf with Apache License 2.0 | 5 votes |
InboundSseEventImpl(Providers providers, String name, String id, String comment, String data) { this.providers = providers; this.name = name; this.id = id; this.comment = comment; this.data = data; }
Example #19
Source File: ConstructorParametersInjectionTest.java From everrest with Eclipse Public License 2.0 | 5 votes |
@Test public void injectsProviders() throws Exception { processor.addApplication(new Application() { @Override public Set<Class<?>> getClasses() { return newHashSet(ProvidersResource.class); } }); ContainerResponse response = launcher.service("POST", "/j/1", "", null, null, null); assertTrue(String.format("Expected %s injected", Providers.class), response.getEntity() instanceof Providers); }
Example #20
Source File: SofaSynchronousDispatcher.java From sofa-rpc with Apache License 2.0 | 5 votes |
public SofaSynchronousDispatcher(ResteasyProviderFactory providerFactory) { super(providerFactory); this.providerFactory = providerFactory; this.registry = new SofaResourceMethodRegistry(providerFactory); // CHANGE defaultContextObjects.put(Providers.class, providerFactory); defaultContextObjects.put(Registry.class, registry); defaultContextObjects.put(Dispatcher.class, this); defaultContextObjects.put(InternalDispatcher.class, InternalDispatcher.getInstance()); }
Example #21
Source File: RestEasyRequestContext.java From jax-rs-pac4j with Apache License 2.0 | 5 votes |
public RestEasyRequestContext(Providers providers, HttpRequest request) { super(providers, new RequestPac4JSecurityContext(ResteasyProviderFactory.getContextData(SecurityContext.class)).context() // if we went through a pac4j security filter .map(sc -> sc.getContext().getRequestContext()) // if not, we create a new ContainerRequestContext .orElse(new PreMatchContainerRequestContext(request))); }
Example #22
Source File: AnnotatedFieldsInjectionTest.java From everrest with Eclipse Public License 2.0 | 5 votes |
@Test public void injectsProviders() throws Exception { processor.addApplication(new Application() { @Override public Set<Class<?>> getClasses() { return newHashSet(ProvidersResource.class); } }); ContainerResponse response = launcher.service("POST", "/j/1", "", null, null, null); assertTrue(String.format("Expected %s injected", Providers.class), response.getEntity() instanceof Providers); }
Example #23
Source File: ThreadLocalContextManager.java From tomee with Apache License 2.0 | 5 votes |
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; }
Example #24
Source File: JaxRsMetricsActivatingProcessor.java From smallrye-metrics with Apache License 2.0 | 5 votes |
@Override public void process(TestDeployment testDeployment, Archive<?> archive) { WebArchive war = (WebArchive) archive; String[] deps = { "io.smallrye:smallrye-config", "io.smallrye:smallrye-metrics", "io.smallrye:smallrye-metrics-testsuite-common", "org.eclipse.microprofile.metrics:microprofile-metrics-api", "org.eclipse.microprofile.config:microprofile-config-api" }; File[] dependencies = Maven.resolver().loadPomFromFile(new File("pom.xml")).resolve(deps).withTransitivity().asFile(); war.addAsLibraries(dependencies); war.addClass(MetricsHttpServlet.class); war.addClass(JaxRsMetricsFilter.class); war.addClass(JaxRsMetricsServletFilter.class); // change application context root to '/' because the TCK assumes that the metrics // will be available at '/metrics', and in our case the metrics servlet is located // within the application itself, we don't use WildFly's built-in support for metrics war.addAsWebInfResource("WEB-INF/jboss-web.xml", "jboss-web.xml"); // activate the servlet filter war.setWebXML("WEB-INF/web.xml"); // activate the JAX-RS request filter war.addAsServiceProvider(Providers.class.getName(), JaxRsMetricsFilter.class.getName()); // exclude built-in Metrics and Config from WildFly war.addAsManifestResource("META-INF/jboss-deployment-structure.xml", "jboss-deployment-structure.xml"); }
Example #25
Source File: Customer.java From cxf with Apache License 2.0 | 5 votes |
public void testParams(@Context UriInfo info, @Context HttpHeaders hs, @Context Request r, @Context SecurityContext s, @Context Providers workers, @HeaderParam("Foo") String h, @HeaderParam("Foo") List<String> l) { // complete }
Example #26
Source File: JAXRSUtilsTest.java From cxf with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void testHttpContextParameters() throws Exception { ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true); OperationResourceInfo ori = new OperationResourceInfo( Customer.class.getMethod("testParams", new Class[]{UriInfo.class, HttpHeaders.class, Request.class, SecurityContext.class, Providers.class, String.class, List.class}), cri); ori.setHttpMethod("GET"); MultivaluedMap<String, String> headers = new MetadataMap<>(); headers.add("Foo", "bar, baz"); Message m = createMessage(); m.put("org.apache.cxf.http.header.split", "true"); m.put(Message.PROTOCOL_HEADERS, headers); List<Object> params = JAXRSUtils.processParameters(ori, new MetadataMap<String, String>(), m); assertEquals("7 parameters expected", 7, params.size()); assertSame(UriInfoImpl.class, params.get(0).getClass()); assertSame(HttpHeadersImpl.class, params.get(1).getClass()); assertSame(RequestImpl.class, params.get(2).getClass()); assertSame(SecurityContextImpl.class, params.get(3).getClass()); assertSame(ProvidersImpl.class, params.get(4).getClass()); assertSame(String.class, params.get(5).getClass()); assertEquals("Wrong header param", "bar", params.get(5)); List<String> values = (List<String>)params.get(6); assertEquals("Wrong headers size", 2, values.size()); assertEquals("Wrong 1st header param", "bar", values.get(0)); assertEquals("Wrong 2nd header param", "baz", values.get(1)); }
Example #27
Source File: ResourceUtilTest.java From minnal with Apache License 2.0 | 5 votes |
@Test public void shouldInvokeMethodWithNoArguments() throws Throwable { Map<String, Object> values = new HashMap<String, Object>(); DummyModel model = new DummyModel(); byte[] bytes = new byte[10]; MediaType mediaType = mock(MediaType.class); HttpHeaders httpHeaders = mock(HttpHeaders.class); when(httpHeaders.getMediaType()).thenReturn(mediaType); MessageBodyReader reader = mock(MessageBodyReader.class); when(reader.readFrom(eq(Map.class), eq(Map.class), isNull(Annotation[].class), eq(mediaType), isNull(MultivaluedMap.class), any(InputStream.class))).thenReturn(values); Providers providers = mock(Providers.class); when(providers.getMessageBodyReader(Map.class, Map.class, null, mediaType)).thenReturn(reader); assertEquals(ResourceUtil.invokeAction(model, "dummyAction", new ArrayList<ParameterMetaData>(), bytes, providers, httpHeaders, values), "dummy"); }
Example #28
Source File: Attachment.java From cxf with Apache License 2.0 | 5 votes |
public Attachment(org.apache.cxf.message.Attachment a, Providers providers) { handler = a.getDataHandler(); for (Iterator<String> i = a.getHeaderNames(); i.hasNext();) { String name = i.next(); if ("Content-ID".equalsIgnoreCase(name)) { continue; } headers.add(name, a.getHeader(name)); } headers.putSingle("Content-ID", a.getId()); this.providers = providers; }
Example #29
Source File: CxfRSService.java From tomee with Apache License 2.0 | 4 votes |
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 }
Example #30
Source File: ConstructorParametersInjectionTest.java From everrest with Eclipse Public License 2.0 | 4 votes |
@Path("1") @POST public Providers m1() { return providers; }