@POST public void reload(@Context Reloader r, @Context ResourceConfig rc, @Context ServerContext sc) { ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader(); try { ClassLoader apiClassLoader = sc.getCommonClassLoader(); Thread.currentThread().setContextClassLoader(apiClassLoader); rc.getClasses().add(org.glassfish.admin.rest.resources.StaticResource.class); r.reload(); } finally { Thread.currentThread().setContextClassLoader(originalContextClassLoader); } }
@Test public void testEnableFor() { ResourceConfig rc = new ResourceConfig(); HttpMethodOverrideFilter.enableFor(rc, HttpMethodOverrideFilter.Source.HEADER); assertTrue(rc.getClasses().contains(HttpMethodOverrideFilter.class)); assertEquals( 1, ((HttpMethodOverrideFilter.Source[]) rc.getProperty(ServerProperties.HTTP_METHOD_OVERRIDE)) .length); assertEquals( HttpMethodOverrideFilter.Source.HEADER, ((HttpMethodOverrideFilter.Source[]) rc.getProperty(ServerProperties.HTTP_METHOD_OVERRIDE)) [0]); }
@Override public Map<String, Object> getAttributes() { final ResourceConfig resourceConfig; if (!applicationInstance.isUnsatisfied() && !applicationInstance.isAmbiguous()) { resourceConfig = ResourceConfig.forApplication(applicationInstance.get()); } else { resourceConfig = new ResourceConfig(); } if (resourceConfig.getClasses().isEmpty()) { resourceConfig .registerClasses(jerseyCdiExtension.getProviders()) .registerClasses(jerseyCdiExtension.getResources()); } final String attributeName = RESOURCE_CONFIG + SERVLET_NAME; return singletonMap(attributeName, resourceConfig); }