org.apache.catalina.Lifecycle.addLifecycleListener()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(184)

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

Lifecycle.addLifecycleListener介绍

[英]Add a LifecycleEvent listener to this component.
[中]将LifecycleEvent侦听器添加到此组件。

代码示例

代码示例来源:origin: org.apache.tomee/tomee-catalina

@Override
public void addLifecycleListener(final LifecycleListener listener) {
  if (delegate instanceof Lifecycle) {
    ((Lifecycle) delegate).addLifecycleListener(listener);
  }
}

代码示例来源:origin: tomcat/catalina

/**
 * Handle the beginning of an XML element.
 *
 * @param attributes The attributes of this element
 *
 * @exception Exception if a processing error occurs
 */
public void begin(String namespace, String name, Attributes attributes)
  throws Exception {
  // Instantiate a new LifecyleListener implementation object
  String className = listenerClass;
  if (attributeName != null) {
    String value = attributes.getValue(attributeName);
    if (value != null)
      className = value;
  }
  Class clazz = Class.forName(className);
  LifecycleListener listener =
    (LifecycleListener) clazz.newInstance();
  // Add this LifecycleListener to our associated component
  Lifecycle lifecycle = (Lifecycle) digester.peek();
  lifecycle.addLifecycleListener(listener);
}

代码示例来源:origin: org.glassfish.main.web/web-core

/**
 * Handle the beginning of an XML element.
 *
 * @param attributes The attributes of this element
 *
 * @exception Exception if a processing error occurs
 */
