List of usage examples for javax.servlet ServletConfig getServletContext
public ServletContext getServletContext();
From source file:org.mobicents.servlet.sip.restcomm.Bootstrapper.java
private static String getRestCommUri(final ServletConfig config) { return config.getServletContext().getContextPath(); }
From source file:org.wso2.carbon.reporting.custom.ui.client.JrxmlFileUploaderClient.java
public static JrxmlFileUploaderClient getInstance(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); return new JrxmlFileUploaderClient(cookie, backendServerURL, configContext); }
From source file:classes.Upload.java
public static String uploadImage(HttpServletRequest request, ServletConfig config, String path) throws FileUploadException, Exception { String url = ""; String imgDir = config.getServletContext().getRealPath(path) + "/"; File dir = new File(imgDir); dir.mkdirs();/*from w w w .j a v a 2s. c o m*/ System.out.println("PasaPorAqui2"); DiskFileItemFactory fabrica = new DiskFileItemFactory(); fabrica.setSizeThreshold(1024); fabrica.setRepository(dir); ServletFileUpload upload = new ServletFileUpload(fabrica); List<FileItem> partes = upload.parseRequest(request); for (FileItem item : partes) { System.out.println("Subiendo"); File archivo = new File(imgDir, item.getName()); item.write(archivo); url = item.getName(); } return url; }
From source file:org.mobicents.servlet.sip.restcomm.Bootstrapper.java
private static String getRestCommPath(final ServletConfig config) { final ServletContext context = config.getServletContext(); final String path = context.getRealPath("/"); if (path.endsWith("/")) { return path.substring(0, path.length() - 1); } else {//from ww w .j a v a 2s .c o m return path; } }
From source file:org.wso2.carbon.reporting.custom.ui.client.DBReportingServiceClient.java
public static DBReportingServiceClient getInstance(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); return new DBReportingServiceClient(cookie, backendServerURL, configContext); }
From source file:org.apache.oodt.cas.product.rss.RSSUtils.java
public static RSSConfig initRSS(ServletConfig conf) throws FileNotFoundException { return RSSConfigReader.readConfig(new File( PathUtils.replaceEnvVariables(conf.getServletContext().getInitParameter((RSS_CONTEXT_CONF_KEY))))); }
From source file:org.wso2.carbon.mediation.configadmin.ui.ConfigManagementClient.java
public static ConfigManagementClient getInstance(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); return new ConfigManagementClient(cookie, backendServerURL, configContext); }
From source file:org.mobicents.servlet.sip.restcomm.Bootstrapper.java
public static void bootstrap(final ServletConfig config) throws BootstrapException { final ServletContext context = config.getServletContext(); final String path = context.getRealPath("WEB-INF/conf/vnxivr.xml"); LOGGER.info("loading configuration file located at " + path); // Initialize the configuration interpolator. final ConfigurationStringLookup strings = new ConfigurationStringLookup(); strings.addProperty("home", getRestCommPath(config)); strings.addProperty("uri", getRestCommUri(config)); ConfigurationInterpolator.registerGlobalLookup("vnxivr", strings); // Load the vnxivr configuration. XMLConfiguration configuration = null; try {//from ww w . j a v a 2 s .c o m configuration = new XMLConfiguration(path); } catch (final ConfigurationException exception) { LOGGER.error("The VNXIVR environment could not be bootstrapped.", exception); throw new BootstrapException(exception); } // Register the services with the service locator. final ServiceLocator services = ServiceLocator.getInstance(); try { final Configuration runtimeConfiguration = configuration.subset("runtime-settings"); runtimeConfiguration.setProperty("home-directory", getRestCommPath(config)); runtimeConfiguration.setProperty("root-uri", getRestCommUri(config)); services.set(Configuration.class, runtimeConfiguration); final MgcpServerManager serverManager = getMgcpServerManager(configuration); services.set(MgcpServerManager.class, serverManager); final CallManager callManager = (CallManager) context .getAttribute("org.mobicents.servlet.sip.restcomm.callmanager.CallManager"); services.set(CallManager.class, callManager); services.set(ConferenceCenter.class, getConferenceCenter(serverManager)); services.set(SmsAggregator.class, getSmsAggregator(configuration)); } catch (final ObjectInstantiationException exception) { LOGGER.error("The VNXIVR environment could not be bootstrapped.", exception); throw new BootstrapException(exception); } }
From source file:org.infoscoop.web.InitializeServlet.java
/** * get the resource on the same context as InputSource. * @param config/*from w ww . jav a 2 s. c om*/ * @param path * @return * @throws ServletException */ public static InputSource getResource(ServletConfig config, String path) throws ServletException { try { URL url = config.getServletContext().getResource(path); InputStream input = config.getServletContext().getResourceAsStream(path); InputSource is = new InputSource(url.toExternalForm()); is.setByteStream(input); is.setSystemId(config.getServletContext().getRealPath(path)); return is; } catch (MalformedURLException e) { throw new ServletException(e); } }
From source file:org.wso2.carbon.reporting.custom.ui.client.ReportResourceSupplierClient.java
public static ReportResourceSupplierClient getInstance(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); return new ReportResourceSupplierClient(cookie, backendServerURL, configContext); }