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

项目:tomcat7    文件:LifecycleSupport.java   
/**
 * Remove a lifecycle event listener from this component.
 *
 * @param listener The listener to remove
 */
public void removeLifecycleListener(LifecycleListener listener) {

    synchronized (listenersLock) {
        int n = -1;
        for (int i = 0; i < listeners.length; i++) {
            if (listeners[i] == listener) {
                n = i;
                break;
            }
        }
        if (n < 0)
            return;
        LifecycleListener results[] =
          new LifecycleListener[listeners.length - 1];
        int j = 0;
        for (int i = 0; i < listeners.length; i++) {
            if (i != n)
                results[j++] = listeners[i];
        }
        listeners = results;
    }

}
项目:lazycat    文件:LifecycleSupport.java   
/**
 * Remove a lifecycle event listener from this component.
 *
 * @param listener
 *            The listener to remove
 */
public void removeLifecycleListener(LifecycleListener listener) {

    synchronized (listenersLock) {
        int n = -1;
        for (int i = 0; i < listeners.length; i++) {
            if (listeners[i] == listener) {
                n = i;
                break;
            }
        }
        if (n < 0)
            return;
        LifecycleListener results[] = new LifecycleListener[listeners.length - 1];
        int j = 0;
        for (int i = 0; i < listeners.length; i++) {
            if (i != n)
                results[j++] = listeners[i];
        }
        listeners = results;
    }

}
项目:jerrydog    文件:LifecycleListenerRule.java   
/**
 * 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);

}
项目:jerrydog    文件:LifecycleSupport.java   
/**
 * Notify all lifecycle event listeners that a particular event has
 * occurred for this Container.  The default implementation performs
 * this notification synchronously using the calling thread.
 *
 * @param type Event type
 * @param data Event data
 */
public void fireLifecycleEvent(String type, Object data) {

    LifecycleEvent event = new LifecycleEvent(lifecycle, type, data);
    LifecycleListener interested[] = null;
    synchronized (listeners) {
        interested = (LifecycleListener[]) listeners.clone();
    }
    for (int i = 0; i < interested.length; i++)
        interested[i].lifecycleEvent(event);

}
项目:tomcat7    文件:LifecycleSupport.java   
/**
 * 增加生命周期的监听,用数组存储
 * Add a lifecycle event listener to this component.
 *
 * @param listener The listener to add
 */
public void addLifecycleListener(LifecycleListener listener) {

  synchronized (listenersLock) {
      LifecycleListener results[] =
        new LifecycleListener[listeners.length + 1];
      for (int i = 0; i < listeners.length; i++)
          results[i] = listeners[i];
      results[listeners.length] = listener;
      listeners = results;
  }

}
项目:tomcat7    文件:TestMapperListener.java   
public ListenersInfo(Container container,
        ContainerListener[] containerListeners,
        LifecycleListener[] lifecycleListeners) {
    this.container = container;
    this.containerListeners = containerListeners;
    this.lifecycleListeners = lifecycleListeners;
}
项目:lams    文件:UserConfig.java   
/**
 * Deploy a web application for the specified user if they have such an
 * application in the defined directory within their home directory.
 *
 * @param user Username owning the application to be deployed
 * @param home Home directory of this user
 */
private void deploy(String user, String home) {

    // Does this user have a web application to be deployed?
    String contextPath = "/~" + user;
    if (host.findChild(contextPath) != null)
        return;
    File app = new File(home, directoryName);
    if (!app.exists() || !app.isDirectory())
        return;
    /*
    File dd = new File(app, "/WEB-INF/web.xml");
    if (!dd.exists() || !dd.isFile() || !dd.canRead())
        return;
    */
    host.getLogger().info(sm.getString("userConfig.deploy", user));

    // Deploy the web application for this user
    try {
        Class clazz = Class.forName(contextClass);
        Context context =
          (Context) clazz.newInstance();
        context.setPath(contextPath);
        context.setDocBase(app.toString());
        if (context instanceof Lifecycle) {
            clazz = Class.forName(configClass);
            LifecycleListener listener =
              (LifecycleListener) clazz.newInstance();
            ((Lifecycle) context).addLifecycleListener(listener);
        }
        host.addChild(context);
    } catch (Exception e) {
        host.getLogger().error(sm.getString("userConfig.error", user), e);
    }

}
项目:apache-tomcat-7.0.73-with-comment    文件:LifecycleSupport.java   
/**
 * Notify all lifecycle event listeners that a particular event has
 * occurred for this Container.  The default implementation performs
 * this notification synchronously using the calling thread.
 *
 * @param type Event type
 * @param data Event data
 */
