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.wso2.carbon.governance.wsdltool.ui.clients.WSDLToolServiceClient.java

public WSDLToolServiceClient(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 + "WSDLToolService";

    try {//from w  w w . j  a  va  2  s.  co m
        stub = new WSDLToolServiceStub(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 wsdltool service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}

From source file:org.seasar.dwr.servlet.S2DwrServlet.java

public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
    ServletContext servletContext = servletConfig.getServletContext();

    try {//from ww  w.ja v  a  2 s.  c  o m
        // setupLogging() only needed for servlet logging if commons-logging
        // is unavailable
        // logStartup() just outputs some version numbers
        StartupUtil.setupLogging(servletConfig, this);
        StartupUtil.logStartup(servletConfig);

        // create and setup a DefaultContainer
        container = ContainerUtil.createDefaultContainer(servletConfig);
        // ContainerUtil.setupDefaultContainer(container, servletConfig);
        ContainerUtil.setupDefaults(container, servletConfig);
        container.addParameter(HtmlCallMarshaller.class.getName(), S2HtmlCallMarshaller.class.getName());
        container.addParameter(PlainCallMarshaller.class.getName(), S2PlainCallMarshaller.class.getName());
        ContainerUtil.setupFromServletConfig(container, servletConfig);
        container.setupFinished();

        webContextBuilder = StartupUtil.initWebContext(servletConfig, servletContext, container);
        StartupUtil.initServerContext(servletConfig, servletContext, container);

        ContainerUtil.prepareForWebContextFilter(servletContext, servletConfig, container, webContextBuilder,
                this);
        ContainerUtil.configureContainerFully(container, servletConfig);
        ContainerUtil.publishContainer(container, servletConfig);
    } catch (ExceptionInInitializerError ex) {
        log.fatal("ExceptionInInitializerError. Nested exception:", ex.getException());
        throw new ServletException(ex);
    } catch (Exception ex) {
        log.fatal("DwrServlet.init() failed", ex);
        throw new ServletException(ex);
    } finally {
        if (webContextBuilder != null) {
            webContextBuilder.unset();
        }

        ServletLoggingOutput.unsetExecutionContext();
    }
}

From source file:org.wso2.carbon.registry.samples.custom.topics.ui.clients.TopicServiceClient.java

public TopicServiceClient(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 + "RegistryTopicAdminService";

    try {//from  w w  w  . j  a  va2  s  . c o  m
        stub = new RegistryTopicAdminServiceStub(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 topic service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}

From source file:com.dien.upload.server.UploadAction.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    ServletContext ctx = config.getServletContext();
    removeSessionFiles = "true".equalsIgnoreCase(ctx.getInitParameter("removeSessionFiles"));
    removeData = "true".equalsIgnoreCase(ctx.getInitParameter("removeData"));

    logger.info("UPLOAD-ACTION init: removeSessionFiles=" + removeSessionFiles + ", removeData=" + removeData);
}

From source file:nl.nn.adapterframework.webcontrol.DumpIbisConsole.java

public void init(ServletConfig config) {
    servletContext = config.getServletContext();
}

From source file:org.apache.stratos.throttling.ui.clients.ThrottlingRuleEditorClient.java

public ThrottlingRuleEditorClient(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 + "ThrottlingRuleEditorService";

    try {/*  w ww  . j  av a2s  .  co m*/
        stub = new ThrottlingRuleEditorServiceStub(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 throttling rule editor service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}

From source file:org.eclipse.virgo.management.console.UploadServlet.java

/**
 * Do not use this method with the HTTPService unless the BundleContext has already been set.
 *///from   w  w w . j  a v  a 2 s.  co  m
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    if (bundleContext == null) {
        this.bundleContext = (BundleContext) config.getServletContext().getAttribute("osgi-bundlecontext");
    }
    this.serverHome = this.bundleContext.getProperty(ORG_ECLIPSE_VIRGO_KERNEL_HOME);
}

From source file:org.usergrid.rest.SwaggerServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    logger.info("init(ServletConfig config)");
    if (sc == null) {
        sc = config.getServletContext();
    }// w  w  w  .  ja va2s  . c  om
    properties = (Properties) getSpringBeanFromWeb("properties");
    loadSwagger();
}

From source file:com.bt.aloha.batchtest.ultramonkey.Servlet.java

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

    WebApplicationContext applicationContext = WebApplicationContextUtils
            .getRequiredWebApplicationContext(servletConfig.getServletContext());
    service = (Service) applicationContext.getBean("serviceBean");
    // check for a system property to set the Stack contact address
    if (null != System.getProperty("sip.stack.contact.address", null)) {
        SimpleSipStack simpleSipStack = (SimpleSipStack) applicationContext.getBean("simpleSipStack");
        simpleSipStack.setContactAddress(System.getProperty("sip.stack.contact.address"));
    }/* ww w. j a  v  a2s .  c  om*/
}

From source file:org.wso2.carbon.registry.profiles.ui.clients.ProfilesAdminServiceClient.java

public ProfilesAdminServiceClient(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 + "ProfilesAdminService";

    try {//  w  w  w  . ja va 2  s  .c  o m
        stub = new ProfilesAdminServiceStub(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 ProfilesAdmin service client. " + axisFault.getMessage();
        log.error(msg, axisFault);
        throw new RegistryException(msg, axisFault);
    }
}