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:grails.plugins.jaxrs.web.JaxrsListener.java

public void contextInitialized(ServletContextEvent event) {
    JaxrsContext jaxrsContext = JaxrsUtils.getRequiredJaxrsContext(event.getServletContext());
    jaxrsContext.setJaxrsServletContext(event.getServletContext());

    try {/*w  ww .j  a  v a 2  s .  c  om*/
        jaxrsContext.init();
    } catch (ServletException e) {
        LOG.error("Initialization of JAX-RS context failed", e);
    }
}

From source file:org.pentaho.platform.web.http.context.HsqldbStartupListener.java

public void contextDestroyed(ServletContextEvent sce) {
    ServletContext ctx = sce.getServletContext();
    Object obj = ctx.getAttribute("hsqldb-starter-bean"); //$NON-NLS-1$
    if (obj != null) {
        logger.debug("Context listener stopping Embedded HSQLDB"); //$NON-NLS-1$
        HsqlDatabaseStarterBean starterBean = (HsqlDatabaseStarterBean) obj;
        starterBean.stop();/* www . java 2 s  .c  o  m*/
    }
}

From source file:de.ingrid.iplug.web.BusClientContextListener.java

public void contextInitialized(ServletContextEvent servletcontextevent) {
    ServletContext servletContext = servletcontextevent.getServletContext();
    String communicationFile = servletContext.getInitParameter("communication.xml");
    BusClient busClient = null;//  www.  java  2  s  .  com
    try {
        busClient = connectIBus(communicationFile);
        BeanFactory beanFactory = (BeanFactory) servletContext.getAttribute("beanFactory");
        beanFactory.addBean("busClient", busClient);
    } catch (Exception e1) {
        LOG.error("can not connect to ibus", e1);
    }

}

From source file:org.sonar.server.configuration.ConfigurationFactory.java

protected String autodetectWebappDeployDirectory(ServletContextEvent sce) {
    String webAppPublicDirPath = sce.getServletContext().getRealPath("/deploy/");
    if (webAppPublicDirPath == null) {
        throw new ConfigurationException("Web app directory not found : /deploy/");
    }/*from  w w  w . ja  va  2s .com*/
    File file = new File(webAppPublicDirPath);
    if (!file.exists()) {
        throw new ConfigurationException("Web app directory not found : " + file);
    }
    return file.toString();
}

From source file:com.fatwire.gst.web.status.StatusRequestListener.java

public void contextInitialized(ServletContextEvent sce) {
    String n = sce.getServletContext().getContextPath();
    if (n == null || n.length() == 0) {
        n = "/";//from  w ww.  j ava  2  s . c  o m
    }

    requestCounter = new RequestCounter(n);
    ConcurrencyCounter<?, ?> old = ConcurrencyCounterLocator.getInstance().register(requestCounter);
    if (old != null) {
        requestCounter = (RequestCounter) old;
    }
    try {
        name = new ObjectName("com.fatwire.gst.web:type=RequestCounter,name=" + ObjectName.quote(n));
        ManagementFactory.getPlatformMBeanServer().registerMBean(new StatusCounter(requestCounter), name);
    } catch (Throwable e) {
        log.warn(e.getMessage(), e);
    }

}

From source file:org.apache.myfaces.webapp.StartupServletContextListener.java

public void contextInitialized(ServletContextEvent event) {
    initFaces(event.getServletContext());
}

From source file:org.guzz.web.context.ContextLoaderListener.java

public void contextDestroyed(ServletContextEvent event) {
    if (context != null) {
        context.shutdown(event.getServletContext());

        context = null;//from www . ja  v a 2 s. com
    }
}

From source file:com.ning.jetty.core.listeners.SetupServer.java

/**
 * This method can be called by classes extending SetupServer to retrieve
 * the actual injector. This requires some inside knowledge on where it is
 * stored, but the actual key is not visible outside the guice packages.
 *///from w w  w.java  2 s  .c  om
public Injector injector(final ServletContextEvent event) {
    return (Injector) event.getServletContext().getAttribute(Injector.class.getName());
}

From source file:com.athena.sqs.MessageDispatchListener.java

public void contextInitialized(ServletContextEvent sce) {
    ServletContext servletContext = sce.getServletContext();
    sqsConfigLocation = servletContext.getInitParameter("sqsConfigLocation");

    String realPath = servletContext.getRealPath(sqsConfigLocation);
    if (logger.isDebugEnabled()) {
        logger.debug("****************** SQS Config ******************");
        logger.debug("LOCATION : " + sqsConfigLocation);
        logger.debug("REAL LOCATION : " + realPath);
        logger.debug("************************************************");
    }//from  w  w  w .j av a  2  s.  c  om

    ApplicationContext applicationContext = (ApplicationContext) servletContext
            .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    // TODO : You can load your own application config here
}

From source file:org.os890.ds.addon.spring.impl.bidirectional.WebappAwareSpringContainerManager.java

@Override
public void contextDestroyed(ServletContextEvent sce) {
    springContextLoader.closeWebApplicationContext(sce.getServletContext());
}