Search in sources :

Example 1 with ContainerListener

use of org.apache.catalina.ContainerListener in project tomcat by apache.

the class ContainerMBean method findContainerListenerNames.

/**
     * List the class name of each of the container listeners added to this
     * container.
     * @return the container listeners class names
     * @throws MBeanException propagated from the managed resource access
     */
public String[] findContainerListenerNames() throws MBeanException {
    Container container = doGetManagedResource();
    List<String> result = new ArrayList<>();
    ContainerListener[] listeners = container.findContainerListeners();
    for (ContainerListener listener : listeners) {
        result.add(listener.getClass().getName());
    }
    return result.toArray(new String[result.size()]);
}
Also used : Container(org.apache.catalina.Container) ArrayList(java.util.ArrayList) ContainerListener(org.apache.catalina.ContainerListener)

Example 2 with ContainerListener

use of org.apache.catalina.ContainerListener in project tomcat by apache.

the class StandardContext method createWrapper.

/**
     * Factory method to create and return a new Wrapper instance, of
     * the Java implementation class appropriate for this Context
     * implementation.  The constructor of the instantiated Wrapper
     * will have been called, but no properties will have been set.
     */
@Override
public Wrapper createWrapper() {
    Wrapper wrapper = null;
    if (wrapperClass != null) {
        try {
            wrapper = (Wrapper) wrapperClass.newInstance();
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            log.error("createWrapper", t);
            return (null);
        }
    } else {
        wrapper = new StandardWrapper();
    }
    synchronized (wrapperLifecyclesLock) {
        for (int i = 0; i < wrapperLifecycles.length; i++) {
            try {
                Class<?> clazz = Class.forName(wrapperLifecycles[i]);
                LifecycleListener listener = (LifecycleListener) clazz.newInstance();
                wrapper.addLifecycleListener(listener);
            } catch (Throwable t) {
                ExceptionUtils.handleThrowable(t);
                log.error("createWrapper", t);
                return (null);
            }
        }
    }
    synchronized (wrapperListenersLock) {
        for (int i = 0; i < wrapperListeners.length; i++) {
            try {
                Class<?> clazz = Class.forName(wrapperListeners[i]);
                ContainerListener listener = (ContainerListener) clazz.newInstance();
                wrapper.addContainerListener(listener);
            } catch (Throwable t) {
                ExceptionUtils.handleThrowable(t);
                log.error("createWrapper", t);
                return (null);
            }
        }
    }
    return (wrapper);
}
Also used : Wrapper(org.apache.catalina.Wrapper) ContainerListener(org.apache.catalina.ContainerListener) LifecycleListener(org.apache.catalina.LifecycleListener) SecurityConstraint(org.apache.tomcat.util.descriptor.web.SecurityConstraint)

Aggregations

ContainerListener (org.apache.catalina.ContainerListener)2 ArrayList (java.util.ArrayList)1 Container (org.apache.catalina.Container)1 LifecycleListener (org.apache.catalina.LifecycleListener)1 Wrapper (org.apache.catalina.Wrapper)1 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)1