org.glassfish.jersey.servlet.ServletProperties Java Examples
The following examples show how to use
org.glassfish.jersey.servlet.ServletProperties.
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: KsqlRestApplication.java From ksql-fork-with-deep-learning-function with Apache License 2.0 | 6 votes |
@Override public void configureBaseApplication(Configurable<?> config, Map<String, String> metricTags) { // Would call this but it registers additional, unwanted exception mappers // super.configureBaseApplication(config, metricTags); // Instead, just copy+paste the desired parts from Application.configureBaseApplication() here: JacksonMessageBodyProvider jsonProvider = new JacksonMessageBodyProvider(getJsonMapper()); config.register(jsonProvider); config.register(JsonParseExceptionMapper.class); // Don't want to buffer rows when streaming JSON in a request to the query resource config.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 0); if (isUiEnabled) { loadUiWar(); config.property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/(static/.*|.*html)"); } }
Example #2
Source File: NiFiRegistryResourceConfig.java From nifi-registry with Apache License 2.0 | 6 votes |
public NiFiRegistryResourceConfig(@Context ServletContext servletContext) { // register filters register(HttpMethodOverrideFilter.class); // register the exception mappers & jackson object mapper resolver packages("org.apache.nifi.registry.web.mapper"); // register endpoints register(AccessPolicyResource.class); register(AccessResource.class); register(BucketResource.class); register(BucketFlowResource.class); register(BucketBundleResource.class); register(BundleResource.class); register(ExtensionResource.class); register(ExtensionRepoResource.class); register(FlowResource.class); register(ItemResource.class); register(TenantResource.class); register(ConfigResource.class); // register multipart feature register(MultiPartFeature.class); // include bean validation errors in response property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); // this is necessary for the /access/token/kerberos endpoint to work correctly // when sending 401 Unauthorized with a WWW-Authenticate: Negotiate header. // if this value needs to be changed, kerberos authentication needs to move to filter chain // so it can directly set the HttpServletResponse instead of indirectly through a JAX-RS Response property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true); // configure jersey to ignore resource paths for actuator and swagger-ui property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/(actuator|swagger/).*"); }
Example #3
Source File: ApplicationGroupTest.java From rest-utils with Apache License 2.0 | 6 votes |
@Test public void testStaticResourceIsolation() throws Exception { TestApp app1 = new TestApp("/app1"); TestApp app2 = new TestApp("/app2") { @Override public void setupResources(final Configurable<?> config, final TestRestConfig appConfig) { config.register(RestResource.class); config.property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/(index\\.html|)"); } @Override protected ResourceCollection getStaticResources() { return new ResourceCollection(Resource.newClassPathResource("static")); } }; server.registerApplication(app1); server.registerApplication(app2); server.start(); assertThat(makeGetRequest("/app1/index.html"), is(Code.NOT_FOUND)); assertThat(makeGetRequest("/app2/index.html"), is(Code.OK)); }
Example #4
Source File: DisconnectedSSOManager.java From datacollector with Apache License 2.0 | 6 votes |
public void registerResources(ServletContextHandler handler) { ServletHolder jerseyServlet = new ServletHolder(ServletContainer.class); jerseyServlet.setInitParameter(ServerProperties.PROVIDER_PACKAGES, getClass().getPackage().getName()); jerseyServlet.setInitParameter( ServletProperties.JAXRS_APPLICATION_CLASS, DisconnectedResourceConfig.class.getName() ); handler.addServlet(jerseyServlet, SECURITY_RESOURCES); AuthenticationResourceHandler authenticationResourceHandler = new AuthenticationResourceHandler(getAuthentication(), false); handler.setAttribute(DISCONNECTED_SSO_AUTHENTICATION_HANDLER_ATTR, authenticationResourceHandler); handler.setAttribute(DISCONNECTED_SSO_SERVICE_ATTR, getSsoService()); ServletHolder login = new ServletHolder(new DisconnectedLoginServlet((DisconnectedSSOService) getSsoService())); handler.addServlet(login, DisconnectedLoginServlet.URL_PATH); ServletHolder logout = new ServletHolder(new DisconnectedLogoutServlet((DisconnectedSSOService) getSsoService())); handler.addServlet(logout, DisconnectedLogoutServlet.URL_PATH); }
Example #5
Source File: WebServerModule.java From datacollector with Apache License 2.0 | 6 votes |
@Provides(type = Type.SET) ContextConfigurator provideJersey() { return new ContextConfigurator() { @Override public void init(ServletContextHandler context) { // REST API that requires authentication ServletHolder protectedRest = new ServletHolder(new ServletContainer()); protectedRest.setInitParameter( ServerProperties.PROVIDER_PACKAGES, SWAGGER_PACKAGE + "," + RestAPI.class.getPackage().getName() ); protectedRest.setInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, RestAPIResourceConfig.class.getName()); context.addServlet(protectedRest, "/rest/*"); RJson.configureRJsonForSwagger(Json.mapper()); // REST API that it does not require authentication ServletHolder publicRest = new ServletHolder(new ServletContainer()); publicRest.setInitParameter(ServerProperties.PROVIDER_PACKAGES, PublicRestAPI.class.getPackage().getName()); publicRest.setInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, RestAPIResourceConfig.class.getName()); context.addServlet(publicRest, "/public-rest/*"); } }; }
Example #6
Source File: Jersey2Plugin.java From seed with Mozilla Public License 2.0 | 6 votes |
private Map<String, Object> buildJerseyProperties(RestConfig restConfig) { Map<String, Object> jerseyProperties = new HashMap<>(); // Default configuration values jerseyProperties.put(ServletProperties.FILTER_FORWARD_ON_404, true); jerseyProperties.put(ServerProperties.WADL_FEATURE_DISABLE, true); // User-defined configuration values jerseyProperties.putAll(restConfig.getJerseyProperties()); // Forced configuration values jerseyProperties.put(ServletProperties.FILTER_CONTEXT_PATH, restConfig.getPath()); if (isJspFeaturePresent()) { jerseyProperties.put(JspMvcFeature.TEMPLATE_BASE_PATH, restConfig.getJspPath()); } return jerseyProperties; }
Example #7
Source File: MotdApplication.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
public MotdApplication() { // scan com.gluonhq package for jax-rs classes packages(true, "com.gluonhq"); // everything inside /webjars should not be handled by the jax-rs application property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/webjars/.*"); // use freemarker for web templating register(FreemarkerMvcFeature.class); property(FreemarkerMvcFeature.TEMPLATE_BASE_PATH, "freemarker"); }
Example #8
Source File: DiscoveryServerMain.java From Ratel with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean jerseyServlet() throws ServletException { ServletContainer servlet = new ServletContainer(); ServletRegistrationBean registration = new ServletRegistrationBean(servlet, "/server/*"); registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JerseyConfig.class.getName()); return registration; }
Example #9
Source File: JerseyConfig.java From difido-reports with Apache License 2.0 | 5 votes |
private void registerEndpoints() { if (!Configuration.INSTANCE.readBoolean(ConfigProps.ARCHIVER_ENABLED)){ register(ExecutionResource.class); register(MachineResource.class); register(TestDetailsResource.class); } register(ReportsResource.class); register(PluginResource.class); register(SettingsResource.class); // This is important if we want the server to serve also static content property(ServletProperties.FILTER_FORWARD_ON_404, true); }
Example #10
Source File: NoAuthPrincipalEntityTest.java From dropwizard-java8 with Apache License 2.0 | 5 votes |
@Override protected DeploymentContext configureDeployment() { forceSet(TestProperties.CONTAINER_PORT, "0"); return ServletDeploymentContext .builder(new NoAuthPrincipalInjectedResourceConfig()) .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, NoAuthPrincipalInjectedResourceConfig.class.getName()) .build(); }
Example #11
Source File: AuthBaseTest.java From dropwizard-java8 with Apache License 2.0 | 5 votes |
@Override protected DeploymentContext configureDeployment() { forceSet(TestProperties.CONTAINER_PORT, "0"); return ServletDeploymentContext.builder(getDropwizardResourceConfig()) .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, getDropwizardResourceConfigClass().getName()) .build(); }
Example #12
Source File: Jersey2Plugin.java From seed with Mozilla Public License 2.0 | 5 votes |
private Map<String, String> buildInitParams(Map<String, Object> jerseyProperties) { Map<String, String> initParams = new HashMap<>(); // Those properties must be defined as init parameters of the filter if (jerseyProperties.containsKey(ServletProperties.FILTER_CONTEXT_PATH)) { initParams.put(ServletProperties.FILTER_CONTEXT_PATH, (String) jerseyProperties.get(ServletProperties.FILTER_CONTEXT_PATH)); } if (jerseyProperties.containsKey(ServletProperties.FILTER_STATIC_CONTENT_REGEX)) { initParams.put(ServletProperties.FILTER_STATIC_CONTENT_REGEX, (String) jerseyProperties.get(ServletProperties.FILTER_STATIC_CONTENT_REGEX)); } return initParams; }
Example #13
Source File: ApplicationInitializer.java From boot-makeover with Apache License 2.0 | 4 votes |
@Bean public ServletRegistrationBean jerseyServlet() { ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/v1.0/**"); registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JerseyConfig.class.getName()); return registration; }
Example #14
Source File: JerseyConfig.java From Qualitis with Apache License 2.0 | 4 votes |
public JerseyConfig() { register(RequestContextFilter.class); register(MultiPartFeature.class); packages(RESOURCE_PACKAGE_NAME); property(ServletProperties.FILTER_FORWARD_ON_404, true); }
Example #15
Source File: Application.java From boot-examples with Apache License 2.0 | 4 votes |
@Bean public ServletRegistrationBean jerseyServlet() { ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/*"); registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JaxRsApplication.class.getName()); return registration; }
Example #16
Source File: StaticResourcesTest.java From rest-utils with Apache License 2.0 | 4 votes |
@Override public void setupResources(Configurable<?> config, TestRestConfig appConfig) { this.resourceConfig = config; config.register(DynamicResource.class); config.property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/(index\\.html|)"); }
Example #17
Source File: HelloWorldApplication.java From rest-utils with Apache License 2.0 | 4 votes |
@Override public void setupResources(Configurable<?> config, HelloWorldRestConfig appConfig) { config.register(new HelloWorldResource(appConfig)); config.property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/(static/.*|.*\\.html|)"); }
Example #18
Source File: App.java From enunciate-sample with Apache License 2.0 | 4 votes |
public App() { packages(App.class.getPackage().getName(), "com.webcohesion.enunciate.rt"); register(JacksonJsonProvider.class); property(ServletProperties.FILTER_FORWARD_ON_404, true); }
Example #19
Source File: WebServerRunner.java From greenbeans with Apache License 2.0 | 4 votes |
private static void addJerseyServlet(ServletContextHandler contextHandler) { ServletHolder jerseyServletHolder = new ServletHolder(new ServletContainer()); jerseyServletHolder.setInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, Application.class.getCanonicalName()); contextHandler.addServlet(jerseyServletHolder, "/api/*"); }
Example #20
Source File: LogSearchServletConfig.java From ambari-logsearch with Apache License 2.0 | 4 votes |
@Bean public ServletRegistrationBean jerseyServlet() { ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/api/v1/*"); registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, LogSearchJerseyResourceConfig.class.getName()); return registration; }
Example #21
Source File: LogSearchJerseyResourceConfig.java From ambari-logsearch with Apache License 2.0 | 4 votes |
public LogSearchJerseyResourceConfig() { packages(ServiceLogsResource.class.getPackage().getName()); register(JacksonJaxbJsonProvider.class); property(ServletProperties.FILTER_FORWARD_ON_404, true); }