public void fireLifecycleEvent(String type, Object data) {

    LifecycleEvent event = new LifecycleEvent(lifecycle, type, data);
    LifecycleListener interested[] = listeners;
    for (int i = 0; i < interested.length; i++)
        interested[i].lifecycleEvent(event);

}
项目:apache-tomcat-7.0.73-with-comment    文件:LifecycleSupport.java   
/**
 * Add a lifecycle event listener to this component.
 *
 * @param listener The listener to add
 */
public void addLifecycleListener(LifecycleListener listener) {

  synchronized (listenersLock) {
      LifecycleListener results[] =
        new LifecycleListener[listeners.length + 1];
      for (int i = 0; i < listeners.length; i++)
          results[i] = listeners[i];
      results[listeners.length] = listener;
      listeners = results;
  }

}
项目:lazycat    文件:LifecycleSupport.java   
/**
 * Add a lifecycle event listener to this component.
 *
 * @param listener
 *            The listener to add
 */
public void addLifecycleListener(LifecycleListener listener) {

    synchronized (listenersLock) {
        LifecycleListener results[] = new LifecycleListener[listeners.length + 1];
        for (int i = 0; i < listeners.length; i++)
            results[i] = listeners[i];
        results[listeners.length] = listener;
        listeners = results;
    }

}
项目:lams    文件:LifecycleSupport.java   
/**
 * Add a lifecycle event listener to this component.
 *
 * @param listener The listener to add
 */
public void addLifecycleListener(LifecycleListener listener) {

  synchronized (listeners) {
      LifecycleListener results[] =
        new LifecycleListener[listeners.length + 1];
      for (int i = 0; i < listeners.length; i++)
          results[i] = listeners[i];
      results[listeners.length] = listener;
      listeners = results;
  }

}
项目:lazycat    文件:UserConfig.java   
/**
 * Deploy a web application for the specified user if they have such an
 * application in the defined directory within their home directory.
 *
 * @param user
 *            Username owning the application to be deployed
 * @param home
 *            Home directory of this user
 */
private void deploy(String user, String home) {

    // Does this user have a web application to be deployed?
    String contextPath = "/~" + user;
    if (host.findChild(contextPath) != null)
        return;
    File app = new File(home, directoryName);
    if (!app.exists() || !app.isDirectory())
        return;
    /*
     * File dd = new File(app, "/WEB-INF/web.xml"); if (!dd.exists() ||
     * !dd.isFile() || !dd.canRead()) return;
     */
    host.getLogger().info(sm.getString("userConfig.deploy", user));

    // Deploy the web application for this user
    try {
        Class<?> clazz = Class.forName(contextClass);
        Context context = (Context) clazz.newInstance();
        context.setPath(contextPath);
        context.setDocBase(app.toString());
        clazz = Class.forName(configClass);
        LifecycleListener listener = (LifecycleListener) clazz.newInstance();
        context.addLifecycleListener(listener);
        host.addChild(context);
    } catch (Exception e) {
        host.getLogger().error(sm.getString("userConfig.error", user), e);
    }

}
项目:jerrydog    文件:StandardServer.java   
/**
 * Store the specified Server properties.
 *
 * @param writer PrintWriter to which we are storing
 * @param indent Number of spaces to indent this element
 * @param server Object to be stored
 *
 * @exception Exception if an exception occurs while storing
 */
private void storeServer(PrintWriter writer, int indent,
                         Server server) throws Exception {

    // Store the beginning of this element
    writer.println("<?xml version='1.0' encoding='utf-8'?>");
    for (int i = 0; i < indent; i++) {
        writer.print(' ');
    }
    writer.print("<Server");
    storeAttributes(writer, server);
    writer.println(">");

    // Store nested <Listener> elements
    if (server instanceof Lifecycle) {
        LifecycleListener listeners[] =
            ((Lifecycle) server).findLifecycleListeners();
        for (int i = 0; i < listeners.length; i++) {
            storeListener(writer, indent + 2, listeners[i]);
        }
    }

    // Store nested <GlobalNamingResources> element
    NamingResources globalNamingResources =
        server.getGlobalNamingResources();
    if (globalNamingResources != null) {
        for (int i = 0; i < indent + 2; i++) {
            writer.print(' ');
        }
        writer.println("<GlobalNamingResources>");
        storeNamingResources(writer, indent + 4, globalNamingResources);
        for (int i = 0; i < indent + 2; i++) {
            writer.print(' ');
        }
        writer.println("</GlobalNamingResources>");
    }

    // Store nested <Service> elements
    Service services[] = server.findServices();
    for (int i = 0; i < services.length; i++) {
        storeService(writer, indent + 2, services[i]);
    }

    // Store the ending of this element
    for (int i = 0; i < indent; i++) {
        writer.print(' ');
    }
    writer.println("</Server>");

}
项目:apache-tomcat-7.0.73-with-comment    文件:TestMapperListener.java   
public ListenersInfo(Container container,
        ContainerListener[] containerListeners,
        LifecycleListener[] lifecycleListeners) {
    this.container = container;
    this.containerListeners = containerListeners;
    this.lifecycleListeners = lifecycleListeners;
}
项目:jerrydog    文件:UserConfig.java   
/**
 * Deploy a web application for the specified user if they have such an
 * application in the defined directory within their home directory.
 *
 * @param user Username owning the application to be deployed
 * @param home Home directory of this user
 */
