Web implementation of the Gourmet Recipe Manager
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

78 lines
2.5 KiB

package com.mousetech.gourmetj;
import javax.faces.application.ViewExpiredException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.primefaces.application.resource.PrimeResourceHandler;
import org.primefaces.renderkit.HeadRenderer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
@SpringBootApplication
@EntityScan(value = {
"com.mousetech.gourmetj.persistence.model" })
public class SpringPrimeFacesApplication {
private static final String IMAGE_IIO_PROVIDER_CONTEXT_LISTENER =
"com.twelvemonkeys.servlet.image.IIOProviderContextListener";
final String errorPage = "/error/error.html";
final String error404Page = "/error/error404.html";
final String expiredPage = "/error/viewExpired.xhtml";
public static void main(String[] args) {
SpringApplication.run(SpringPrimeFacesApplication.class,
args);
}
@Bean
public ServletContextInitializer initializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext)
throws ServletException {
/* Note that we cannot set theme here since it was
* already set earlier. Default value is "aristo".
*/
// servletContext.setInitParameter(
// "primefaces.THEME", "bluesky");
servletContext.setInitParameter(
"javax.faces.FACELETS_SKIP_COMMENTS",
"true");
servletContext.setInitParameter(
"com.sun.faces.expressionFactory",
"com.sun.el.ExpressionFactoryImpl");
servletContext.setInitParameter(
"primefaces.UPLOADER", "native");
servletContext.addListener(IMAGE_IIO_PROVIDER_CONTEXT_LISTENER);
}
};
}
@Bean
public ErrorPageRegistrar errorPageRegistrar() {
return new ErrorPageRegistrar() {
@Override
public void registerErrorPages(
ErrorPageRegistry registry) {
registry.addErrorPages(new ErrorPage(
HttpStatus.NOT_FOUND, error404Page));
registry.addErrorPages(new ErrorPage(
ViewExpiredException.class,
expiredPage));
registry.addErrorPages(new ErrorPage(
HttpStatus.INTERNAL_SERVER_ERROR,
errorPage));
}
};
}
}