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

The following examples show how to use org.springframework.boot.web.servlet.ServletRegistrationBean#setOrder() . 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: WebRegistrationConfiguration.java    From EasyEE with MIT License 5 votes vote down vote up
/**
 * CKFinder Servlet
 * @return
 */
@Bean
public ServletRegistrationBean ckfinderConnectorServletRegistrationBean() {
	ServletRegistrationBean registrationBean = new ServletRegistrationBean();
	registrationBean.addInitParameter("XMLConfig", "/WEB-INF/ckfinder-config.xml");
	registrationBean.addInitParameter("debug", "false");
	registrationBean.setOrder(1);
	// Jars in "WEB-INF/lib/", please add to build path for development
	registrationBean.setServlet(new com.ckfinder.connector.ConnectorServlet());
	
	registrationBean.addUrlMappings("/staticresources/ckfinder/core/connector/java/connector.java");
	return registrationBean;
}
 
Example 3
Source File: WebRegistrationConfiguration.java    From EasyEE with MIT License 5 votes vote down vote up
/**
 * CKFinder Servlet
 * @return
 */
@Bean
public ServletRegistrationBean ckfinderConnectorServletRegistrationBean() {
	ServletRegistrationBean registrationBean = new ServletRegistrationBean();
	registrationBean.addInitParameter("XMLConfig", "/WEB-INF/ckfinder-config.xml");
	registrationBean.addInitParameter("debug", "false");
	registrationBean.setOrder(1);
	// Jars in "WEB-INF/lib/", please add to build path for development
	registrationBean.setServlet(new com.ckfinder.connector.ConnectorServlet());
	
	registrationBean.addUrlMappings("/staticresources/ckfinder/core/connector/java/connector.java");
	return registrationBean;
}
 
Example 4
Source File: SecurityFilterConfig.java    From cosmo with Apache License 2.0 5 votes vote down vote up
@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 5
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;
}