private void deploy(String user, String home) {

    // Does this user have a web application to be deployed?
    String contextPath = "/~" + user;
    if (host.findChild(contextPath) != null)
        return;
    File app = new File(home, directoryName);
    if (!app.exists() || !app.isDirectory())
        return;
    /*
    File dd = new File(app, "/WEB-INF/web.xml");
    if (!dd.exists() || !dd.isFile() || !dd.canRead())
        return;
    */
    log(sm.getString("userConfig.deploy", user));

    // Deploy the web application for this user
    try {
        Class clazz = Class.forName(contextClass);
        Context context =
          (Context) clazz.newInstance();
        context.setPath(contextPath);
        context.setDocBase(app.toString());
        if (context instanceof Lifecycle) {
            clazz = Class.forName(configClass);
            LifecycleListener listener =
              (LifecycleListener) clazz.newInstance();
            ((Lifecycle) context).addLifecycleListener(listener);
        }
        host.addChild(context);
    } catch (Exception e) {
        log(sm.getString("userConfig.error", user), e);
    }

}
项目:tomcat7    文件:WebappClassLoaderBase.java   
/**
 * Get the lifecycle listeners associated with this lifecycle. If this
 * Lifecycle has no listeners registered, a zero-length array is returned.
 */
@Override
public LifecycleListener[] findLifecycleListeners() {
    return new LifecycleListener[0];
}
项目:apache-tomcat-7.0.73-with-comment    文件:TesterContext.java   
@Override
public void removeLifecycleListener(LifecycleListener listener) {
    // NO-OP
}
项目:tomcat7    文件:LifecycleBase.java   
/**
 * {@inheritDoc}
 */
@Override
public void addLifecycleListener(LifecycleListener listener) {
    lifecycle.addLifecycleListener(listener);
}
项目:tomcat7    文件:TesterContext.java   
@Override
public void addLifecycleListener(LifecycleListener listener) {
    // NO-OP
}
项目:apache-tomcat-7.0.73-with-comment    文件:LifecycleBase.java   
/**
 * {@inheritDoc}
 */
@Override
public LifecycleListener[] findLifecycleListeners() {
    return lifecycle.findLifecycleListeners();
}
项目:tomcat7    文件:TesterContext.java   
@Override
public void removeLifecycleListener(LifecycleListener listener) {
    // NO-OP
}
项目:apache-tomcat-7.0.73-with-comment    文件:LifecycleBase.java   
/**
 * {@inheritDoc}
 */
@Override
public void removeLifecycleListener(LifecycleListener listener) {
    lifecycle.removeLifecycleListener(listener);
}
项目:jerrydog    文件:StandardServer.java   
/**
 * Store the specified Connector properties.
 *
 * @param writer PrintWriter to which we are storing
 * @param indent Number of spaces to indent this element
 * @param connector Object whose properties are being stored
 *
 * @exception Exception if an exception occurs while storing
 */
private void storeConnector(PrintWriter writer, int indent,
                            Connector connector) throws Exception {

    // Store the beginning of this element
    for (int i = 0; i < indent; i++) {
        writer.print(' ');
    }
    writer.print("<Connector");
    storeAttributes(writer, connector);
    writer.println(">");

    // Store nested <Factory> element
    ServerSocketFactory factory = connector.getFactory();
    if (factory != null) {
        storeFactory(writer, indent + 2, factory);
    }

    // Store nested <Listener> elements
    if (connector instanceof Lifecycle) {
        LifecycleListener listeners[] =
            ((Lifecycle) connector).findLifecycleListeners();
        if (listeners == null) {
            listeners = new LifecycleListener[0];
        }
        for (int i = 0; i < listeners.length; i++) {
            if (listeners[i].getClass().getName().equals
                (SERVER_LISTENER_CLASS_NAME)) {
                continue;
            }
            storeListener(writer, indent + 2, listeners[i]);
        }
    }

    // Store the ending of this element
    for (int i = 0; i < indent; i++) {
        writer.print(' ');
    }
    writer.println("</Connector>");

}
项目:tomcat7    文件:TesterHost.java   
@Override
public void removeLifecycleListener(LifecycleListener listener) {
    // NO-OP
}
项目:tomcat8-redis-session-manager    文件:RedisSessionManager.java   
/**
 * Get the lifecycle listeners associated with this lifecycle. If this
 * Lifecycle has no listeners registered, a zero-length array is returned.
 */
