本文整理了Java中org.apache.catalina.LifecycleEvent
类的一些代码示例,展示了LifecycleEvent
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LifecycleEvent
类的具体详情如下:
包路径:org.apache.catalina.LifecycleEvent
类名称:LifecycleEvent
[英]General event for notifying listeners of significant changes on a component that implements the Lifecycle interface. In particular, this will be useful on Containers, where these events replace the ContextInterceptor concept in Tomcat 3.x.
[中]用于通知侦听器实现生命周期接口的组件上的重大更改的常规事件。特别是,这在容器上非常有用,其中这些事件取代了Tomcat3中的ContextInterceptor概念。十、
代码示例来源:origin: org.springframework.boot/spring-boot
@Override
public void lifecycleEvent(LifecycleEvent event) {
if (event.getType().equals(Lifecycle.START_EVENT)) {
Context cOntext= (Context) event.getLifecycle();
Manager manager = context.getManager();
if (manager != null && manager instanceof StandardManager) {
((StandardManager) manager).setPathname(null);
}
}
}
代码示例来源:origin: org.springframework.boot/spring-boot
context.addLifecycleListener((event) -> {
if (context.equals(event.getSource())
&& Lifecycle.START_EVENT.equals(event.getType())) {
ContextBindings.bindClassLoader(context, context.getNamingToken(),
getClass().getClassLoader());
代码示例来源:origin: SonarSource/sonarqube
@Test
public void log_when_started_and_stopped() {
Logger logger = mock(Logger.class);
TomcatAccessLog.LifecycleLogger listener = new TomcatAccessLog.LifecycleLogger(logger);
LifecycleEvent event = new LifecycleEvent(mock(Lifecycle.class), "before_init", null);
listener.lifecycleEvent(event);
verifyZeroInteractions(logger);
event = new LifecycleEvent(mock(Lifecycle.class), "after_start", null);
listener.lifecycleEvent(event);
verify(logger).debug("Tomcat is started");
event = new LifecycleEvent(mock(Lifecycle.class), "after_destroy", null);
listener.lifecycleEvent(event);
verify(logger).debug("Tomcat is stopped");
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* 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();
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@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());
}
}
}
}
代码示例来源:origin: org.jaggeryjs/org.jaggeryjs.jaggery.tomcat.listener
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.CONFIGURE_START_EVENT.equals(event.getType())) {
Context cOntext= null;
if (event.getLifecycle() instanceof Context) {
cOntext= (Context) event.getLifecycle();
}
if (!isJaggeryApp(context)) {
return;
}
log.debug(context.getName() + " is identified as a Jagggery App");
try {
Class> webappLoader = context.getServletContext().getClassLoader().loadClass(JAGGERY_CLASSLOAD_NAME);
Method methodProcessJaggeryApp = webappLoader.getMethod(JAGGERY_METHOD_NAME, Context.class, Path.class);
methodProcessJaggeryApp.invoke(webappLoader.newInstance(), context, getAppBase(context));
} catch (Exception e) {
log.error("Error occurred while processing the jaggery.conf file", e);
}
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@Override
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.BEFORE_START_EVENT.equals(event.getType())) {
initWebappDefaults((Context) event.getLifecycle());
}
}
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
public void lifecycleEvent(LifecycleEvent event) {
try {
Context cOntext= (Context) event.getLifecycle();
if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
context.setConfigured(true);
}
} catch (ClassCastException e) {
return;
}
}
代码示例来源:origin: org.apache.openejb/tomee-webservices
public void lifecycleEvent(LifecycleEvent event) {
Context cOntext= (Context) event.getLifecycle();
if (event.getType().equals(Lifecycle.BEFORE_START_EVENT)) {
context.getServletContext().setAttribute(IGNORE_CONTEXT, "true");
}
if (event.getType().equals(Lifecycle.START_EVENT) || event.getType().equals(Lifecycle.BEFORE_START_EVENT) || event.getType().equals("configure_start")) {
context.setConfigured(true);
}
}
});
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Use as base to handle start/stop/periodic Events from host. Currently
* only log the messages as trace level.
*
* @see org.apache.catalina.LifecycleListener#lifecycleEvent(org.apache.catalina.LifecycleEvent)
*/
@Override
public void lifecycleEvent(LifecycleEvent lifecycleEvent) {
if (log.isTraceEnabled())
log.trace(sm.getString("SimpleTcpCluster.event.log", lifecycleEvent.getType(), lifecycleEvent.getData()));
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void lifecycleEvent(LifecycleEvent event) {
if ("after_start".equals(event.getType())) {
logger.debug("Tomcat is started");
} else if ("after_destroy".equals(event.getType())) {
logger.debug("Tomcat is stopped");
}
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@Override
public void lifecycleEvent(LifecycleEvent event) {
try {
Context cOntext= (Context) event.getLifecycle();
if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
context.setConfigured(true);
// Process annotations
WebAnnotationSet.loadApplicationAnnotations(context);
// 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) {
}
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@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);
}
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@Override
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.BEFORE_START_EVENT.equals(event.getType())) {
if (!libraryName.isEmpty()) {
System.loadLibrary(libraryName);
log.info(sm.getString("jniLifecycleListener.load.name", libraryName));
} else if (!libraryPath.isEmpty()) {
System.load(libraryPath);
log.info(sm.getString("jniLifecycleListener.load.path", libraryPath));
} else {
throw new IllegalArgumentException(sm.getString("jniLifecycleListener.missingPathOrName"));
}
}
}
代码示例来源:origin: codefollower/Tomcat-Research
@Override
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.AFTER_START_EVENT.equals(event.getType())) {
if (event.getSource() instanceof StandardServer) {
createMBean((StandardServer) event.getSource());
}
}
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6
@Override
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.START_EVENT.equals(event.getType())) {
event = new LifecycleEvent(event.getLifecycle(),
Lifecycle.INIT_EVENT,
event.getData());
} else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
event = new LifecycleEvent(event.getLifecycle(),
Lifecycle.AFTER_STOP_EVENT,
event.getData());
}
super.lifecycleEvent(event);
}
}
代码示例来源:origin: org.apache.tomee/tomee-loader
@Override
public synchronized void lifecycleEvent(final LifecycleEvent event) {
try {
if (server == null && Lifecycle.START_EVENT.equals(event.getType())) {
serviceURL = new JMXServiceURL(protocol, host, port, urlPath);
server = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null,
ManagementFactory.getPlatformMBeanServer());
server.start();
LOGGER.info("Started JMX server: " + serviceURL.toString());
} else if (server != null && Lifecycle.STOP_EVENT.equals(event.getType())) {
server.stop();
server = null;
LOGGER.info("Stopped JMX server: " + serviceURL.toString());
}
} catch (final Exception e) {
throw new JMXException(e);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void start() throws Exception {
this.tomcatServer.start();
this.port = this.tomcatServer.getConnector().getLocalPort();
this.context.addLifecycleListener(event -> {
if (logger.isDebugEnabled()) {
logger.debug("Event: " + event.getType());
}
});
}
代码示例来源:origin: org.nuxeo.lib.runtime/nuxeo-runtime-tomcat-adapter
@Override
public void lifecycleEvent(LifecycleEvent event) {
Lifecycle lf = event.getLifecycle();
if (lf instanceof Context) {
Loader loader = ((Context) lf).getLoader();
if (loader instanceof NuxeoWebappLoader) {
handleEvent((NuxeoWebappLoader) loader, event);
}
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* @return the Lifecycle on which this event occurred.
*/
public Lifecycle getLifecycle() {
return (Lifecycle) getSource();
}