Java Code Examples for org.apache.catalina.Server#addLifecycleListener()

The following examples show how to use org.apache.catalina.Server#addLifecycleListener() . 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: TomcatSetup.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public void accept(final Tomcat tomcat) {
    final Server server = tomcat.getServer();
    server.addLifecycleListener(event -> {
        if (Server.class.isInstance(event.getData()) && Lifecycle.AFTER_DESTROY_EVENT.equals(event.getType())
                && Boolean.getBoolean("talend.component.exit-on-destroy")) {
            System.exit(0);
        }
    });
    // if we want it to be really configurable we should add it in ComponentServerConfiguration
    // and set this instance in the standard context to be able to configure it from cdi side
    final boolean dev = Boolean.getBoolean("talend.component.server.tomcat.valve.error.debug");
    if (!dev) {
        Stream
                .of(server.findServices())
                .map(Service::getContainer)
                .flatMap(e -> Stream.of(e.findChildren()))
                .filter(StandardHost.class::isInstance)
                .map(StandardHost.class::cast)
                .forEach(host -> host.addLifecycleListener(event -> {
                    if (event.getType().equals(Lifecycle.BEFORE_START_EVENT)) {
                        StandardHost.class
                                .cast(host)
                                .setErrorReportValveClass(MinimalErrorReportValve.class.getName());
                    }
                }));
    }
}
 
Example 2
Source File: Runner.java    From myrrix-recommender with Apache License 2.0 5 votes vote down vote up
private static void configureServer(Server server) {
  //server.addLifecycleListener(new SecurityListener());
  //server.addLifecycleListener(new AprLifecycleListener());
  LifecycleListener jasperListener = new JasperListener();
  server.addLifecycleListener(jasperListener);
  jasperListener.lifecycleEvent(new LifecycleEvent(server, Lifecycle.BEFORE_INIT_EVENT, null));
  server.addLifecycleListener(new JreMemoryLeakPreventionListener());
  //server.addLifecycleListener(new GlobalResourcesLifecycleListener());
  server.addLifecycleListener(new ThreadLocalLeakPreventionListener());
}
 
Example 3
Source File: ServingLayer.java    From oryx with Apache License 2.0 4 votes vote down vote up
private static void configureServer(Server server) {
  server.addLifecycleListener(new JreMemoryLeakPreventionListener());
  server.addLifecycleListener(new ThreadLocalLeakPreventionListener());
}