Java Code Examples for org.springframework.boot.web.servlet.ServletRegistrationBean#setLoadOnStartup()
The following examples show how to use
org.springframework.boot.web.servlet.ServletRegistrationBean#setLoadOnStartup() .
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: PluginConfig.java From flow-platform-x with Apache License 2.0 | 7 votes |
@Bean("gitServletBean") public ServletRegistrationBean<GitServlet> gitServletBean(Path pluginDir, PluginRepoResolver pluginRepoResolver) { GitServlet servlet = new GitServlet(); servlet.setRepositoryResolver(pluginRepoResolver); ServletRegistrationBean<GitServlet> bean = new ServletRegistrationBean<>(servlet, GIT_URL + "/*"); bean.setLoadOnStartup(1); bean.addInitParameter("base-path", pluginDir.toString()); bean.addInitParameter("export-all", "true"); bean.setAsyncSupported(true); return bean; }
Example 2
Source File: BaseRestApiConfiguration.java From flowable-engine with Apache License 2.0 | 7 votes |
protected ServletRegistrationBean registerServlet(FlowableServlet servletProperties, Class<?> baseConfig) { AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext(); dispatcherServletConfiguration.setParent(applicationContext); dispatcherServletConfiguration.register(baseConfig); DispatcherServlet servlet = new DispatcherServlet(dispatcherServletConfiguration); String path = servletProperties.getPath(); String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet, urlMapping); registrationBean.setName(servletProperties.getName()); registrationBean.setLoadOnStartup(servletProperties.getLoadOnStartup()); registrationBean.setAsyncSupported(true); if (multipartConfigElement != null) { registrationBean.setMultipartConfig(multipartConfigElement); } return registrationBean; }
Example 3
Source File: FacesServletAutoConfiguration.java From joinfaces with Apache License 2.0 | 6 votes |
/** * This bean registers the {@link FacesServlet}. * <p> * This {@link ServletRegistrationBean} also sets two * {@link ServletContext#setAttribute(String, Object) servlet-context attributes} to inform Mojarra and MyFaces about * the dynamically added Servlet. * * @param facesServletProperties The properties for the {@link FacesServlet}-registration. * * @return A custom {@link ServletRegistrationBean} which registers the {@link FacesServlet}. */ @Bean public ServletRegistrationBean<FacesServlet> facesServletRegistrationBean( FacesServletProperties facesServletProperties ) { ServletRegistrationBean<FacesServlet> facesServletServletRegistrationBean = new ServletRegistrationBean<FacesServlet>(new FacesServlet()) { @Override protected ServletRegistration.Dynamic addRegistration(String description, ServletContext servletContext) { ServletRegistration.Dynamic servletRegistration = super.addRegistration(description, servletContext); if (servletRegistration != null) { servletContext.setAttribute("org.apache.myfaces.DYNAMICALLY_ADDED_FACES_SERVLET", true); servletContext.setAttribute("com.sun.faces.facesInitializerMappingsAdded", true); } return servletRegistration; } }; facesServletServletRegistrationBean.setName(facesServletProperties.getName()); facesServletServletRegistrationBean.setUrlMappings(facesServletProperties.getUrlMappings()); facesServletServletRegistrationBean.setLoadOnStartup(facesServletProperties.getLoadOnStartup()); facesServletServletRegistrationBean.setEnabled(facesServletProperties.isEnabled()); facesServletServletRegistrationBean.setAsyncSupported(facesServletProperties.isAsyncSupported()); facesServletServletRegistrationBean.setOrder(facesServletProperties.getOrder()); return facesServletServletRegistrationBean; }
Example 4
Source File: ServletMappingAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 6 votes |
@Bean ServletRegistrationBean servletRegistrationBean(ServletMappingConfiguration config) { ServletRegistrationBean mapping = new ServletRegistrationBean(); mapping.setServlet(new CamelHttpTransportServlet()); mapping.addUrlMappings(config.getContextPath()); mapping.setName(config.getServletName()); mapping.setLoadOnStartup(1); return mapping; }
Example 5
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 6
Source File: HttpServerConfig.java From Spring-5.0-Cookbook with MIT License | 5 votes |
public ServletRegistrationBean routeServlet1(RouterFunction<?> routerFunction) throws Exception { HttpHandler httpHandler = RouterFunctions.toHttpHandler(routerFunction ); ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler); ServletRegistrationBean registrationBean = new ServletRegistrationBean<>(servlet, "/flux" + "/*"); registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); System.out.println("starts server"); return registrationBean; }
Example 7
Source File: KurentoRepositoryServerApp.java From kurento-java with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean repositoryServletRegistrationBean( RepositoryHttpServlet repositoryHttpServlet) { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(repositoryHttpServlet, "/repository_servlet/*"); servletRegistrationBean.setLoadOnStartup(1); return servletRegistrationBean; }
Example 8
Source File: HystrixConfiguration.java From springcloud-course with GNU General Public License v3.0 | 5 votes |
@Bean(name = "hystrixRegistrationBean") public ServletRegistrationBean servletRegistrationBean() { ServletRegistrationBean registration = new ServletRegistrationBean( new HystrixMetricsStreamServlet(), "/hystrix.stream"); registration.setName("hystrixServlet"); registration.setLoadOnStartup(1); return registration; }
Example 9
Source File: HttpServerConfig.java From Spring-5.0-Cookbook with MIT License | 5 votes |
public ServletRegistrationBean routeServlet1(RouterFunction<?> routerFunction) throws Exception { HttpHandler httpHandler = RouterFunctions.toHttpHandler(routerFunction ); ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler); ServletRegistrationBean registrationBean = new ServletRegistrationBean<>(servlet, "/flux" + "/*"); registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); System.out.println("starts server"); return registrationBean; }
Example 10
Source File: HttpServerConfig.java From Spring-5.0-Cookbook with MIT License | 5 votes |
public ServletRegistrationBean routeServlet1(RouterFunction<?> routerFunction) throws Exception { HttpHandler httpHandler = RouterFunctions.toHttpHandler(routerFunction ); ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler); ServletRegistrationBean registrationBean = new ServletRegistrationBean<>(servlet, "/flux" + "/*"); registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); System.out.println("starts server"); return registrationBean; }
Example 11
Source File: HttpServerConfig.java From Spring-5.0-Cookbook with MIT License | 5 votes |
public ServletRegistrationBean routeServlet1(RouterFunction<?> routerFunction) throws Exception { HttpHandler httpHandler = RouterFunctions.toHttpHandler(routerFunction ); ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler); ServletRegistrationBean registrationBean = new ServletRegistrationBean<>(servlet, "/flux" + "/*"); registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); System.out.println("starts server"); return registrationBean; }
Example 12
Source File: HystrixConfiguration.java From springcloud-course with GNU General Public License v3.0 | 5 votes |
@Bean(name = "hystrixForTurbineRegistrationBean") public ServletRegistrationBean servletTurbineRegistrationBean() { ServletRegistrationBean registration = new ServletRegistrationBean( new HystrixMetricsStreamServlet(), "/actuator/hystrix.stream"); registration.setName("hystrixForTurbineServlet"); registration.setLoadOnStartup(1); return registration; }
Example 13
Source File: ActivitiUIApplication.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean apiDispatcher() { DispatcherServlet api = new DispatcherServlet(); api.setContextClass(AnnotationConfigWebApplicationContext.class); api.setContextConfigLocation(ApiDispatcherServletConfiguration.class.getName()); ServletRegistrationBean registrationBean = new ServletRegistrationBean(); registrationBean.setServlet(api); registrationBean.addUrlMappings("/api/*"); // api下面的所有内容都访问到这里 registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); registrationBean.setName("api"); // 不能重复,重复则以最后一个设置的为准 return registrationBean; }
Example 14
Source File: HystrixApplication.java From blog with MIT License | 5 votes |
@Bean public ServletRegistrationBean getServlet() { HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; }
Example 15
Source File: HystrixConfiguration.java From springcloud-course with GNU General Public License v3.0 | 5 votes |
@Bean(name = "hystrixForTurbineRegistrationBean") public ServletRegistrationBean servletTurbineRegistrationBean() { ServletRegistrationBean registration = new ServletRegistrationBean( new HystrixMetricsStreamServlet(), "/actuator/hystrix.stream"); registration.setName("hystrixForTurbineServlet"); registration.setLoadOnStartup(1); return registration; }
Example 16
Source File: KittyConsumerApplication.java From kitty with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public ServletRegistrationBean getServlet() { HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; }
Example 17
Source File: HttpServerConfig.java From Spring-5.0-Cookbook with MIT License | 5 votes |
public ServletRegistrationBean routeServlet1(RouterFunction<?> routerFunction) throws Exception { HttpHandler httpHandler = RouterFunctions.toHttpHandler(routerFunction ); ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler); ServletRegistrationBean registrationBean = new ServletRegistrationBean<>(servlet, "/flux" + "/*"); registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); System.out.println("starts server"); return registrationBean; }
Example 18
Source File: HystrixDashboardConfiger.java From HIS with Apache License 2.0 | 5 votes |
/** * * 地址/hystrix */ @Bean public ServletRegistrationBean getServlet() { HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); //Spring boot 以代码的方式装载servlet registrationBean.setLoadOnStartup(1); //设置启动顺序 registrationBean.addUrlMappings("/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; }
Example 19
Source File: HystrixDashboardConfig.java From cloud-template with MIT License | 5 votes |
@Bean public ServletRegistrationBean getServlet() { HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet); registrationBean.setLoadOnStartup(1); registrationBean.addUrlMappings("/hystrix.stream"); registrationBean.setName("HystrixMetricsStreamServlet"); return registrationBean; }
Example 20
Source File: HystrixConfiguration.java From springcloud-course with GNU General Public License v3.0 | 5 votes |
@Bean(name = "hystrixRegistrationBean") public ServletRegistrationBean servletRegistrationBean() { ServletRegistrationBean registration = new ServletRegistrationBean( new HystrixMetricsStreamServlet(), "/hystrix.stream"); registration.setName("hystrixServlet"); registration.setLoadOnStartup(1); return registration; }