Java Code Examples for org.apache.catalina.LifecycleEvent#getSource()

The following examples show how to use org.apache.catalina.LifecycleEvent#getSource() . 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: StoreConfigLifecycleListener.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Register StoreRegistry after Start the complete Server.
 *
 * @see org.apache.catalina.LifecycleListener#lifecycleEvent(org.apache.catalina.LifecycleEvent)
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {
    if (Lifecycle.AFTER_START_EVENT.equals(event.getType())) {
        if (event.getSource() instanceof Server) {
            createMBean((Server) event.getSource());
        } else {
            log.warn(sm.getString("storeConfigListener.notServer"));
        }
    } else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
        if (oname != null) {
            registry.unregisterComponent(oname);
            oname = null;
        }
    }
 }
 
Example 2
Source File: TomcatBpmPlatformBootstrap.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void deployBpmPlatform(LifecycleEvent event) {

    final StandardServer server = (StandardServer) event.getSource();

    containerDelegate.getServiceContainer().createDeploymentOperation("deploy BPM platform")
      .addAttachment(TomcatAttachments.SERVER, server)
      .addStep(new TomcatParseBpmPlatformXmlStep())
      .addStep(new DiscoverBpmPlatformPluginsStep())
      .addStep(new StartManagedThreadPoolStep())
      .addStep(new StartJobExecutorStep())
      .addStep(new PlatformXmlStartProcessEnginesStep())
      .execute();

    LOG.camundaBpmPlatformSuccessfullyStarted(server.getServerInfo());

  }
 
Example 3
Source File: ContextConfig.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.AFTER_DESTROY_EVENT.equals(event.getType())) {
        Host host = (Host) event.getSource();
        hostWebXmlCache.remove(host);
    }
}
 
Example 4
Source File: StandardHost.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void lifecycleEvent(LifecycleEvent event) {
    if (event.getType().equals(Lifecycle.AFTER_START_EVENT)) {
        if (event.getSource() instanceof Context) {
            Context context = ((Context) event.getSource());
            childClassLoaders.put(context.getLoader().getClassLoader(),
                    context.getServletContext().getContextPath());
        }
    }
}
 
Example 5
Source File: StandardHost.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public void lifecycleEvent(LifecycleEvent event) {
    if (event.getType().equals(Lifecycle.AFTER_START_EVENT)) {
        if (event.getSource() instanceof Context) {
            Context context = ((Context) event.getSource());
            childClassLoaders.put(context.getLoader().getClassLoader(),
                    context.getServletContext().getContextPath());
        }
    }
}
 
Example 6
Source File: TomcatJavaJndiBinder.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void lifecycleEvent(final LifecycleEvent event) {
    final Object source = event.getSource();
    if (source instanceof StandardContext) {
        final StandardContext context = (StandardContext) source;
        if (Lifecycle.CONFIGURE_START_EVENT.equals(event.getType())) {
            TomcatJndiBuilder.mergeJava(context);
        }
    }
}
 
Example 7
Source File: OpenEJBListener.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void lifecycleEvent(final LifecycleEvent event) {
    // only install once
    if (listenerInstalled || !Lifecycle.AFTER_INIT_EVENT.equals(event.getType())) {
        return;
    }

    try {
        File webappDir = findOpenEjbWar();
        if (webappDir == null && event.getSource() instanceof StandardServer) {
            final StandardServer server = (StandardServer) event.getSource();
            webappDir = tryToFindAndExtractWar(server);
            if (webappDir != null) { // we are using webapp startup
                final File exploded = extractDirectory(webappDir);
                if (exploded != null) {
                    extract(webappDir, exploded);
                }
                webappDir = exploded;
                TomcatHelper.setServer(server);
            }
        }
        if (webappDir != null) {
            LOGGER.log(Level.INFO, "found the tomee webapp on {0}", webappDir.getPath());
            final Properties properties = new Properties();
            properties.setProperty("tomee.war", webappDir.getAbsolutePath());
            properties.setProperty("openejb.embedder.source", OpenEJBListener.class.getSimpleName());
            TomcatEmbedder.embed(properties, StandardServer.class.getClassLoader());
            listenerInstalled = true;
        } else if (logWebappNotFound) {
            LOGGER.info("tomee webapp not found from the listener, will try from the webapp if exists");
            logWebappNotFound = false;
        }
    } catch (final Exception e) {
        LOGGER.log(Level.SEVERE, "TomEE Listener can't start OpenEJB", e);
        // e.printStackTrace(System.err);
    }
}
 
Example 8
Source File: TomcatBpmPlatformBootstrap.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void undeployBpmPlatform(LifecycleEvent event) {

    final StandardServer server = (StandardServer) event.getSource();

    containerDelegate.getServiceContainer().createUndeploymentOperation("undeploy BPM platform")
      .addAttachment(TomcatAttachments.SERVER, server)
      .addStep(new StopJobExecutorStep())
      .addStep(new StopManagedThreadPoolStep())
      .addStep(new StopProcessApplicationsStep())
      .addStep(new StopProcessEnginesStep())
      .addStep(new UnregisterBpmPlatformPluginsStep())
      .execute();

    LOG.camundaBpmPlatformStopped(server.getServerInfo());
  }