@Override
public LifecycleListener[] findLifecycleListeners() {
  return lifecycle.findLifecycleListeners();
}
项目:lazycat    文件:LifecycleBase.java   
/**
 * {@inheritDoc}
 */
@Override
public void addLifecycleListener(LifecycleListener listener) {
    lifecycle.addLifecycleListener(listener);
}
项目:apache-tomcat-7.0.73-with-comment    文件:TesterHost.java   
@Override
public LifecycleListener[] findLifecycleListeners() {
    return null;
}
项目:apache-tomcat-7.0.73-with-comment    文件:TesterContext.java   
@Override
public void addLifecycleListener(LifecycleListener listener) {
    // NO-OP
}
项目:apache-tomcat-7.0.73-with-comment    文件:LifecycleBase.java   
/**
 * {@inheritDoc}
 */
@Override
public void addLifecycleListener(LifecycleListener listener) {
    lifecycle.addLifecycleListener(listener);
}
项目:lams    文件:RewriteValve.java   
public void removeLifecycleListener(LifecycleListener listener) {
    lifecycle.removeLifecycleListener(listener);
}
项目:lazycat    文件:LifecycleSupport.java   
/**
 * Notify all lifecycle event listeners that a particular event has occurred
 * for this Container. The default implementation performs this notification
 * synchronously using the calling thread.
 *
 * @param type
 *            Event type
 * @param data
 *            Event data
 */
public void fireLifecycleEvent(String type, Object data) {

    LifecycleEvent event = new LifecycleEvent(lifecycle, type, data);
    LifecycleListener interested[] = listeners;
    for (int i = 0; i < interested.length; i++)
        interested[i].lifecycleEvent(event);

}
项目:tomcat7    文件:WebappClassLoaderBase.java   
/**
 * Remove a lifecycle event listener from this component.
 *
 * @param listener The listener to remove
 */
@Override
public void removeLifecycleListener(LifecycleListener listener) {
    // NOOP
}
项目:tomcat7    文件:Tomcat.java   
/**
 * Return a listener that provides the required configuration items for JSP
 * processing. From the standard Tomcat global web.xml. Pass this to
 * {@link Context#addLifecycleListener(LifecycleListener)} and then pass the
 * result of {@link #noDefaultWebXmlPath()} to 
 * {@link ContextConfig#setDefaultWebXml(String)}. 
 * @return a listener object that configures default JSP processing.
 */
public LifecycleListener getDefaultWebXmlListener() {
    return new DefaultWebXmlListener();
}
项目:jerrydog    文件:HttpProcessor.java   
/**
 * Get the lifecycle listeners associated with this lifecycle. If this
 * Lifecycle has no listeners registered, a zero-length array is returned.
 */
public LifecycleListener[] findLifecycleListeners() {

    return lifecycle.findLifecycleListeners();

}
项目:jerrydog    文件:HttpConnector.java   
/**
 * Remove a lifecycle event listener from this component.
 *
 * @param listener The listener to add
 */
public void removeLifecycleListener(LifecycleListener listener) {

    lifecycle.removeLifecycleListener(listener);

}
项目:jerrydog    文件:AccessLogValve.java   
/**
 * Remove a lifecycle event listener from this component.
 *
 * @param listener The listener to add
 */
public void removeLifecycleListener(LifecycleListener listener) {

    lifecycle.removeLifecycleListener(listener);

}
项目:jerrydog    文件:LifecycleSupport.java   
/**
 * Get the lifecycle listeners associated with this lifecycle. If this 
 * Lifecycle has no listeners registered, a zero-length array is returned.
 */
public LifecycleListener[] findLifecycleListeners() {

    return listeners;

}
项目:jerrydog    文件:AccessLogValve.java   
/**
 * Add a lifecycle event listener to this component.
 *
 * @param listener The listener to add
 */
public void addLifecycleListener(LifecycleListener listener) {

    lifecycle.addLifecycleListener(listener);

}
项目:jerrydog    文件:HttpProcessor.java   
/**
 * Add a lifecycle event listener to this component.
 *
 * @param listener The listener to add
 */
public void addLifecycleListener(LifecycleListener listener) {

    lifecycle.addLifecycleListener(listener);

}
项目:jerrydog    文件:StandardService.java   
/**
 * Remove a LifecycleEvent listener from this component.
 *
 * @param listener The listener to remove
 */
public void removeLifecycleListener(LifecycleListener listener) {

    lifecycle.removeLifecycleListener(listener);

}