Example usage for javax.servlet ServletContextEvent getServletContext

List of usage examples for javax.servlet ServletContextEvent getServletContext

Introduction

In this page you can find the example usage for javax.servlet ServletContextEvent getServletContext.

Prototype

public ServletContext getServletContext() 

Source Link

Document

Return the ServletContext that changed.

Usage

From source file:net.sourceforge.vulcan.web.VulcanContextListener.java

public void contextInitialized(ServletContextEvent event) {
    final ServletContext context = event.getServletContext();

    wac = WebApplicationContextUtils.getRequiredWebApplicationContext(context);

    stateManager = (StateManager) wac.getBean(Keys.STATE_MANAGER, StateManager.class);

    context.setAttribute(Keys.STATE_MANAGER, stateManager);
    context.setAttribute(Keys.EVENT_POOL, wac.getBean(Keys.EVENT_POOL));
    context.setAttribute(Keys.BUILD_OUTCOME_STORE, wac.getBean(Keys.BUILD_OUTCOME_STORE));

    JstlFunctions.setWebApplicationContext(wac);
    XslHelper.setWebApplicationContext(wac);

    try {//from  w w w.j a  v a 2 s.com
        stateManager.start();
    } catch (Exception e) {
        final EventHandler eventHandler = (EventHandler) wac.getBean(Keys.EVENT_HANDLER, EventHandler.class);

        eventHandler
                .reportEvent(new ErrorEvent(this, "errors.load.failure", new String[] { e.getMessage() }, e));
    }
}

From source file:edu.cornell.mannlib.vivo.orcid.OrcidContextSetup.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    ServletContext ctx = sce.getServletContext();
    ConfigurationProperties props = ConfigurationProperties.getBean(ctx);
    StartupStatus ss = StartupStatus.getBean(ctx);

    if (props.getProperty("orcid.clientId", "").isEmpty()) {
        ss.info(this, "ORCID Integration is not configured.");
        return;/*from   ww  w .j  a va  2  s. c  o  m*/
    }

    initializeOrcidClientContext(props, ss);

    checkForCommonNameProperty(props, ss);
}

From source file:nl.b3p.kaartenbalie.service.MapFileScanner.java

public void contextInitialized(ServletContextEvent sce) {
    try {//from w ww .jav  a 2s.  c o m
        this.context = sce.getServletContext();
        init();

        fsManager = VFS.getManager();

        listendir = fsManager.resolveFile(scandirectory);
        fm = new DefaultFileMonitor(new MapFileListener(organization));
        fm.setRecursive(true);
        fm.addFile(listendir);
        fm.start();

    } catch (FileSystemException ex) {
        log.error("Cannot initialize MapFileScanner: ", ex);
    }
}

From source file:darks.grid.web.GridContextListener.java

@Override
public void contextInitialized(ServletContextEvent ctx) {
    if (isSpringValid())
        GridSpringContext.loadContext(ctx.getServletContext());
    String configPath = ctx.getServletContext().getInitParameter("configPath");
    if (configPath == null || "".equals(configPath.trim()))
        configPath = DEFAULT_CONFIG_PATH;
    else/*w w  w  .j a  v  a  2s . co  m*/
        configPath = configPath.trim();
    GridConfiguration config = GridConfigFactory.configure(this.getClass().getResourceAsStream(configPath));
    GridRuntime.initialize(config);
}

From source file:gov.nih.nci.caintegrator.application.configuration.ConfigurationListener.java

public void contextInitialized(final ServletContextEvent servletContextEvent) {
    super.contextInitialized(servletContextEvent);
    SpringContext.initialize(servletContextEvent.getServletContext());
}

From source file:jp.primecloud.auto.ui.mock.MockBeanContext.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    String param = sce.getServletContext().getInitParameter("mockMode");
    mockMode = BooleanUtils.toBoolean(param);

    if (mockMode) {
        new BeanContext().setApplicationContext(createMockContext());
    } else {//from   ww w.  ja v  a2 s  . c  o  m
        contextLoaderListener.contextInitialized(sce);
    }
}

From source file:net.kamhon.ieagle.application.JContextLoaderListener.java

public void contextInitialized(final ServletContextEvent servletContextEvent) {
    super.contextInitialized(servletContextEvent);
    Application.initialize(servletContextEvent.getServletContext());
}

From source file:edu.cornell.mannlib.vitro.webapp.servlet.setup.ModelMakerSetup.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    ServletContext ctx = sce.getServletContext();
    StartupStatus ss = StartupStatus.getBean(ctx);

    createConfigurationModelMaker(ctx);/*ww  w  . ja  v  a2  s.c o  m*/
    createContentModelMaker(ctx);

    ss.info(this, "Created model makers.");
}

From source file:com.netspective.sparx.util.ApplicationEventsListener.java

public void contextDestroyed(ServletContextEvent event) {
    log.trace("Destroying context " + event.getServletContext().getServletContextName());

    Set connContextsWithOpenConnections = new HashSet(
            AbstractConnectionContext.getConnectionContextsWithOpenConnections());
    for (Iterator i = connContextsWithOpenConnections.iterator(); i.hasNext();) {
        ConnectionContext cc = (ConnectionContext) i.next();

        // if the cc is bound to a session, it will be cleaned up when session is closed if requested
        if (!cc.isBoundToSession()) {
            if (cc instanceof HttpSessionBindableConnectionContext) {
                HttpSessionBindableConnectionContext bindableCC = (HttpSessionBindableConnectionContext) cc;
                if (!bindableCC.isCloseOnSessionUnbind())
                    cc.rollbackAndCloseAndLogAsConnectionLeak(log,
                            "** Connection leak detected: connection is marked as a sending bound CC but is not set to automatically close when unbound.");
            }//  www  .j  a  va  2s.com
        } else
            cc.rollbackAndCloseAndLogAsConnectionLeak(log, null);
    }

    HtmlTabularReportDataSourceScrollStatesManager.closeAllScrollStates(log);
}

From source file:com.bekk.boss.pluto.embedded.jetty.util.OverrideContextLoaderListener.java

public void contextInitialized(ServletContextEvent sce) {
    SContext servletContext = (SContext) sce.getServletContext();
    ContextHandler contextHandler = servletContext.getContextHandler();
    Map initParams = contextHandler.getInitParams();
    String configLocations = (String) initParams.get(ContextLoader.CONFIG_LOCATION_PARAM);
    if (configLocations != null) {
        configLocations = configLocations + " " + PLUTO_SERVICE_CONFIG_LOCATION;
        initParams.put(ContextLoader.CONFIG_LOCATION_PARAM, configLocations);
    } else {/*from www  .ja  v  a 2 s .c  o  m*/
        initParams.put(ContextLoader.CONFIG_LOCATION_PARAM, PLUTO_SERVICE_CONFIG_LOCATION);
    }
    // Traverse listeners to see if there's a configured
    // ContextLoaderListener
    EventListener[] listeners = contextHandler.getEventListeners();
    if (listeners != null) {
        List newListenerList = new ArrayList();
        for (int i = 0; i < listeners.length; i++) {
            EventListener listener = listeners[i];
            if (!(listener instanceof ContextLoaderListener)) {
                newListenerList.add(listener);
            }
        }
        contextHandler.setEventListeners(
                (EventListener[]) newListenerList.toArray(new EventListener[newListenerList.size()]));
    }
    contextLoaderListener.contextInitialized(sce);
}