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:com.enonic.cms.web.webdav.SimpleDavServlet.java

public void init(final ServletConfig config) throws ServletException {
    final ServletContext servletContext = config.getServletContext();
    this.configuration = getConfiguration(servletContext);
    this.resourceRoot = configuration.getResourceRoot();

    setLocatorFactory(new DavLocatorFactoryImpl());
    setDavSessionProvider(new DavSessionProviderImpl(configuration));
    setResourceFactory(new DavResourceFactoryImpl(configuration));

    super.init(config);
}

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

public GovImpactAdminServiceClient(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 + "GovImpactAnalysisAdminService";

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

}

From source file:org.openempi.webapp.server.BlockingDataServiceImpl.java

public void init(ServletConfig config) throws ServletException {
    super.init(config);
    context = (ApplicationContext) config.getServletContext().getAttribute(WebappConstants.APPLICATION_CONTEXT);
}

From source file:de.qucosa.dissemination.epicur.servlet.EpicurDisseminationServlet.java

private String getParameterValue(ServletConfig config, String name) {
    String v = config.getServletContext().getInitParameter(name);
    if (v == null || v.isEmpty()) {
        v = System.getProperty(name);
    }/*from  w ww. j av a2  s. c  o  m*/
    return v;
}

From source file:adminpackage.adminview.UpdateProductServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    context = config.getServletContext();
    super.init(config); //To change body of generated methods, choose Tools | Templates.
    adminFacadeHandler = new AdminFacadeHandler();
}

From source file:org.apache.ambari.view.tez.ProxyServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    ServletContext context = config.getServletContext();
    ViewContext viewContext = (ViewContext) context.getAttribute(ViewContext.CONTEXT_ATTRIBUTE);
    this.urlConnectionProvider = viewContext.getURLConnectionProvider();
}

From source file:org.sakaiproject.tool.assessment.ui.servlet.StoreApplicationContext.java

public void init(ServletConfig config) throws ServletException {
    super.init(config);
    if (ctx == null) {
        ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
        //log.log("***context="+ctx);
        SpringBeanLocator.setApplicationContext(ctx);

        ContextUtil.setServletContext(config.getServletContext());
    }// ww  w .  j  a  va2 s . c  o m
}

From source file:io.github.benas.todolist.web.servlet.user.account.DeleteAccountServlet.java

@Override
public void init(ServletConfig servletConfig) throws ServletException {
    ApplicationContext applicationContext = WebApplicationContextUtils
            .getWebApplicationContext(servletConfig.getServletContext());
    userService = applicationContext.getBean(UserService.class);
}

From source file:net.felsing.client_cert.GetCountries.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    context = config.getServletContext().getRealPath("/WEB-INF/classes");
}

From source file:org.jboss.datagrid.LoadXMLServlet.java

public void init(ServletConfig config) throws ServletException {

    File folder;//from www. j  ava  2s. c  o m
    ServletContext ctx = config.getServletContext();
    folder = new File(ctx.getRealPath(Resources.xmlDataDir()));
    //folder = new File(Resources.xmlDataDir());
    logger.info("Using absolute path: " + folder.getAbsolutePath());
    File[] listOfFiles = folder.listFiles(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.toLowerCase().endsWith(".xml");
        }
    });

    if (listOfFiles == null || listOfFiles.length == 0)
        logger.info("Did not find any XML files in the " + Resources.jdgProperty(Resources.XML_DIRECTORY)
                + " directory");
    else {
        logger.info("Found " + listOfFiles.length + " files!");

        for (File file : listOfFiles) {
            if (file.isFile()) {
                //System.out.println(file.getName());
                try {
                    String content = FileUtils.readFileToString(file, "UTF-8");
                    logger.info("Putting contents from file " + file.getName()
                            + " into the cache, content length=" + content.length());
                    cache.put(file.getName(), content);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

    Set<String> set = cache.keySet();
    logger.info("Warming up the cache....");

    for (String key : set) {
        for (int i = 0; i < 1000; ++i)
            cache.get(key);
    }

}