List of usage examples for javax.servlet ServletConfig getServletContext
public ServletContext getServletContext();
From source file:org.LexGrid.LexBIG.caCore.web.util.LexEVSHTTPQuery.java
/** * Initialize the servlet//from w w w . ja v a2s . co m */ public void init(ServletConfig config) throws ServletException { super.init(config); context = config.getServletContext(); WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context); Properties systemProperties = (Properties) ctx.getBean("WebSystemProperties"); cacoreStyleSheet = systemProperties.getProperty("resultOutputFormatter"); jsonStyleSheet = systemProperties.getProperty("jsonOutputFormatter"); log.debug("cacoreStylesheet: " + cacoreStyleSheet); try { String pageCount = systemProperties.getProperty("rowCounter"); log.debug("rowCounter: " + pageCount); if (pageCount != null) { pageSize = Integer.parseInt(pageCount); } } catch (Exception ex) { log.error("Exception: ", ex); } }
From source file:org.apache.nutch.searcher.response.SearchServlet.java
/** * Initializes servlet configuration default values. Gets NutchBean and * ResponseWriters.//w ww.j a v a2 s.c o m */ public void init(ServletConfig config) throws ServletException { // set sensible defaults for response writer values and cache NutchBean. // Also get and cache all ResponseWriter implementations. super.init(config); try { this.conf = NutchConfiguration.get(config.getServletContext()); this.defaultRespType = conf.get("search.response.default.type", "xml"); this.defaultLang = conf.get("search.response.default.lang"); this.defaultNumRows = conf.getInt("search.response.default.numrows", 10); this.defaultDedupField = conf.get("search.response.default.dedupfield", "site"); this.defaultNumDupes = conf.getInt("search.response.default.numdupes", 1); bean = NutchBean.get(config.getServletContext(), this.conf); writers = new ResponseWriters(conf); } catch (IOException e) { throw new ServletException(e); } }
From source file:nl.b3p.kaartenbalie.core.server.persistence.MyEMFDatabase.java
public void initGlobalContextParams(ServletConfig config) { ServletContext context = config.getServletContext(); String value = context.getInitParameter(MyEMFDatabase.MAPFILE_DIR); if (value != null && value.length() > 0) { mapfiles = value;/*from ww w. j a v a 2s.com*/ } value = context.getInitParameter(MyEMFDatabase.UPLOAD_DIR); if (value != null && value.length() > 0) { upload = value; } value = context.getInitParameter(MyEMFDatabase.DEFAULT_ORGANIZATION); if (value != null && value.length() > 0) { defaultOrganization = value; } value = context.getInitParameter(MyEMFDatabase.LDAP_USELDAP); if (value != null && value.length() > 0) { ldapUseLdap = new Boolean(value); } value = context.getInitParameter(MyEMFDatabase.LDAP_DEFAULTGROUP); if (value != null && value.length() > 0) { ldapDefaultGroup = value; } value = context.getInitParameter(MyEMFDatabase.LDAP_HOST); if (value != null && value.length() > 0) { ldapHost = value; } value = context.getInitParameter(MyEMFDatabase.LDAP_PORT); if (value != null && value.length() > 0) { ldapPort = new Integer(value); } value = context.getInitParameter(MyEMFDatabase.LDAP_USERSUFFIX); if (value != null && value.length() > 0) { ldapUserSuffix = value; } }
From source file:org.auraframework.http.AuraResourceServlet.java
@Override public void init(ServletConfig config) { servletContext = config.getServletContext(); }
From source file:com.alfaariss.oa.OAServlet.java
/** * Starts requestor profiles and helpers. * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) *///from www .ja va2s. c o m public void init(ServletConfig oServletConfig) throws ServletException { try { _context = oServletConfig.getServletContext(); //Retrieve configuration manager IConfigurationManager config = _engine.getConfigurationManager(); //Start profiles and helpers start(config, null); //Add as listener _engine.addComponent(this); } catch (OAException e) { _logger.fatal("Error starting Asimba Server", e); stop(); //Stop started profiles and helpers throw new ServletException(SystemErrors.toHexString(e.getCode())); } catch (Exception e) { _logger.fatal("Error starting Asimba Server", e); stop(); //Stop started profiles and helpers throw new ServletException(SystemErrors.toHexString(SystemErrors.ERROR_INTERNAL)); } }
From source file:com.iorga.iraj.servlet.AgglomeratorServlet.java
private void parseResource(final ServletConfig config, final String path) throws IOException, URISyntaxException { //TODO catch the modifications on the path itself final URL pathUrl = config.getServletContext().getResource(path); long lastModified = pathUrl.openConnection().getLastModified(); final InputStream targetIS = pathUrl.openStream(); final Document document = Jsoup.parse(targetIS, "UTF-8", ""); final Elements elements = document.getElementsByAttribute(ATTRIBUTE_NAME); for (final Element element : elements) { // each element which defines iraj-agglomerate // retrieve the suffix final String suffix = element.attr(ATTRIBUTE_NAME); final String urlAttribute = element.attr(URL_ATTRIBUTE_ATTRIBUTE_NAME); String src = StringUtils.removeEndIgnoreCase(element.attr(urlAttribute), suffix); String prefix = ""; if (!src.startsWith("/")) { // this is not an absolute file, let's add the prefix from the given path prefix = StringUtils.substringBeforeLast(path, "/") + "/"; src = prefix + src;/* w ww . j a v a2 s . co m*/ } // searching all scripts inside the folder defined by src attribute lastModified = searchAndAppendAfter(config, element, src, prefix, suffix, urlAttribute, lastModified); // finally remove it element.remove(); } caches.put(path, new ParsedResourceCacheEntry(path, document, lastModified)); }
From source file:dhbw.ka.mwi.businesshorizon2.SpringApplicationServlet.java
/** * Diese Methode wird einmal beim Initialisieren aufgerufen. Dort werden die Konfigurationseinstellungen * aus der web.xml gelesen. Darueberhinaus wird ein Spring-Application-Context aus der servletConfig * geholt, mit dem es moeglich ist, Beans mit Session-Scope zu erzeugen. * /* w w w. j a va 2 s . c o m*/ * @author Christian Gahlert */ @SuppressWarnings("unchecked") @Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); applicationBean = servletConfig.getInitParameter("applicationBean"); if (applicationBean == null) { throw new ServletException("ApplicationBean not specified in servlet parameters"); } applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletConfig.getServletContext()); applicationClass = (Class<? extends Application>) applicationContext.getType(applicationBean); }
From source file:com.recomdata.datasetexplorer.proxy.XmlHttpProxyServlet.java
public void init(ServletConfig config) throws ServletException { super.init(config); ctx = config.getServletContext(); // set the response content type if (ctx.getInitParameter("responseContentType") != null) { responseContentType = ctx.getInitParameter("responseContentType"); }/* ww w .j av a 2s. c om*/ // allow for resources dir over-ride at the xhp level otherwise allow // for the jmaki level resources if (ctx.getInitParameter("jmaki-xhp-resources") != null) { resourcesDir = ctx.getInitParameter("jmaki-xhp-resources"); } else if (ctx.getInitParameter("jmaki-resources") != null) { resourcesDir = ctx.getInitParameter("jmaki-resources"); } // allow for resources dir over-ride if (ctx.getInitParameter("jmaki-classpath-resources") != null) { classpathResourcesDir = ctx.getInitParameter("jmaki-classpath-resources"); } String requireSessionString = ctx.getInitParameter("requireSession"); if (requireSessionString != null) { if ("false".equals(requireSessionString)) { requireSession = false; getLogger().severe("XmlHttpProxyServlet: intialization. Session requirement disabled."); } else if ("true".equals(requireSessionString)) { requireSession = true; getLogger().severe("XmlHttpProxyServlet: intialization. Session requirement enabled."); } } String xdomainString = ctx.getInitParameter("allowXDomain"); if (xdomainString != null) { if ("true".equals(xdomainString)) { allowXDomain = true; getLogger().severe("XmlHttpProxyServlet: intialization. xDomain access is enabled."); } else if ("false".equals(xdomainString)) { allowXDomain = false; getLogger().severe("XmlHttpProxyServlet: intialization. xDomain access is disabled."); } } // if there is a proxyHost and proxyPort specified create an HttpClient with the proxy String proxyHost = ctx.getInitParameter("proxyHost"); String proxyPortString = ctx.getInitParameter("proxyPort"); if (proxyHost != null && proxyPortString != null) { int proxyPort = 8080; try { proxyPort = new Integer(proxyPortString).intValue(); xhp = new XmlHttpProxy(proxyHost, proxyPort); } catch (NumberFormatException nfe) { getLogger().severe("XmlHttpProxyServlet: intialization error. The proxyPort must be a number"); throw new ServletException( "XmlHttpProxyServlet: intialization error. The proxyPort must be a number"); } } else { xhp = new XmlHttpProxy(); } }
From source file:org.CloudOps.laas.ws.login.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String apikeysPropertiesFilename = config.getServletContext().getInitParameter("apikeys.properties"); if (apikeysPropertiesFilename != null) { if (!apikeysPropertiesFilename.startsWith("/")) { String hd = System.getProperty("user.dir"); if (!hd.endsWith("/")) hd += "/"; apikeysPropertiesFilename = hd + apikeysPropertiesFilename; }// w ww . j ava 2 s .c o m apikeysProperties = new File(apikeysPropertiesFilename); reloadApikeys(); } else { ServletContext context = config.getServletContext(); String path = context.getRealPath("/"); log.info("No API keys defined parameter must be defined 'apikeys.properties', webapp deployed at '" + path + "'"); } }
From source file:org.wso2.carbon.mediation.templates.ui.TemplateAdminClientAdapter.java
public TemplateAdminClientAdapter(ServletConfig config, HttpSession session) throws AxisFault { super(config, session); 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 + "TemplateAdminService"; templateAdminStub = new TemplateAdminServiceStub(configContext, serviceURL); ServiceClient client = templateAdminStub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true);//from w w w .j a va 2 s . co m option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); }