org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher Java Examples
The following examples show how to use
org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher.
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: EmbeddedKeycloakConfig.java From spring-security-oauth with MIT License | 6 votes |
@Bean ServletRegistrationBean<HttpServlet30Dispatcher> keycloakJaxRsApplication( KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception { mockJndiEnvironment(dataSource); EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties; ServletRegistrationBean<HttpServlet30Dispatcher> servlet = new ServletRegistrationBean<>( new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
Example #2
Source File: EmbeddedKeycloakConfig.java From spring-security-oauth with MIT License | 6 votes |
@Bean ServletRegistrationBean<HttpServlet30Dispatcher> keycloakJaxRsApplication(KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception { mockJndiEnvironment(dataSource); EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties; ServletRegistrationBean<HttpServlet30Dispatcher> servlet = new ServletRegistrationBean<>(new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
Example #3
Source File: EmbeddedKeycloakConfig.java From spring-security-oauth with MIT License | 6 votes |
@Bean ServletRegistrationBean<HttpServlet30Dispatcher> keycloakJaxRsApplication( KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception { mockJndiEnvironment(dataSource); EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties; ServletRegistrationBean<HttpServlet30Dispatcher> servlet = new ServletRegistrationBean<>( new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
Example #4
Source File: EmbeddedKeycloakConfig.java From spring-boot-keycloak-server-example with Apache License 2.0 | 6 votes |
@Bean ServletRegistrationBean<HttpServlet30Dispatcher> keycloakJaxRsApplication(SpringBootConfigProvider configProvider) { //FIXME: hack to propagate Spring Boot Properties to Keycloak Application EmbeddedKeycloakApplication.keycloakProperties = keycloakProperties; //FIXME: hack to propagate Spring Boot Properties to Keycloak Application EmbeddedKeycloakApplication.customProperties = customProperties; //FIXME: hack to propagate Spring Boot ConfigProvider to Keycloak Application EmbeddedKeycloakApplication.configProvider = configProvider; ServletRegistrationBean<HttpServlet30Dispatcher> servlet = new ServletRegistrationBean<>(new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); String keycloakContextPath = customProperties.getServer().getContextPath(); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakContextPath); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakContextPath + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
Example #5
Source File: ResteasyServletContextAttributeProvider.java From hammock with Apache License 2.0 | 5 votes |
@Produces public ServletDescriptor resteasyServlet() { String path = restServerConfiguration.getRestServerUri(); if( !(applicationInstance.isUnsatisfied() || applicationInstance.isAmbiguous())) { ApplicationPath appPath = ClassUtils.getAnnotation(applicationInstance.get().getClass(), ApplicationPath.class); if(appPath != null) { path = appPath.value(); } } String pattern = path.endsWith("/") ? path + "*" : path + "/*"; WebInitParam param = new WebParam("resteasy.servlet.mapping.prefix", path); return new ServletDescriptor("ResteasyServlet",new String[]{pattern}, new String[]{pattern}, 1,new WebInitParam[]{param},true,HttpServlet30Dispatcher.class); }
Example #6
Source File: JettyAppServer.java From keycloak with Apache License 2.0 | 5 votes |
private void addRestEasyServlet(WebArchive archive, WebAppContext webAppContext) { log.debug("Starting Resteasy deployment"); boolean addServlet = true; ServletHolder resteasyServlet = new ServletHolder("javax.ws.rs.core.Application", new HttpServlet30Dispatcher()); String jaxrsApplication = getJaxRsApplication(archive); Set<Class<?>> pathAnnotatedClasses = getPathAnnotatedClasses(archive); if (jaxrsApplication != null) { log.debug("App has an Application.class: " + jaxrsApplication); resteasyServlet.setInitParameter("javax.ws.rs.Application", jaxrsApplication); } else if (!pathAnnotatedClasses.isEmpty()) { log.debug("App has @Path annotated classes: " + pathAnnotatedClasses); ResteasyDeployment deployment = new ResteasyDeployment(); deployment.setApplication(new RestSamlApplicationConfig(pathAnnotatedClasses)); webAppContext.setAttribute(ResteasyDeployment.class.getName(), deployment); } else { log.debug("An application doesn't have Application.class, nor @Path annotated classes. Skipping Resteasy initialization."); addServlet = false; } if (addServlet) { // this should be /* in general. However Jetty 9.2 (this is bug specific to this version), // can not merge two instances of javax.ws.rs.Application together (one from web.xml // and the other one added here). In 9.1 and 9.4 this works fine. // Once we stop supporting 9.2, this should replaced with /* and this comment should be removed. webAppContext.addServlet(resteasyServlet, "/"); } log.debug("Finished Resteasy deployment"); }
Example #7
Source File: ResteasyServletProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@BuildStep public void build( Capabilities capabilities, Optional<ResteasyServerConfigBuildItem> resteasyServerConfig, BuildProducer<FeatureBuildItem> feature, BuildProducer<FilterBuildItem> filter, BuildProducer<ServletBuildItem> servlet, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<ServletInitParamBuildItem> servletInitParameters, Optional<ServletContextPathBuildItem> servletContextPathBuildItem, ResteasyInjectionReadyBuildItem resteasyInjectionReady) throws Exception { if (!capabilities.isPresent(Capability.SERVLET)) { return; } feature.produce(new FeatureBuildItem(Feature.RESTEASY)); if (resteasyServerConfig.isPresent()) { reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, ServletConfigSourceImpl.class, ServletContextConfigSourceImpl.class, FilterConfigSourceImpl.class)); String path = resteasyServerConfig.get().getPath(); //if JAX-RS is installed at the root location we use a filter, otherwise we use a Servlet and take over the whole mapped path if (path.equals("/") || path.isEmpty()) { filter.produce(FilterBuildItem.builder(JAX_RS_FILTER_NAME, ResteasyFilter.class.getName()).setLoadOnStartup(1) .addFilterServletNameMapping("default", DispatcherType.REQUEST) .addFilterServletNameMapping("default", DispatcherType.FORWARD) .addFilterServletNameMapping("default", DispatcherType.INCLUDE).setAsyncSupported(true) .build()); reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, ResteasyFilter.class.getName())); } else { String mappingPath = getMappingPath(path); servlet.produce(ServletBuildItem.builder(JAX_RS_SERVLET_NAME, HttpServlet30Dispatcher.class.getName()) .setLoadOnStartup(1).addMapping(mappingPath).setAsyncSupported(true).build()); reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, HttpServlet30Dispatcher.class.getName())); } for (Entry<String, String> initParameter : resteasyServerConfig.get().getInitParameters().entrySet()) { servletInitParameters .produce(new ServletInitParamBuildItem(initParameter.getKey(), initParameter.getValue())); } } }