public void begin(Attributes attributes) throws Exception {
  // Instantiate a new LifecyleListener implementation object
  String className = listenerClass;
  if (attributeName != null) {
    String value = attributes.getValue(attributeName);
    if (value != null)
      className = value;
  }
  Class clazz = Class.forName(className);
  LifecycleListener listener =
    (LifecycleListener) clazz.newInstance();
  // Add this LifecycleListener to our associated component
  Lifecycle lifecycle = (Lifecycle) digester.peek();
  lifecycle.addLifecycleListener(listener);
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-tomcat

/**
* Associate lifecycle listeners with the instance, if it implements Lifecycle.
*/
protected static void addLifecycleListeners(Object instance, List<ListenerMetaData> list) throws Exception
{
 if (list == null) {
   return;
 }
 org.apache.catalina.Lifecycle lifecycle = null;
 if (!(instance instanceof org.apache.catalina.Lifecycle))
 {
   return;
 }
 else
 {
   lifecycle = (org.apache.catalina.Lifecycle) instance;
 }
 Iterator<ListenerMetaData> listenerMetaDatas = list.iterator();
 while (listenerMetaDatas.hasNext())
 {
   ListenerMetaData listenerMetaData = listenerMetaDatas.next();
   lifecycle.addLifecycleListener((org.apache.catalina.LifecycleListener) getInstance(listenerMetaData, null));
 }
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat

public Context createEJBWebServiceContext(String contextPath, 
    WebServiceContainer webServiceContainer, 
    String securityRealmName, 
    String realmName, 
    String transportGuarantee, 
    String authMethod, 
    ClassLoader classLoader) {
  if( log.isDebugEnabled() )
    log.debug("Creating EJBWebService context '" + contextPath + "'.");
  TomcatEJBWebServiceContext context = new TomcatEJBWebServiceContext(contextPath, webServiceContainer, securityRealmName, realmName, transportGuarantee, authMethod, classLoader);
  ContextConfig config = new ContextConfig();
  config.setCustomAuthenticators(authenticators);
  ((Lifecycle) context).addLifecycleListener(config);
  return (context);
}

代码示例来源:origin: tomcat/catalina

LifecycleListener listener =
  (LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);

代码示例来源:origin: org.jboss.mod_cluster/mod_cluster

public void start() throws JMException
{
 Server server = this.findServer();
 
 if (server != null)
 {
   if (!(server instanceof Lifecycle)) throw new IllegalStateException();
   Lifecycle lifecycle = (Lifecycle) server;
      if (!this.containsListener(lifecycle))
   {
    lifecycle.addLifecycleListener(this);
   }
      if (this.init.compareAndSet(false, true))
   {
    this.init(server);
   }
      if (this.start.compareAndSet(false, true))
   {
    this.eventHandler.start(new CatalinaServer(server, this.mbeanServer));
   }
 }
}

代码示例来源:origin: org.jboss.mod_cluster/mod_cluster

private void addListeners(Server server)
{
 // Register ourself as a listener for child services
 for (Service service: server.findServices())
 {
   Container engine = service.getContainer();
   engine.addContainerListener(this);
   ((Lifecycle) engine).addLifecycleListener(this);
   for (Container host: engine.findChildren())
   {
    host.addContainerListener(this);
    
    for (Container context: host.findChildren())
    {
      ((Lifecycle) context).addLifecycleListener(this);
    }
   }
 }
}

代码示例来源:origin: tomcat/catalina

LifecycleListener listener =
 (LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);

代码示例来源:origin: org.jboss.web/jbossweb

/**
 * Prepare for the beginning of active use of the public methods of this
 * component.  This method should be called after <code>configure()</code>,
 * and before any of the public methods of the component are utilized.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
public void start() throws LifecycleException {
  // Validate and update our current component state
  if (started)
    throw new LifecycleException
      (MESSAGES.valveAlreadyStarted());
  lifecycle.fireLifecycleEvent(START_EVENT, null);
  started = true;
  if (container instanceof Context) {
    ((Lifecycle) container).addLifecycleListener(this);
  }
  
}

代码示例来源:origin: jboss.web/jbossweb

/**
 * Prepare for the beginning of active use of the public methods of this
 * component.  This method should be called after <code>configure()</code>,
 * and before any of the public methods of the component are utilized.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
public void start() throws LifecycleException {
  // Validate and update our current component state
  if (started)
    throw new LifecycleException
      (sm.getString("semaphoreValve.alreadyStarted"));
  lifecycle.fireLifecycleEvent(START_EVENT, null);
  started = true;
  if (container instanceof Context) {
    ((Lifecycle) container).addLifecycleListener(this);
  }
  
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat

public Context createContext(String path, String docBase, ClassLoader cl) {
  if( log.isDebugEnabled() )
    log.debug("Creating context '" + path + "' with docBase '" +
          docBase + "'");
  GeronimoStandardContext context = new GeronimoStandardContext();
  context.setDocBase(docBase);
  context.setPath(path);
  
  if (cl != null)
    context.setParentClassLoader(cl);
  
  ContextConfig config = new ContextConfig();
  config.setCustomAuthenticators(authenticators);
  ((Lifecycle) context).addLifecycleListener(config);
  context.setDelegate(true);
  return (context);
}

代码示例来源:origin: tomcat/catalina

((Lifecycle) context).addLifecycleListener(config);

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6

for (ListenerType listenerType: getListener()) {
  LifecycleListener listener = listenerType.getLifecycleListener(cl);
  lifecycle.addLifecycleListener(listener);

代码示例来源:origin: jboss.web/jbossweb

((Lifecycle) context).addLifecycleListener(config);

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat6

for (ListenerType listenerType: getListener()) {
  LifecycleListener listener = listenerType.getLifecycleListener(cl);
  lifecycle.addLifecycleListener(listener);

代码示例来源:origin: org.mobicents.arquillian.container/mss-tomcat-embedded-6

@Override
public Context createContext(String path, String docBase) {
  if( log.isDebugEnabled() )
    log.debug("Creating context '" + path + "' with docBase '" +
          docBase + "'");
  context = new StandardContext();
  context.setDocBase(docBase);
  context.setPath(path);
  ContextConfig config = new ContextConfig();
  config.setCustomAuthenticators(authenticators);
  ((Lifecycle) context).addLifecycleListener(config);
  return (context);
}

代码示例来源:origin: jboss.web/jbossweb

((Lifecycle) context).addLifecycleListener(this);
if (context.isStarted()) {
  addContext(context);

代码示例来源:origin: org.jboss.web/jbossweb

((Lifecycle) context).addLifecycleListener(this);
if (context.isStarted()) {
  addContext(context);

代码示例来源:origin: jboss.web/jbossweb

Engine engine = (Engine) service.getContainer();
engine.addContainerListener(this);
((Lifecycle) engine).addLifecycleListener(this);
if (engine.getDefaultHost() != null) {
  mapper.setDefaultHostName(engine.getDefaultHost());
  mapper.addHost(host.getName(), ((Host) host).findAliases(), host);
  for (Container context : host.findChildren()) {
    ((Lifecycle) context).addLifecycleListener(this);

相关文章