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.eviware.soapui.impl.wsdl.monitor.jettyproxy.TunnelServlet.java

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

From source file:com.squid.kraken.v4.auth.ChangePasswordServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    // setup the//  www  .  ja  v  a  2s  .c om
    privateServerURL = (String) config.getServletContext().getAttribute("privateServerURL");
}

From source file:org.restcomm.sbc.ServiceLauncher.java

@Override
public void init(final ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
    if (LOG.isInfoEnabled()) {
        LOG.info(">> ServiceLauncher Servlet init()");
    }/*from   w  w w.j av  a 2  s . co m*/
    final ServletContext context = servletConfig.getServletContext();

    SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);

    Configuration configuration = (Configuration) context.getAttribute(Configuration.class.getName());

    Monitor monitor = Monitor.getMonitor();
    monitor.start(sipFactory, configuration);

}

From source file:org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet.java

public void init(ServletConfig config) throws ServletException {

    super.init(config);

    log.info("Initializing ResourceServlet");

    this.context = config.getServletContext();
}

From source file:org.efs.openreports.dispatcher.XMLADispatcher.java

public void init(ServletConfig servletConfig) throws ServletException {
    ApplicationContext appContext = WebApplicationContextUtils
            .getRequiredWebApplicationContext(servletConfig.getServletContext());

    directoryProvider = (DirectoryProvider) appContext.getBean("directoryProvider", DirectoryProvider.class);

    super.init(servletConfig);
}

From source file:org.pentaho.platform.web.servlet.ServletToBeanProxy.java

protected ApplicationContext getContext(final ServletConfig config) {
    return WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
}

From source file:com.liferay.arquillian.DeployerServlet.java

private InputStream getUploadedBundleInputStream(HttpServletRequest request)
        throws FileUploadException, IOException {

    DiskFileItemFactory factory = new DiskFileItemFactory();

    ServletConfig servletConfig = this.getServletConfig();

    ServletContext servletContext = servletConfig.getServletContext();

    File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir");

    factory.setRepository(repository);//from  ww  w.  j a  va2 s.c  o m

    ServletFileUpload upload = new ServletFileUpload(factory);

    List<FileItem> items = upload.parseRequest(request);

    FileItem fileItem = items.get(0);

    return fileItem.getInputStream();
}

From source file:org.efs.openreports.services.servlet.ReportServiceServlet.java

public void init(ServletConfig servletConfig) throws ServletException {
    ApplicationContext appContext = WebApplicationContextUtils
            .getRequiredWebApplicationContext(servletConfig.getServletContext());

    reportService = (ReportService) appContext.getBean("reportService", ReportService.class);

    //cache ServletReportServiceInput PropertyDescriptors
    descriptors = PropertyUtils.getPropertyDescriptors(ServletReportServiceInput.class);

    super.init(servletConfig);

    log.info("Started...");
}

From source file:org.wso2.carbon.email.verification.ui.clients.EmailVerificationServiceClient.java

public EmailVerificationServiceClient(ServletConfig config, HttpSession session) throws RegistryException {

    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
    ConfigurationContext configContext = (ConfigurationContext) config.getServletContext()
            .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
    epr = backendServerURL + "EmailVerificationService";

    try {/*  w w  w  .j  a  v a 2 s  .com*/
        stub = new EmailVerificationServiceStub(configContext, epr);

        ServiceClient client = stub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

    } catch (AxisFault axisFault) {
        String msg = "Failed to initiate Add Services service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}

From source file:ro.cs.ts.start.InitApplication.java

/**
 * Initializarea contextului. Aici se preiau nomenclatoarele ce se vor
 * pastra pe sesiune//  w w w . j a  v a 2s .c  om
 */
public void init(ServletConfig conf) throws ServletException {
    logger.info("Initializare aplicatie...");

    try {

        ServletContext sc = conf.getServletContext();
        logger.info("*******************************************************");
        logger.info("*                                                     *");
        logger.info("*        INITIATING APPLICATION TIME SHEET->          *");
        logger.info("*                                                     *");
        logger.info("*******************************************************");
        logger.info(IConstant.APP_VERSION.concat("/").concat(IConstant.APP_RELEASE_DATE));
        sc.setAttribute("VERSION", IConstant.APP_VERSION);
        sc.setAttribute("RELEASE_DATE", IConstant.APP_RELEASE_DATE);
        sc.setAttribute("RELEASE_YEAR", IConstant.APP_RELEASE_YEAR);

        //Nomenclators         

        // RESULTS PER PAGE
        ListLoader.getInstance().load_nom_resultsPerPage();

        // PROJECT
        ListLoader.getInstance().load_nom_projectStatus();

        //BILLABLE
        ListLoader.getInstance().load_nom_billable();

        // TIME UNIT
        ListLoader.getInstance().load_nom_timeUnit();

        //SUPPORTED LANGUAGES
        ListLoader.getInstance().load_nom_supportedLanguages();

        //REPORT SUBTOTAL INTERVAL
        ListLoader.getInstance().load_nom_reportSubtotalInterval();

        //REPORT SUBTOTAL INTERVAL
        ListLoader.getInstance().load_nom_pricesComputeType();

        //REPORT PARAMS MAP
        TSContext.storeOnContext(IConstant.REPORT_PARAM_MAP, new HashMap<String, ReportParams>());

        RoleVoter rv = (RoleVoter) TSContext.getApplicationContext().getBean("roleVoter");

        // put exceptionContant bean on servletContect
        sc.setAttribute(IConstant.EXCEPTION_CONSTANT, ExceptionConstant.getInstance());
        sc.setAttribute(IConstant.PERMISSION_CONSTANT, PermissionConstant.getInstance());
        sc.setAttribute(IConstant.BACK_CONSTANT, BackConstant.getInstance());

        logger.info("Role Prefix: \"" + rv.getRolePrefix() + "\"");
        logger.info("*******************************************************");
        logger.info("*                                                     *");
        logger.info("*       INITIATING APPLICATION END TIME SHEET<-       *");
        logger.info("*                                                     *");
        logger.info("*******************************************************");

    } catch (Exception ex) {
        logger.info("*******************************************************");
        logger.info("*                                                     *");
        logger.info("*        ERROR INITIATING APPLICATION!!!              *");
        logger.info("*                                                     *");
        logger.info("*******************************************************");
        logger.error("", ex);
    }
    logger.info("The application was initiated!");
}