热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.catalina.LifecycleEvent类的使用及代码示例

标题:

本文整理了Java中org.apache.catalina.LifecycleEvent类的一些代码示例,展示了LifecycleEvent类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LifecycleEvent类的具体详情如下:
包路径:org.apache.catalina.LifecycleEvent
类名称: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();
}

推荐阅读
  • 本文详细探讨了Java中的ClassLoader类加载器的工作原理,包括其如何将class文件加载至JVM中,以及JVM启动时的动态加载策略。文章还介绍了JVM内置的三种类加载器及其工作方式,并解释了类加载器的继承关系和双亲委托机制。 ... [详细]
  • 在尝试使用C# Windows Forms客户端通过SignalR连接到ASP.NET服务器时,遇到了内部服务器错误(500)。本文将详细探讨问题的原因及解决方案。 ... [详细]
  • 2018-2019学年第六周《Java数据结构与算法》学习总结
    本文总结了2018-2019学年第六周在《Java数据结构与算法》课程中的学习内容,重点介绍了非线性数据结构——树的相关知识及其应用。 ... [详细]
  • 本文介绍如何使用 Angular 6 的 HttpClient 模块来获取 HTTP 响应头,包括代码示例和常见问题的解决方案。 ... [详细]
  • Java项目分层架构设计与实践
    本文探讨了Java项目中应用分层的最佳实践,不仅介绍了常见的三层架构(Controller、Service、DAO),还深入分析了各层的职责划分及优化建议。通过合理的分层设计,可以提高代码的可维护性、扩展性和团队协作效率。 ... [详细]
  • 我有一个SpringRestController,它处理API调用的版本1。继承在SpringRestControllerpackagerest.v1;RestCon ... [详细]
  • 简化报表生成:EasyReport工具的全面解析
    本文详细介绍了EasyReport,一个易于使用的开源Web报表工具。该工具支持Hadoop、HBase及多种关系型数据库,能够将SQL查询结果转换为HTML表格,并提供Excel导出、图表显示和表头冻结等功能。 ... [详细]
  • 本文介绍如何从字符串中移除大写、小写、特殊、数字和非数字字符,并提供了多种编程语言的实现示例。 ... [详细]
  • 深入解析SpringMVC核心组件:DispatcherServlet的工作原理
    本文详细探讨了SpringMVC的核心组件——DispatcherServlet的运作机制,旨在帮助有一定Java和Spring基础的开发人员理解HTTP请求是如何被映射到Controller并执行的。文章将解答以下问题:1. HTTP请求如何映射到Controller;2. Controller是如何被执行的。 ... [详细]
  • 深入解析Spring启动过程
    本文详细介绍了Spring框架的启动流程,帮助开发者理解其内部机制。通过具体示例和代码片段,解释了Bean定义、工厂类、读取器以及条件评估等关键概念,使读者能够更全面地掌握Spring的初始化过程。 ... [详细]
  • 本文探讨了如何利用HTML5和JavaScript在浏览器中进行本地文件的读取和写入操作,并介绍了获取本地文件路径的方法。HTML5提供了一系列API,使得这些操作变得更加简便和安全。 ... [详细]
  • 本文将详细探讨 Java 中提供的不可变集合(如 `Collections.unmodifiableXXX`)和同步集合(如 `Collections.synchronizedXXX`)的实现原理及使用方法,帮助开发者更好地理解和应用这些工具。 ... [详细]
  • 实用正则表达式有哪些
    小编给大家分享一下实用正则表达式有哪些,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下 ... [详细]
  • 本文介绍了如何使用JavaScript的Fetch API与Express服务器进行交互,涵盖了GET、POST、PUT和DELETE请求的实现,并展示了如何处理JSON响应。 ... [详细]
  • 深入理解Vue.js:从入门到精通
    本文详细介绍了Vue.js的基础知识、安装方法、核心概念及实战案例,帮助开发者全面掌握这一流行的前端框架。 ... [详细]
author-avatar
叶子已经不是木头的了
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有