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.stratos.validate.domain.ui.clients.ValidateDomainAdminClient.java

public ValidateDomainAdminClient(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 + "ValidateDomainAdminService";

    try {/* w  w w  .j  a v  a 2 s  . c o  m*/
        stub = new ValidateDomainAdminServiceStub(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:org.apache.stratos.validate.domain.ui.clients.ValidateDomainNonAdminClient.java

public ValidateDomainNonAdminClient(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 + "ValidateDomainService";

    try {// w  w w. ja  va2 s  .com
        stub = new ValidateDomainServiceStub(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:com.tenduke.example.scribeoauth.oauth2.OAuth20CallbackServlet.java

/**
 * Initializes this servlet by reading OAuth configuration from file WEB-INF/oauth20.json.
 * @param config Servlet configuration.//w  ww.  ja v  a2 s .c  o m
 * @throws ServletException For errors during init.
 */
@Override
public void init(final ServletConfig config) throws ServletException {
    //
    super.init(config);
    //
    oauthConfig = readConfiguration("oauth20.json", config.getServletContext());
    provider = new OAuth20Provider(oauthConfig);
}

From source file:org.wso2.carbon.governance.list.ui.clients.ListMetadataServiceClient.java

public ListMetadataServiceClient(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 + "ListMetadataService";

    try {//  w w w. ja  v a2  s. c o  m
        stub = new ListMetadataServiceStub(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:org.wso2.stratos.esb.login.ui.clients.TenantServiceClient.java

public TenantServiceClient(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 + "TenantConfigService";

    try {/*from  www  . jav a  2 s.com*/
        stub = new TenantConfigServiceStub(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:org.apache.stratos.tenant.mgt.ui.clients.TenantServiceClient.java

public TenantServiceClient(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);
    String epr = backendServerURL + "TenantMgtAdminService";

    try {//from  w  ww .  ja  v a 2  s. co  m
        stub = new TenantMgtAdminServiceStub(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:org.sakaiproject.search.tool.ControllerServlet.java

public void init(ServletConfig servletConfig) throws ServletException {

    super.init(servletConfig);

    ServletContext sc = servletConfig.getServletContext();

    wac = WebApplicationContextUtils.getWebApplicationContext(sc);
    try {/*w  w  w. j ava  2s .  c  o  m*/
        searchBeanFactory = (SearchBeanFactory) wac.getBean("search-searchBeanFactory");
        ServletContext context = getServletContext();
        searchBeanFactory.setContext(context);
    } catch (Exception ex) {
        int x = 1; //ignore
    }
    if (sessionManager == null) {
        sessionManager = (SessionManager) wac.getBean(SessionManager.class.getName());
    }

}

From source file:org.wso2.carbon.mediation.templates.ui.EndpointTemplateAdminClient.java

public EndpointTemplateAdminClient(ServletConfig config, HttpSession session) 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 + "EndpointTemplateAdminService";
    endpointTemplateAdminStub = new EndpointTemplateAdminServiceStub(configContext, serviceURL);
    ServiceClient client = endpointTemplateAdminStub._getServiceClient();
    Options option = client.getOptions();
    option.setManageSession(true);/*from w ww. ja  va2 s.c  o  m*/
    option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);

}

From source file:com.ifactory.service.weather.photo.PhotoServlet.java

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

    try {/*  w ww  . j  a  va 2s.  c om*/
        InputStream is = conf.getServletContext().getResourceAsStream("/WEB-INF/photo.properties");
        Properties props = new Properties();
        props.load(is);
        dbHost = props.getProperty("dbhost");
        dbPort = Integer.parseInt(props.getProperty("dbport"));
        dbName = props.getProperty("database");
        photoHost = props.getProperty("photo_origin");
    } catch (IOException e) {
        // Log exception
    }

    try {
        this.photo = new PhotoService(dbHost, dbPort, dbName, photoHost);
    } catch (UnknownHostException e) {
        // Log this exception....
    } finally {
    }
}

From source file:dk.clarin.tools.rest.register.java

public void init(ServletConfig config) throws ServletException {
    InputStream fis = config.getServletContext().getResourceAsStream("/WEB-INF/classes/properties.xml");
    ToolsProperties.readProperties(fis);
    BracMat = new bracmat(ToolsProperties.bootBracmat);
    super.init(config);
}