Search in sources :

Example 1 with DefaultExceptionHandler

use of alfio.util.DefaultExceptionHandler in project alf.io by alfio-event.

the class SpringBootLauncher method main.

/**
 * Entry point for spring boot
 * @param args original arguments
 */
public static void main(String[] args) {
    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
    String profiles = System.getProperty("spring.profiles.active", "");
    SpringApplication application = new SpringApplication(SpringBootInitializer.class, BaseConfiguration.class, DataSourceConfiguration.class, WebSecurityConfig.class, MvcConfiguration.class);
    List<String> additionalProfiles = new ArrayList<>();
    additionalProfiles.add(Initializer.PROFILE_SPRING_BOOT);
    if ("true".equals(System.getenv("ALFIO_LOG_STDOUT_ONLY"))) {
        // -> will load application-stdout.properties on top to override the logger configuration
        additionalProfiles.add("stdout");
    }
    if ("true".equals(System.getenv("ALFIO_DEMO_ENABLED"))) {
        additionalProfiles.add(Initializer.PROFILE_DEMO);
    }
    application.setAdditionalProfiles(additionalProfiles.toArray(new String[0]));
    ConfigurableApplicationContext applicationContext = application.run(args);
    ConfigurableEnvironment environment = applicationContext.getEnvironment();
    log.info("profiles: requested {}, active {}", profiles, String.join(", ", environment.getActiveProfiles()));
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) SpringApplication(org.springframework.boot.SpringApplication) ArrayList(java.util.ArrayList) DefaultExceptionHandler(alfio.util.DefaultExceptionHandler)

Example 2 with DefaultExceptionHandler

use of alfio.util.DefaultExceptionHandler in project alf.io by alfio-event.

the class Initializer method onStartup.

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);
    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
    configureSessionCookie(servletContext);
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    Dynamic characterEncodingFilter = servletContext.addFilter("CharacterEncodingFilter", cef);
    characterEncodingFilter.setAsyncSupported(true);
    characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*");
    // force log initialization, then disable it
    XRLog.setLevel(XRLog.EXCEPTION, Level.WARNING);
    XRLog.setLoggingEnabled(false);
}
Also used : Dynamic(javax.servlet.FilterRegistration.Dynamic) CharacterEncodingFilter(org.springframework.web.filter.CharacterEncodingFilter) DefaultExceptionHandler(alfio.util.DefaultExceptionHandler)

Aggregations

DefaultExceptionHandler (alfio.util.DefaultExceptionHandler)2 ArrayList (java.util.ArrayList)1 Dynamic (javax.servlet.FilterRegistration.Dynamic)1 SpringApplication (org.springframework.boot.SpringApplication)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)1 CharacterEncodingFilter (org.springframework.web.filter.CharacterEncodingFilter)1