Java Code Examples for org.springframework.boot.web.servlet.ServletRegistrationBean#setUrlMappings()

The following examples show how to use org.springframework.boot.web.servlet.ServletRegistrationBean#setUrlMappings() . 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: FacesServletAutoConfiguration.java    From joinfaces with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: WebServiceConfig.java    From freeacs with MIT License 5 votes vote down vote up
@Bean
public ServletRegistrationBean<Monitor> monitor() {
  ServletRegistrationBean<Monitor> srb = new ServletRegistrationBean<>();
  srb.setServlet(new Monitor());
  srb.setUrlMappings(Collections.singletonList("/ok"));
  return srb;
}
 
Example 3
Source File: DruidConfig.java    From blog with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Druidçš„servlet
 * 
 * @return
 */
@Bean
public ServletRegistrationBean statViewServlet() {
	ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet());
	Map<String, String> initParams = new HashMap<>();
	initParams.put("loginUsername", "root");
	initParams.put("loginPassword", "root");
	initParams.put("allow", "127.0.0.1");
	bean.setInitParameters(initParams);
	bean.setUrlMappings(Arrays.asList("/druid/*"));
	return bean;
}
 
Example 4
Source File: JavametricsCodewindSpringConfigurer.java    From javametrics with Apache License 2.0 5 votes vote down vote up
@Bean
ServletRegistrationBean JavametricsCodewindSpringServletRegistration () {
	ServletRegistrationBean srb = new ServletRegistrationBean();
	srb.setServlet(new WebPage());
	srb.setUrlMappings(Arrays.asList("/metrics/codewind"));
	return srb;
}