List of usage examples for javax.servlet ServletConfig getServletContext
public ServletContext getServletContext();
From source file:org.jdesktop.wonderland.artupload.FileUploadServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); try {/* w ww.j av a 2 s .c o m*/ File fileDir = Util.getShareDir(config.getServletContext()); if (!fileDir.exists()) { fileDir.mkdirs(); } logger.info("File directory is " + fileDir.getCanonicalPath()); } catch (IOException ioe) { throw new ServletException(ioe); } }
From source file:org.wso2.carbon.registry.resource.ui.clients.CustomUIServiceClient.java
public CustomUIServiceClient(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 + "CustomUIAdminService"; try {// www.jav a 2s . c o m stub = new CustomUIAdminServiceStub(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 custom UI service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:org.wso2.carbon.governance.notifications.ui.clients.InfoAdminServiceClient.java
public InfoAdminServiceClient(String cookie, ServletConfig config, HttpSession session) throws RegistryException { String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); epr = backendServerURL + "InfoAdminService"; try {// w ww . j a va 2 s. c o m stub = new InfoAdminServiceStub(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 comment service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:org.appcelerator.transport.DownloadTransportServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); if (this.embeddedMode) { AnnotationHelper.initializeAnnotationDBFromClasspath(); } else {/*w w w .j a va 2 s. c om*/ AnnotationHelper.initializeAnnotationDBFromServlet(config.getServletContext()); } ServiceRegistry.intialize(config.getServletContext()); }
From source file:org.wso2.carbon.registry.reporting.ui.clients.ReportGeneratorClient.java
public ReportGeneratorClient(HttpServletRequest request, ServletConfig config) { HttpSession session = request.getSession(); 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 + "ReportingAdminService"; try {/*from w w w . j a va 2 s.c o m*/ stub = new ReportingAdminServiceStub(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 e) { log.error("Failed to initiate report generator client.", e); } }
From source file:net.sourceforge.happybank.control.BaseServlet.java
/** * Initialise spring application context and facade. * @param config servlet config/*from w ww . ja v a 2 s .c om*/ * @throws ServletException on error */ public void init(ServletConfig config) throws ServletException { super.init(config); // load Spring framework Web context WebApplicationContext wac = WebApplicationContextUtils .getRequiredWebApplicationContext(config.getServletContext()); // set banking facade bank = (BankingFacade) wac.getBean("bankManager"); }
From source file:org.wso2.carbon.governance.custom.lifecycles.history.ui.clients.LifecycleServiceClient.java
public LifecycleServiceClient(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 + "CustomLifecyclesChecklistAdminService"; try {/* w w w. j a v a2s . c om*/ stub = new CustomLifecyclesChecklistAdminServiceStub(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 history service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:egovframework.rte.itl.webservice.EgovWebServiceServlet.java
public void loadBus(ServletConfig servletConfig) throws ServletException { super.loadBus(servletConfig); LOG.debug("EgovWebServiceServlet loadBus"); ApplicationContext applicationContext = WebApplicationContextUtils .getWebApplicationContext(servletConfig.getServletContext()); if (applicationContext == null) { LOG.error("applicationContext is null"); return;/*from w w w . j a v a 2s .co m*/ } EgovWebServiceContext context = null; try { context = (EgovWebServiceContext) applicationContext.getBean("egovWebServiceContext", EgovWebServiceContext.class); } catch (BeansException e) { LOG.error("Cannot get EgovWebServiceContext", e); return; } context.publishServer(bus); }
From source file:com.tenduke.example.scribeoauth.oauth10a.OAuth10aCallbackServlet.java
/** * Initializes this servlet by reading OAuth configuration from file WEB-INF/oauth10a.json. * @param config Servlet configuration.//w w w . j av a 2 s .c o m * @throws ServletException For errors during init. */ @Override public void init(final ServletConfig config) throws ServletException { // super.init(config); // oauthConfig = readConfiguration("oauth10a.json", config.getServletContext()); provider = new OAuth10aProvider(oauthConfig); }
From source file:org.apache.stratos.usage.ui.clients.UsageServiceClient.java
public UsageServiceClient(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 + "UsageService"; try {// w ww . j a va 2 s .c o m stub = new UsageServiceStub(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 UsageService service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }