Example usage for javax.servlet ServletContextListener getClass

List of usage examples for javax.servlet ServletContextListener getClass

Introduction

In this page you can find the example usage for javax.servlet ServletContextListener getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:edu.cornell.mannlib.vitro.webapp.startup.StartupManager.java

/**
 * Call contextInitialized() on the listener.
 * // w  w  w .j  a va2s .com
 * If there is an unexpected exception, set a fatal error.
 */
private void initialize(ServletContextListener listener, ServletContextEvent sce) {
    try {
        log.debug("Initializing '" + listener.getClass().getName() + "'");
        listener.contextInitialized(sce);
        ss.listenerExecuted(listener);
    } catch (Exception e) {
        ss.fatal(listener, "Threw unexpected exception", e);
    } catch (Throwable t) {
        log.fatal(listener + " Threw unexpected error", t);
        throw t;
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.startup.StartupManager.java

/**
 * Notify the listeners that the context is being destroyed, in the reverse
 * order from how they were notified at initialization.
 *///from w w w.  j  a v  a  2 s  . c  o m
@Override
public void contextDestroyed(ServletContextEvent sce) {
    List<ServletContextListener> destroyList = new ArrayList<ServletContextListener>(initializeList);
    Collections.reverse(destroyList);

    for (ServletContextListener listener : destroyList) {
        try {
            log.debug("Destroying '" + listener.getClass().getName() + "'");
            listener.contextDestroyed(sce);
        } catch (Exception e) {
            log.error("Unexpected exception from contextDestroyed() on '" + listener.getClass().getName() + "'",
                    e);
        } catch (Throwable t) {
            log.fatal("Unexpected error from contextDestroyed() on '" + listener.getClass().getName() + "'", t);
            throw t;
        }
    }
    log.info("Called 'contextDestroyed' on all listeners.");
}

From source file:edu.cornell.mannlib.vitro.webapp.startup.StartupManager.java

/**
 * If we have more than one listener from the same class, set a fatal error.
 *//*from   w  w w . jav a 2  s.  c o  m*/
private void checkForDuplicateListeners() {
    for (int i = 0; i < initializeList.size(); i++) {
        for (int j = i + 1; j < initializeList.size(); j++) {
            ServletContextListener iListener = initializeList.get(i);
            ServletContextListener jListener = initializeList.get(j);
            if (iListener.getClass().equals(jListener.getClass())) {
                ss.fatal(this,
                        ("File contains duplicate listener classes: '" + iListener.getClass().getName() + "'"));
            }
        }
    }
}