org.springframework.boot.web.servlet.ServletRegistrationBean Java Examples
The following examples show how to use
org.springframework.boot.web.servlet.ServletRegistrationBean.
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: DruidMonitorConfigurer.java From FlyCms with MIT License | 6 votes |
/** * 注册ServletRegistrationBean * @return */ @Bean public ServletRegistrationBean registrationBean() { ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); /** 初始化参数配置,initParams**/ //白名单 bean.addInitParameter("allow", "127.0.0.1");//多个ip逗号隔开 //IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page. //bean.addInitParameter("deny", "192.168.1.110"); //登录查看信息的账号密码. bean.addInitParameter("loginUsername", "admin"); bean.addInitParameter("loginPassword", "flyCms2018"); //是否能够重置数据. bean.addInitParameter("resetEnable", "false"); return bean; }
Example #3
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 #4
Source File: DruidServletConfiguration.java From druid-spring-boot with Apache License 2.0 | 6 votes |
/** * Druid 提供了一个 StatViewServlet 用于展示 Druid 的统计信息 * 这个 StatViewServlet 的用途包括: * 1. 提供监控信息展示的 HTML 页面 * 2. 提供监控信息的 JSON API */ @Bean public ServletRegistrationBean druidStatViewServlet(DruidDataSourceProperties druidProperties) { log.debug("druid stat-view-servlet init..."); DruidStatViewServletProperties properties = druidProperties.getStatViewServlet(); ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet()); registration.addUrlMappings(properties.getUrlMappings()); if (!StringUtils.isEmpty(properties.getLoginUsername())) { registration.addInitParameter("loginUsername", properties.getLoginUsername()); } if (!StringUtils.isEmpty(properties.getLoginPassword())) { registration.addInitParameter("loginPassword", properties.getLoginPassword()); } if (!StringUtils.isEmpty(properties.getAllow())) { registration.addInitParameter("allow", properties.getAllow()); } if (!StringUtils.isEmpty(properties.getDeny())) { registration.addInitParameter("deny", properties.getDeny()); } registration.addInitParameter("resetEnable", Boolean.toString(properties.isResetEnable())); return registration; }
Example #5
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 #6
Source File: DruidConfiguration.java From youkefu with Apache License 2.0 | 6 votes |
/** * 注册一个StatViewServlet * @return */ @Bean public ServletRegistrationBean DruidStatViewServle2(){ //org.springframework.boot.context.embedded.ServletRegistrationBean提供类的进行注册. ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(),"/druid/*"); //添加初始化参数:initParams //白名单: // servletRegistrationBean.addInitParameter("allow","127.0.0.1"); //IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page. // servletRegistrationBean.addInitParameter("deny","192.168.1.73"); //登录查看信息的账号密码. servletRegistrationBean.addInitParameter("loginUsername","admin"); servletRegistrationBean.addInitParameter("loginPassword","123456"); //是否能够重置数据. servletRegistrationBean.addInitParameter("resetEnable","false"); return servletRegistrationBean; }
Example #7
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 #8
Source File: DuridConfig.java From MicroCommunity with Apache License 2.0 | 6 votes |
/** * servlet注册 * @return ServletRegistrationBean */ @Bean public ServletRegistrationBean statViewServlet() { //创建servlet注册实体 ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); //设置ip白名单 servletRegistrationBean.addInitParameter("allow", "127.0.0.1"); //设置ip黑名单,如果allow与deny共同存在时,deny优先于allow //servletRegistrationBean.addInitParameter("deny","192.168.0.19"); //设置控制台管理用户 servletRegistrationBean.addInitParameter("loginUsername", "admin"); servletRegistrationBean.addInitParameter("loginPassword", "123456"); //是否可以重置数据 servletRegistrationBean.addInitParameter("resetEnable", "false"); return servletRegistrationBean; }
Example #9
Source File: MonitorAutoconfiguration.java From saluki with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean registration(HystrixMetricsStreamServlet servlet) { ServletRegistrationBean registrationBean = new ServletRegistrationBean(); registrationBean.setServlet(servlet); registrationBean.setEnabled(true); registrationBean.addUrlMappings("/hystrix.stream"); return registrationBean; }
Example #10
Source File: HystrixConfig.java From spring-cloud-learning with MIT License | 5 votes |
@Bean @SuppressWarnings("unchecked") 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 #11
Source File: AsyncVaadinServletConfiguration.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Override protected void addInitParameters(final ServletRegistrationBean servletRegistrationBean) { super.addInitParameters(servletRegistrationBean); servletRegistrationBean.addInitParameter(ApplicationConfig.JSR356_MAPPING_PATH, "/UI"); servletRegistrationBean.addInitParameter(ApplicationConfig.ATMOSPHERE_INTERCEPTORS, SpringSecurityAtmosphereInterceptor.class.getName()); }
Example #12
Source File: SecurityFilterConfig.java From cosmo with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean<?> davServlet() { HttpRequestHandlerServlet handler = new HttpRequestHandlerServlet() { @Override public String getServletName() { return DAV_SERVLET_NAME; } }; ServletRegistrationBean<?> bean = new ServletRegistrationBean<>(handler, PATH_DAV); bean.setName(handler.getServletName()); bean.setOrder(0); return bean; }
Example #13
Source File: WebServiceConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { MessageDispatcherServlet servlet = new MessageDispatcherServlet(); servlet.setApplicationContext(applicationContext); servlet.setTransformWsdlLocations(true); return new ServletRegistrationBean(servlet, "/ws/*"); }
Example #14
Source File: MockApplication.java From AuTe-Framework with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean wiremockAdminHandlerBean() { ServletRegistrationBean bean = new ServletRegistrationBean(new WireMockHandlerDispatchingServlet(), "/__admin/*"); bean.addInitParameter("RequestHandlerClass", AdminRequestHandler.class.getName()); bean.setLoadOnStartup(1); bean.setName("wiremockAdmin"); return bean; }
Example #15
Source File: DruidAutoConfig.java From springboot-seed with MIT License | 5 votes |
@Bean public ServletRegistrationBean DruidStatViewServle2() { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*"); //白名单: servletRegistrationBean.addInitParameter("allow", properties.getAllow()); //登录查看信息的账号密码. servletRegistrationBean.addInitParameter("loginUsername", properties.getUsername()); servletRegistrationBean.addInitParameter("loginPassword", properties.getPassword()); return servletRegistrationBean; }
Example #16
Source File: FunctionalSpringBootApplication.java From tutorials with MIT License | 5 votes |
@Bean public ServletRegistrationBean servletRegistrationBean() throws Exception { HttpHandler httpHandler = WebHttpHandlerBuilder.webHandler((WebHandler) toHttpHandler(routingFunction())) .filter(new IndexRewriteFilter()) .build(); ServletRegistrationBean registrationBean = new ServletRegistrationBean<>(new RootServlet(httpHandler), "/"); registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); return registrationBean; }
Example #17
Source File: WebServiceConfig.java From spring-ws with MIT License | 5 votes |
@Bean public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { MessageDispatcherServlet servlet = new MessageDispatcherServlet(); servlet.setApplicationContext(applicationContext); return new ServletRegistrationBean(servlet, "/codenotfound/ws/*"); }
Example #18
Source File: DruidDataSourceConfig.java From easyweb with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean druidServlet() { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(); servletRegistrationBean.setServlet(new StatViewServlet()); servletRegistrationBean.addUrlMappings("/druid/*"); Map<String, String> initParameters = new HashMap<String, String>(); // initParameters.put("loginUsername", "druid");// 用户名 // initParameters.put("loginPassword", "druid");// 密码 initParameters.put("resetEnable", "false");// 禁用HTML页面上的“Reset All”功能 initParameters.put("allow", "127.0.0.1"); // IP白名单 (没有配置或者为空,则允许所有访问) // initParameters.put("deny", "192.168.20.38");// IP黑名单 // (存在共同时,deny优先于allow) servletRegistrationBean.setInitParameters(initParameters); return servletRegistrationBean; }
Example #19
Source File: EcssentDatabaseConfig.java From maintain with MIT License | 5 votes |
@Bean public ServletRegistrationBean druidServlet() { ServletRegistrationBean reg = new ServletRegistrationBean(); reg.setServlet(new StatViewServlet()); reg.addUrlMappings("/druid/*"); // reg.addInitParameter("allow", "127.0.0.1"); // reg.addInitParameter("deny",""); reg.addInitParameter("loginUsername", "admin"); reg.addInitParameter("loginPassword", "admin"); return reg; }
Example #20
Source File: SecurityDemo01Application.java From blog-sample with Apache License 2.0 | 5 votes |
/** * 注入验证码servlet */ @Bean public ServletRegistrationBean indexServletRegistration() { ServletRegistrationBean registration = new ServletRegistrationBean(new VerifyServlet()); registration.addUrlMappings(SecurityConstants.VALIDATE_CODE_PIC_URL); return registration; }
Example #21
Source File: WebServiceConfig.java From cloud-native-microservice-strangler-example with GNU General Public License v3.0 | 5 votes |
@Bean public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { MessageDispatcherServlet servlet = new MessageDispatcherServlet(); servlet.setApplicationContext(applicationContext); servlet.setTransformWsdlLocations(true); return new ServletRegistrationBean(servlet, "/v1/customers/*"); }
Example #22
Source File: WebSocketConfig.java From WebIDE-Backend with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Bean // for socket.io public ServletRegistrationBean servletRegistrationBean() { ServletRegistrationBean bean = new ServletRegistrationBean(new AtmosphereServlet(), "/coding-ide-tty1/*"); bean.addInitParameter("socketio-transport", "websocket"); bean.addInitParameter("socketio-timeout", "25000"); bean.addInitParameter("socketio-heartbeat", "15000"); bean.addInitParameter("socketio-suspendTime", "30000"); bean.addInitParameter("org.atmosphere.cpr.sessionSupport", "true"); bean.addInitParameter("SPACE_HOME", spaceHome); bean.setLoadOnStartup(100); bean.setAsyncSupported(true); return bean; }
Example #23
Source File: WebServiceConfig.java From springboot-learn with MIT License | 5 votes |
@Bean public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { MessageDispatcherServlet servlet = new MessageDispatcherServlet(); servlet.setApplicationContext(applicationContext); servlet.setTransformWsdlLocations(true); //配置对外服务根路径 return new ServletRegistrationBean(servlet, "/ws/*"); }
Example #24
Source File: FacesServletAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 5 votes |
@Test public void testDefaultMapping() { this.webApplicationContextRunner .run(context -> { ServletRegistrationBean<FacesServlet> facesServletRegistrationBean = (ServletRegistrationBean<FacesServlet>) context.getBean("facesServletRegistrationBean"); assertThat(facesServletRegistrationBean.getUrlMappings()).containsExactlyInAnyOrder("/faces/*", "*.jsf", "*.faces", "*.xhtml"); }); }
Example #25
Source File: ProxyConfiguration.java From cymbal with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty(name = "proxy.grafana.enable", havingValue = "true") public ServletRegistrationBean grafanaProxyServletRegistration() { ServletRegistrationBean registrationBean = new ServletRegistrationBean(new URITemplateProxyServlet(), "/grafana/*"); registrationBean.setName("grafana"); registrationBean.setInitParameters(proxyProperties.getGrafana()); return registrationBean; }
Example #26
Source File: GenericTestProxyContainer.java From odo with Apache License 2.0 | 5 votes |
@Bean public ServletRegistrationBean dispatcherRegistration() { ServletRegistrationBean registration = new ServletRegistrationBean(new Proxy()); registration.addUrlMappings("/*"); return registration; }
Example #27
Source File: AbsDwrConfig.java From jeesupport with MIT License | 5 votes |
@SuppressWarnings( "unchecked" ) @Bean @DependsOn( "commonConfig" ) public ServletRegistrationBean servletRegistrationBean() { String dwr_url = CommonConfig.getString("jees.webs.dwr.url", "/dwr" ); DwrSpringServlet servlet = new DwrSpringServlet(); ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet, dwr_url + "/*"); registrationBean.addInitParameter("debug", CommonConfig.getString("jees.webs.dwr.debug", "false" )); return registrationBean; }
Example #28
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 #29
Source File: FacesServletAutoConfigurationTest.java From joinfaces with Apache License 2.0 | 5 votes |
@Test public void testDisableFacesservletToXhtmlCustomMapping() { this.webApplicationContextRunner .withPropertyValues("joinfaces.jsf.disable-facesservlet-to-xhtml=true", "joinfaces.faces-servlet.url-mappings=*.xhtml") .run(context -> { ServletRegistrationBean<FacesServlet> facesServletRegistrationBean = (ServletRegistrationBean<FacesServlet>) context.getBean("facesServletRegistrationBean"); assertThat(facesServletRegistrationBean.getUrlMappings()).containsExactly("*.xhtml"); }); }
Example #30
Source File: RepositoryMongoTest.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; }