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:com.github.gagu.web.util.Log4jConfigListener.java

@Override
public void contextInitialized(ServletContextEvent event) {
    Log4jWebConfigurer.initLogging(event.getServletContext());
    System.out.println("log4j is ok.");
}

From source file:net.duckling.falcon.api.mstatic.VersionStartupListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    ServletContext context = sce.getServletContext();
    String versionFile = context.getInitParameter("version-file");
    String fullpath = context.getRealPath(versionFile);
    try {/*from w  w w .j  a  va  2  s  .c  o m*/
        String version = FileUtils.readFileToString(new File(fullpath));
        if (version != null) {
            version = version.trim();
        } else {
            version = "N/A";
        }
        VersionAttributeHelper.setVersion(context, version);
    } catch (IOException e) {
        log.error("Reading version file failed.", e);
    }
}

From source file:com.github.cherimojava.orchidae.config.ServletListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    try {// ww w  .  jav a  2  s . c  o  m
        onStartup(sce.getServletContext());
    } catch (ServletException e) {
        LOG.fatal("Could not setup context, bailing out", e);
        System.exit(1);
    }
}

From source file:com.krawler.common.listeners.LocaleResolverBuilder.java

@Override
public void contextDestroyed(ServletContextEvent sce) {
    ServletContext context = sce.getServletContext();
    context.removeAttribute(LOCALE_RESOLVER_CLASS_NAME_ATTR);
}

From source file:com.bank.manager.configs.ContextCleanupListener.java

@Override
public void contextDestroyed(ServletContextEvent event) {
    cleanupAttributes(event.getServletContext());
}

From source file:com.github.gagu.web.util.Log4jConfigListener.java

@Override
public void contextDestroyed(ServletContextEvent event) {
    Log4jWebConfigurer.shutdownLogging(event.getServletContext());
}

From source file:org.sakaiproject.util.SakaiContextLoaderListener.java

/**
 * Initialize the root web application context.
 *///from  w w w .j a v  a2 s.c o  m
@Override
public void contextInitialized(ServletContextEvent event) {
    initWebApplicationContext(event.getServletContext());

    // increment the count of children for the component manager
    ((SpringCompMgr) ComponentManager.getInstance()).addChildAc();
}

From source file:edu.cornell.mannlib.oce.startup.StartupListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    ctx = sce.getServletContext();
    try {// w  w w .  j  ava  2 s. c  o  m
        readSettings();
        new LogFileAdjuster(settings).setupLogging();
        new OrcidClientSetup(settings).initialize();
        new FreemarkerSetup(ctx).initialize();
    } catch (Exception e) {
        log.error("Problem during startup", e);
        ctx.setAttribute(ATTRIBUTE_NAME, e);
    }
}

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

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

    DataSource bds = getApplicationDataSource(ctx);
    if (bds == null) {
        ss.fatal(this, "A DataSource must be setup before ModelSetup "
                + "is run. Make sure that JenaPersistentDataSourceSetup runs before " + "ModelSetup.");
        return;/*from w w w . j  a  v  a2 s .  c o m*/
    }

    setupUserAccountModel(bds, ctx, ss);
}

From source file:cn.vlabs.umt.ui.UMTStartupListener.java

public void contextDestroyed(ServletContextEvent event) {
    ServletContext context = event.getServletContext();
    FileSystemXmlApplicationContext factory = (FileSystemXmlApplicationContext) context
            .getAttribute(Attributes.APPLICATION_CONTEXT_KEY);
    if (factory != null) {
        context.removeAttribute(Attributes.APPLICATION_CONTEXT_KEY);
        factory.close();//from w  ww  . j  a  v  a  2  s  .  c  om
        factory = null;
    }
}