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

The following examples show how to use org.springframework.boot.web.servlet.ServletRegistrationBean#setEnabled() . 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: MonitorAutoconfiguration.java    From saluki with Apache License 2.0 5 votes vote down vote up
@Bean
public ServletRegistrationBean registration(HystrixMetricsStreamServlet servlet) {
    ServletRegistrationBean registrationBean = new ServletRegistrationBean();
    registrationBean.setServlet(servlet);
    registrationBean.setEnabled(true);
    registrationBean.addUrlMappings("/hystrix.stream");
    return registrationBean;
}
 
Example 3
Source File: DruidWebStatAutoConfiguration.java    From spring-boot-starter-dao with Apache License 2.0 5 votes vote down vote up
@Bean
ServletRegistrationBean servletRegistration(DruidStatProperties druidStatConfig) {
	ServletRegistrationBean filterRegistration = new ServletRegistrationBean(new StatViewServlet());
	filterRegistration.setAsyncSupported(true);
	filterRegistration.setEnabled(true);
	filterRegistration.addUrlMappings("/druid/*");
	filterRegistration.setInitParameters(druidStatParameters(druidStatConfig));
	return filterRegistration;
}
 
Example 4
Source File: ParaServer.java    From para with Apache License 2.0 5 votes vote down vote up
/**
 * @return API servlet bean
 */
@Bean
public ServletRegistrationBean<?> apiV1RegistrationBean() {
	String path = Api1.PATH + "*";
	ServletRegistrationBean<?> reg = new ServletRegistrationBean<>(new ServletContainer(new Api1()), path);
	logger.debug("Initializing Para API v1 [{}]...", path);
	reg.setName(Api1.class.getSimpleName());
	reg.setAsyncSupported(true);
	reg.setEnabled(true);
	reg.setOrder(3);
	return reg;
}