Example usage for javax.servlet ServletConfig getServletContext

List of usage examples for javax.servlet ServletConfig getServletContext

Introduction

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

Prototype

public ServletContext getServletContext();

Source Link

Document

Returns a reference to the ServletContext in which the caller is executing.

Usage

From source file:org.apache.ambari.servicemonitor.reporting.restapi.RestStatusServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    try {/*from  w w  w . ja va2  s  .  co  m*/
        super.init(config);
        ctx = config.getServletContext();
        owner = (RestReporter) ctx.getAttribute(RestServer.OWNER);
    } catch (ServletException e) {
        throw e;
    } catch (Exception e) {
        throw new ServletException(e);
    }
}

From source file:org.wso2.carbon.governance.gadgets.ui.ResourceImpactAdminClient.java

public ResourceImpactAdminClient(ServletConfig config, HttpSession session, HttpServletRequest request)
        throws AxisFault {
    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
    ConfigurationContext configContext = (ConfigurationContext) config.getServletContext()
            .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);

    String serviceURL = backendServerURL + "ResourceImpactAdminService";

    stub = new ResourceImpactAdminServiceStub(configContext, serviceURL);
    ServiceClient client = stub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);/*  w  ww .j  av  a 2s .c o m*/
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

}

From source file:com.rabidgremlin.onepagewebstarter.guice.CxfGuiceServlet.java

@Override
protected Map<Class<?>, ResourceProvider> getResourceProviders(ServletConfig servletConfig,
        Map<Class<?>, Map<String, List<String>>> resourceClasses) throws ServletException {
    Injector injector = (Injector) servletConfig.getServletContext().getAttribute(Injector.class.getName());

    Map<Class<?>, ResourceProvider> providers = new HashMap<Class<?>, ResourceProvider>();
    for (Map.Entry<Class<?>, Map<String, List<String>>> entry : resourceClasses.entrySet()) {
        Class<?> cls = entry.getKey();
        providers.put(cls, new SingletonResourceProvider(injector.getInstance(cls)));
    }//w  w w .  ja  v  a2s.co m

    return providers;
}

From source file:org.raptorjs.templating.rhino.servlet.RaptorTemplatesServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    this.config = config;
    this.context = config.getServletContext();

}

From source file:org.artifactory.rest.servlet.ArtifactoryRestServlet.java

@SuppressWarnings({ "unchecked" })
@Override/*from ww w. j a v a2s  .c  o  m*/
public void init(ServletConfig config) throws ServletException {
    this.config = config;
    BlockingQueue<Filter> waiters = (BlockingQueue<Filter>) config.getServletContext()
            .getAttribute(APPLICATION_CONTEXT_LOCK_KEY);
    if (waiters != null) {
        waiters.add(this);
    } else {
        //Servlet 2.5 lazy filter initing
        delayedInit();
    }
    // register the bean utils converter to fail if encounters a type mismatch between the destination
    // and the original, see RTFACT-3610
    BeanUtilsBean instance = BeanUtilsBean2.getInstance();
    instance.getConvertUtils().register(true, false, 0);
}

From source file:com.afspq.web.ProcessQuery.java

public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {/*w  w  w  . j  a  va 2  s  .  c  om*/
        fullTextSearch = new Search(config.getServletContext(), SearcherModule.FULL_TEXT_INDEX);
        imageSearch = new Search(config.getServletContext(), SearcherModule.IMAGE_INDEX);
    } catch (Exception ex) {
        System.out.println(new Date().toString() + "\nABORT: Servlet initialization failed.");
        System.exit(1);
    }
}

From source file:org.kani.spring.ApplicationServlet.java

@SuppressWarnings("unchecked")
@Override// w  ww .j a v  a2s.  com
public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);

    applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletConfig.getServletContext());
    if (!applicationContext.containsBean(APPLICATION_BEAN_NAME)) {
        throw new IllegalStateException("No application bean with name " + APPLICATION_BEAN_NAME + " found.");
    }

    if (!applicationContext.isTypeMatch(APPLICATION_BEAN_NAME, Application.class)) {
        Object applicationBean = applicationContext.getBean(APPLICATION_BEAN_NAME);
        throw new IllegalStateException(
                String.format("Application bean has type %s but should be a subtype of %s.",
                        applicationBean.getClass().getName(), Application.class.getName()));
    }
    applicationClass = (Class<? extends Application>) applicationContext.getType(APPLICATION_BEAN_NAME);
}

From source file:com.sap.dirigible.runtime.content.ContentInitializerServlet.java

private void checkAndImportRegistry(ServletConfig config, String user) throws IOException {
    String path = config.getServletContext().getRealPath(PATH_REGISTRY_ROOT_SOURCE);
    File root = new File(path);
    logger.debug("root: " + root.getCanonicalPath().replace('\\', '/')); //$NON-NLS-1$
    if (root.exists() && root.isDirectory()) {
        File[] files = root.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File folder = files[i];
                checkAndImportFileOrFolder(root.getCanonicalPath().length(), folder, user);
            }/*  w w  w .j a  v  a  2  s .com*/
        }
    } else {
        throw new IOException(CONTENT_INITIALIZATION_FAILED + path);
    }
}

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

public void init(ServletConfig servletConfig) throws ServletException {
    //Check, if ServletContextListener already called
    ServletContext servletContext = servletConfig.getServletContext();
    Boolean b = (Boolean) servletContext
            .getAttribute(org.apache.myfaces.webapp.StartupServletContextListener.FACES_INIT_DONE);
    if (b == null || b.booleanValue() == false) {
        log.warn("ServletContextListener not yet called");
        org.apache.myfaces.webapp.StartupServletContextListener.initFaces(servletConfig.getServletContext());
    }/*  www . j ava2 s . c o m*/
    delegate.init(servletConfig);
    log.info("MyFacesServlet for context '" + servletConfig.getServletContext().getRealPath("/")
            + "' initialized.");
}

From source file:com.solab.alarms.servlet.AlarmServlet.java

public void init(ServletConfig config) throws ServletException {
    super.init(config);
    WebApplicationContext ctxt = WebApplicationContextUtils
            .getWebApplicationContext(config.getServletContext());
    sender = ctxt.getBean(AlarmSenderImpl.class);
    auth = ctxt.getBean(PasswordVerifier.class);
}