Java 类org.apache.catalina.LifecycleEvent 实例源码

项目:class-guard    文件:JasperListener.java   
/**
 * Primary entry point for startup and shutdown events.
 *
 * @param event The event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
        try {
            // Set JSP factory
            Class.forName("org.apache.jasper.compiler.JspRuntimeContext",
                          true,
                          this.getClass().getClassLoader());
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            // Should not occur, obviously
            log.warn("Couldn't initialize Jasper", t);
        }
        // Another possibility is to do directly:
        // JspFactory.setDefaultFactory(new JspFactoryImpl());
    }

}
项目:tomcat7    文件:Tomcat.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    try {
        Context context = (Context) event.getLifecycle();
        if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
            context.setConfigured(true);
        }
        // LoginConfig is required to process @ServletSecurity
        // annotations
        if (context.getLoginConfig() == null) {
            context.setLoginConfig(
                    new LoginConfig("NONE", null, null, null));
            context.getPipeline().addValve(new NonLoginAuthenticator());
        }
    } catch (ClassCastException e) {
        return;
    }
}
项目:tomcat7    文件:HostConfig.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
        // The context has stopped.
        Context context = (Context) event.getLifecycle();

        // Remove the old expanded WAR.
        ExpandWar.delete(toDelete);

        // Reset the docBase to trigger re-expansion of the WAR.
        context.setDocBase(newDocBase);

        // Remove this listener from the Context else it will run every
        // time the Context is stopped.
        context.removeLifecycleListener(this);
    }
}
项目:tomcat7    文件:EngineConfig.java   
/**
 * Process the START event for an associated Engine.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the engine we are associated with
    try {
        engine = (Engine) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:tomcat7    文件:UserConfig.java   
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:tomcat7    文件:JasperListener.java   
/**
 * Primary entry point for startup and shutdown events.
 *
 * @param event The event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
        try {
            // Set JSP factory
            Class.forName("org.apache.jasper.compiler.JspRuntimeContext",
                          true,
                          this.getClass().getClassLoader());
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            // Should not occur, obviously
            log.warn("Couldn't initialize Jasper", t);
        }
        // Another possibility is to do directly:
        // JspFactory.setDefaultFactory(new JspFactoryImpl());
    }

}
项目:lams    文件:EngineConfig.java   
/**
 * Process the START event for an associated Engine.
 *
 * @param event The lifecycle event that has occurred
 */
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the engine we are associated with
    try {
        engine = (Engine) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:lams    文件:UserConfig.java   
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:lams    文件:JasperListener.java   
/**
 * Primary entry point for startup and shutdown events.
 *
 * @param event The event that has occurred
 */
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.INIT_EVENT.equals(event.getType())) {
        try {
            // Set JSP factory
            Class.forName("org.apache.jasper.compiler.JspRuntimeContext",
                          true,
                          this.getClass().getClassLoader());
        } catch (Throwable t) {
            // Should not occur, obviously
            log.warn("Couldn't initialize Jasper", t);
        }
        // Another possibility is to do directly:
        // JspFactory.setDefaultFactory(new JspFactoryImpl());
    }

}
项目:jerrydog    文件:ContextConfig.java   
/**
 * Process the START event for an associated Context.
 *
 * @param event The lifecycle event that has occurred
 */
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the context we are associated with
    try {
        context = (Context) event.getLifecycle();
        if (context instanceof StandardContext) {
            int contextDebug = ((StandardContext) context).getDebug();
            if (contextDebug > this.debug)
                this.debug = contextDebug;
        }
    } catch (ClassCastException e) {
        log(sm.getString("contextConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:jerrydog    文件:EngineConfig.java   
/**
 * Process the START event for an associated Engine.
 *
 * @param event The lifecycle event that has occurred
 */
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the engine we are associated with
    try {
        engine = (Engine) event.getLifecycle();
        if (engine instanceof StandardEngine) {
            int engineDebug = ((StandardEngine) engine).getDebug();
            if (engineDebug > this.debug)
                this.debug = engineDebug;
        }
    } catch (ClassCastException e) {
        log(sm.getString("engineConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:jerrydog    文件:UserConfig.java   
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log(sm.getString("hostConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:apache-tomcat-7.0.73-with-comment    文件:Tomcat.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    try {
        Context context = (Context) event.getLifecycle();
        if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
            context.setConfigured(true);
        }
        // LoginConfig is required to process @ServletSecurity
        // annotations
        if (context.getLoginConfig() == null) {
            context.setLoginConfig(
                    new LoginConfig("NONE", null, null, null));
            context.getPipeline().addValve(new NonLoginAuthenticator());
        }
    } catch (ClassCastException e) {
        return;
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:EngineConfig.java   
/**
 * Process the START event for an associated Engine.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the engine we are associated with
    try {
        engine = (Engine) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:apache-tomcat-7.0.73-with-comment    文件:UserConfig.java   
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:apache-tomcat-7.0.73-with-comment    文件:JasperListener.java   
/**
 * Primary entry point for startup and shutdown events.
 *
 * @param event The event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
        try {
            // Set JSP factory
            Class.forName("org.apache.jasper.compiler.JspRuntimeContext",
                          true,
                          this.getClass().getClassLoader());
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            // Should not occur, obviously
            log.warn("Couldn't initialize Jasper", t);
        }
        // Another possibility is to do directly:
        // JspFactory.setDefaultFactory(new JspFactoryImpl());
    }

}
项目:alfresco-file-transfer-receiver    文件:Http11Connector.java   
public Http11Connector()
{
    super("HTTP/1.1");

    if (log.isDebugEnabled())
    {
        addLifecycleListener(new LifecycleListener()
        {
            public void lifecycleEvent(LifecycleEvent event)
            {
                if (log.isDebugEnabled())
                {
                    log.debug("event: " + event.getType());
                }
            }
        });
    }
}
项目:jwala    文件:JGroupsReportingLifeCycleListenerImplTest.java   
@Test
public void testLifecycleEvent() throws Exception {
    when(mockLifeCycle.getState()).thenReturn(LifecycleState.STOPPING);
    lifeCycleListener.lifecycleEvent(new LifecycleEvent(mockLifeCycle, null, null));
    sleep(2500);

    when(mockLifeCycle.getState()).thenReturn(LifecycleState.STOPPED);
    lifeCycleListener.lifecycleEvent(new LifecycleEvent(mockLifeCycle, null, null));
    sleep(2500);

    verify(mockAppender, atLeastOnce()).doAppend((LoggingEvent) captorLoggingEvent.capture());

    final int eventTotal = captorLoggingEvent.getAllValues().size();
    final LoggingEvent loggingEvent = (LoggingEvent) captorLoggingEvent.getAllValues().get(eventTotal - 1);
    assertEquals("Channel closed", loggingEvent.getMessage());
    System.out.println(captorLoggingEvent.getAllValues().size());

    // make sure that the scheduler has stopped by checking if there are extra events after the listener has processed
    // a STOPPED life cycle
    sleep(2500); // pause to let any rogue scheduler do logging if there are any...
    assertEquals(eventTotal, captorLoggingEvent.getAllValues().size());
}
项目:lazycat    文件:HostConfig.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
        // The context has stopped.
        Context context = (Context) event.getLifecycle();

        // Remove the old expanded WAR.
        ExpandWar.delete(toDelete);

        // Reset the docBase to trigger re-expansion of the WAR.
        context.setDocBase(newDocBase);

        // Remove this listener from the Context else it will run every
        // time the Context is stopped.
        context.removeLifecycleListener(this);
    }
}
项目:lazycat    文件:EngineConfig.java   
/**
 * Process the START event for an associated Engine.
 *
 * @param event
 *            The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the engine we are associated with
    try {
        engine = (Engine) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:lazycat    文件:UserConfig.java   
/**
 * Process the START event for an associated Host.
 *
 * @param event
 *            The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:lazycat    文件:JasperListener.java   
/**
 * Primary entry point for startup and shutdown events.
 *
 * @param event
 *            The event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
        try {
            // Set JSP factory
            Class.forName("org.apache.jasper.compiler.JspRuntimeContext", true, this.getClass().getClassLoader());
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            // Should not occur, obviously
            log.warn("Couldn't initialize Jasper", t);
        }
        // Another possibility is to do directly:
        // JspFactory.setDefaultFactory(new JspFactoryImpl());
    }

}
项目:tomcat-extension-samlsso    文件:SAML2SSOManagerTest.java   
@BeforeClass
public void init() {
    System.setProperty(Globals.CATALINA_BASE_PROP, Paths.get(TestConstants.TEST_RESOURCES_LOCATION).toString());

    prepareCatalinaComponents();

    //  load the server level configurations
    ServerConfigurationLoader loader = new ServerConfigurationLoader();
    List<Lifecycle> components = new ArrayList<>();
    components.add(new StandardServer());
    components.add(engine);
    components.stream()
            .forEach(component -> loader.lifecycleEvent(
                    new LifecycleEvent(component, Lifecycle.BEFORE_START_EVENT, null)));

    //  load the context configurations
    ContextConfigurationLoader contextLoader = new ContextConfigurationLoader();
    contextLoader.lifecycleEvent(new LifecycleEvent(barContext, Lifecycle.BEFORE_START_EVENT, null));
    contextLoader.lifecycleEvent(new LifecycleEvent(fooContext, Lifecycle.BEFORE_START_EVENT, null));
}
项目:hazelcast-tomcat-sessionmanager    文件:ClientServerLifecycleListener.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {

    if (getConfigLocation() == null) {
        setConfigLocation("hazelcast-client-default.xml");
    }

    if ("start".equals(event.getType())) {

        try {
            XmlClientConfigBuilder builder = new XmlClientConfigBuilder(getConfigLocation());
            config = builder.build();
        } catch (IOException e) {
            throw new RuntimeException("failed to load Config:", e);
        }

        if (config == null) {
            throw new RuntimeException("failed to find configLocation:" + getConfigLocation());
        }
    }
}
项目:Telepathology    文件:AbstractVistaRealmImpl.java   
/**
 * This is where the realm initialization occurs.
 * 
 * Get the realm started, this includes restoring the realm state from
 * context properties.
 */
@Override
public void start() throws LifecycleException
{
    // Server server = ServerFactory.getServer();
    // logger.info("VistaRealm starting on server " + server.getInfo());

    notifyLifecycleListeners(new LifecycleEvent(this, Lifecycle.BEFORE_START_EVENT));

    // register ourselves with the JMX MBean server if it exists
    mBeanRegistration();

    if (isInitialized())
    {
        getLogger().info("Realm[" + this.getRealmName() + "] initialized with authorization site " + this.toString() + ".");

        notifyLifecycleListeners(new LifecycleEvent(this, Lifecycle.START_EVENT));
        getLogger().info("Realm [" + this.getRealmName() + "] is started.");
        notifyLifecycleListeners(new LifecycleEvent(this, Lifecycle.AFTER_START_EVENT));
    } else
        getLogger().warn("[" + this.getRealmName() + "] is NOT initialized, use JMX interface to set required fields and initialize.");

}
项目:Telepathology    文件:TomcatLifecycleAdapter.java   
/**
 * Translate the Tomcat specific events into VIX, server-agnostic, events
 * 
 * @param event
 * @return
 */
static ServerLifecycleEvent translate(LifecycleEvent event)
{
    if ("INIT".equalsIgnoreCase( event.getType() ))
        return new ServerLifecycleEvent(ServerLifecycleEvent.EventType.INIT);           
    else if ("BEFORE_START".equalsIgnoreCase( event.getType() ))
        return new ServerLifecycleEvent(ServerLifecycleEvent.EventType.BEFORE_START);           
    else if ("START".equalsIgnoreCase( event.getType() ))
        return new ServerLifecycleEvent(ServerLifecycleEvent.EventType.START);          
    else if ("AFTER_START".equalsIgnoreCase( event.getType() ))
        return new ServerLifecycleEvent(ServerLifecycleEvent.EventType.AFTER_START);            
    else if ("BEFORE_STOP".equalsIgnoreCase( event.getType() ))
        return new ServerLifecycleEvent(ServerLifecycleEvent.EventType.BEFORE_STOP);            
    else if ("STOP".equalsIgnoreCase( event.getType() ))
        return new ServerLifecycleEvent(ServerLifecycleEvent.EventType.STOP);           
    else if ("AFTER_STOP".equalsIgnoreCase( event.getType() ))
        return new ServerLifecycleEvent(ServerLifecycleEvent.EventType.AFTER_STOP);         

    return null;
}
项目:tc-init-health-check-listener    文件:InitHealthCheckListener.java   
public void lifecycleEvent(LifecycleEvent event) {
    if (!(event.getLifecycle() instanceof Server))
        return;

    if (!startupCompleted && Lifecycle.AFTER_START_EVENT.equals(event.getType()))
        handleEvent((Server) event.getLifecycle(), "startup");
    else if (startupCompleted) {
        if(Lifecycle.BEFORE_STOP_EVENT.equals(event.getType()))
            handleEvent((Server) event.getLifecycle(), "prestop");
        else if(Lifecycle.STOP_EVENT.equals(event.getType()))
            handleEvent((Server) event.getLifecycle(), "stop");
        else if(Lifecycle.AFTER_STOP_EVENT.equals(event.getType()))
            handleEvent((Server) event.getLifecycle(), "poststop");
    }
    return;
}
项目:class-guard    文件:Tomcat.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    try {
        Context context = (Context) event.getLifecycle();
        if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
            context.setConfigured(true);
        }
        // LoginConfig is required to process @ServletSecurity
        // annotations
        if (context.getLoginConfig() == null) {
            context.setLoginConfig(
                    new LoginConfig("NONE", null, null, null));
            context.getPipeline().addValve(new NonLoginAuthenticator());
        }
    } catch (ClassCastException e) {
        return;
    }
}
项目:class-guard    文件:EngineConfig.java   
/**
 * Process the START event for an associated Engine.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the engine we are associated with
    try {
        engine = (Engine) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:class-guard    文件:UserConfig.java   
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:apache-tomcat-7.0.57    文件:Tomcat.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    try {
        Context context = (Context) event.getLifecycle();
        if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
            context.setConfigured(true);
        }
        // LoginConfig is required to process @ServletSecurity
        // annotations
        if (context.getLoginConfig() == null) {
            context.setLoginConfig(
                    new LoginConfig("NONE", null, null, null));
            context.getPipeline().addValve(new NonLoginAuthenticator());
        }
    } catch (ClassCastException e) {
        return;
    }
}
项目:apache-tomcat-7.0.57    文件:EngineConfig.java   
/**
 * Process the START event for an associated Engine.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the engine we are associated with
    try {
        engine = (Engine) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:apache-tomcat-7.0.57    文件:UserConfig.java   
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:apache-tomcat-7.0.57    文件:JasperListener.java   
/**
 * Primary entry point for startup and shutdown events.
 *
 * @param event The event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
        try {
            // Set JSP factory
            Class.forName("org.apache.jasper.compiler.JspRuntimeContext",
                          true,
                          this.getClass().getClassLoader());
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            // Should not occur, obviously
            log.warn("Couldn't initialize Jasper", t);
        }
        // Another possibility is to do directly:
        // JspFactory.setDefaultFactory(new JspFactoryImpl());
    }

}
项目:apache-tomcat-7.0.57    文件:Tomcat.java   
@Override
public void lifecycleEvent(LifecycleEvent event) {
    try {
        Context context = (Context) event.getLifecycle();
        if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
            context.setConfigured(true);
        }
        // LoginConfig is required to process @ServletSecurity
        // annotations
        if (context.getLoginConfig() == null) {
            context.setLoginConfig(
                    new LoginConfig("NONE", null, null, null));
            context.getPipeline().addValve(new NonLoginAuthenticator());
        }
    } catch (ClassCastException e) {
        return;
    }
}
项目:apache-tomcat-7.0.57    文件:EngineConfig.java   
/**
 * Process the START event for an associated Engine.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the engine we are associated with
    try {
        engine = (Engine) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:apache-tomcat-7.0.57    文件:UserConfig.java   
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.START_EVENT))
        start();
    else if (event.getType().equals(Lifecycle.STOP_EVENT))
        stop();

}
项目:apache-tomcat-7.0.57    文件:JasperListener.java   
/**
 * Primary entry point for startup and shutdown events.
 *
 * @param event The event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
        try {
            // Set JSP factory
            Class.forName("org.apache.jasper.compiler.JspRuntimeContext",
                          true,
                          this.getClass().getClassLoader());
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            // Should not occur, obviously
            log.warn("Couldn't initialize Jasper", t);
        }
        // Another possibility is to do directly:
        // JspFactory.setDefaultFactory(new JspFactoryImpl());
    }

}
项目:product-as    文件:SAML2SSOManagerTest.java   
@BeforeClass
public void init() {
    System.setProperty(Globals.CATALINA_BASE_PROP, Paths.get(TestConstants.TEST_RESOURCES_LOCATION).toString());

    prepareCatalinaComponents();

    //  load the server level configurations
    ServerConfigurationLoader loader = new ServerConfigurationLoader();
    List<Lifecycle> components = new ArrayList<>();
    components.add(new StandardServer());
    components.add(engine);
    components.stream()
            .forEach(component -> loader.lifecycleEvent(
                    new LifecycleEvent(component, Lifecycle.BEFORE_START_EVENT, null)));

    //  load the context configurations
    ContextConfigurationLoader contextLoader = new ContextConfigurationLoader();
    contextLoader.lifecycleEvent(new LifecycleEvent(barContext, Lifecycle.BEFORE_START_EVENT, null));
    contextLoader.lifecycleEvent(new LifecycleEvent(fooContext, Lifecycle.BEFORE_START_EVENT, null));
}
项目:product-as    文件:ApplicationServerConfigurationTest.java   
@Test(description = "Loads the XML file content of a valid WSO2 App Server specific server level configuration " +
        "descriptor", priority = 2)
public void testObjectLoadingFromDescriptor() throws IOException, ApplicationServerConfigurationException {
    //  deletes the existing server descriptor
    Files.delete(dist_server_descriptor);

    Path source = Paths.get(TestConstants.TEST_RESOURCES, Constants.APP_SERVER_DESCRIPTOR);
    Files.copy(source, dist_server_descriptor);

    lifecycle_components
            .stream()
            .forEach(component -> loader.lifecycleEvent(
                    new LifecycleEvent(component, Lifecycle.BEFORE_START_EVENT, null)));

    ApplicationServerConfiguration actual = ServerConfigurationLoader.getServerConfiguration();
    ApplicationServerConfiguration expected = generateDefault();
    Assert.assertTrue(compare(actual, expected));

    //  deletes the existing server descriptor
    Files.delete(dist_server_descriptor);
}