List of usage examples for javax.servlet ServletConfig getServletContext
public ServletContext getServletContext();
From source file:org.b5chat.crossfire.web.FaviconServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); // Create a pool of HTTP connections to use to get the favicons client = new HttpClient(new MultiThreadedHttpConnectionManager()); HttpConnectionManagerParams params = client.getHttpConnectionManager().getParams(); params.setConnectionTimeout(2000);/*from w w w.j av a 2s .c om*/ params.setSoTimeout(2000); // Load the default favicon to use when no favicon was found of a remote host try { URL resource = config.getServletContext().getResource("/images/server_16x16.gif"); defaultBytes = getImage(resource.toString()); } catch (MalformedURLException e) { e.printStackTrace(); } // Initialize caches. missesCache = CacheFactory.createCache("Favicon Misses"); hitsCache = CacheFactory.createCache("Favicon Hits"); }
From source file:org.tinygroup.jspengine.servlet.JspServletWrapper.java
JspServletWrapper(ServletConfig config, Options options, String jspUri, boolean isErrorPage, JspRuntimeContext rctxt) throws JasperException { this.isTagFile = false; this.config = config; this.options = options; this.jspUri = jspUri; ctxt = new JspCompilationContext(jspUri, isErrorPage, options, config.getServletContext(), this, rctxt); // START PWC 6468930 String jspFilePath = ctxt.getRealPath(jspUri); if (jspFilePath != null) { jspFile = new File(jspFilePath); }// ww w. ja va 2 s .c om // END PWC 6468930 }
From source file:com.bigdata.rdf.sail.remoting.GraphRepositoryServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); if (repo != null) { return;//from w w w . java2 s . com } try { // load properties file ServletContext context = config.getServletContext(); String propsDir = context.getRealPath("/WEB-INF"); String propsFileName = config.getInitParameter(SAIL_PROPERTIES); File propsFile = new File(propsDir, propsFileName); Properties sailProps = new Properties(); sailProps.load(new FileInputStream(propsFile)); BigdataSail sail = new BigdataSail(sailProps); repo = new BigdataSailRepository(sail); repo.initialize(); } catch (Exception ex) { ex.printStackTrace(); throw new ServletException(ex); } }
From source file:org.mobicents.servlet.sip.restcomm.callmanager.mgcp.MgcpCallManager.java
@Override public final void init(final ServletConfig config) throws ServletException { try {/* w w w . ja va 2 s . c o m*/ final ServletContext context = config.getServletContext(); LOGGER.info( "initializing the servlet with context:" + context + " ServerInfo:" + context.getServerInfo() + " ServletContextName:" + context.getServletContextName() + " config:" + config); context.setAttribute("org.mobicents.servlet.sip.restcomm.callmanager.CallManager", this); try { Bootstrapper.bootstrap(config); } catch (final BootstrapException exception) { throw new ServletException(exception); } sipFactory = (SipFactory) config.getServletContext().getAttribute(SIP_FACTORY); final ServiceLocator services = ServiceLocator.getInstance(); servers = services.get(MgcpServerManager.class); configuration = services.get(Configuration.class); proxyUser = configuration.getString("outbound-proxy-user"); proxyPassword = configuration.getString("outbound-proxy-password"); final String uri = configuration.getString("outbound-proxy-uri"); if (uri != null && !uri.isEmpty()) { proxyUri = sipFactory.createSipURI(null, uri); } /////////// LOGGER.info("initializing jvoicexml inteface........"); embJVXML = new EmbeddedJVXML(); embJVXML.init(); // //init jvoicexml context // contextJXML = new InitialContext(); // LOGGER.info("init jvoicexml context:contextJXML:"+contextJXML); // // // // LOGGER.info("creating VoiceXML documents and binding to the applications....."); // vxmlDocument = createVXMLDoc(); // printDocument(vxmlDocument); // // // // LOGGER.info("adding VXML document to repository..."); // vxmlURI=addDocument(vxmlDocument); // } catch (Exception e) { ExLog.exception(LOGGER, e); } }
From source file:com.jsmartframework.web.manager.ServletControl.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); WebContext.setServlet(this); // Call registered WebContextListeners for (ServletContextListener contextListener : HANDLER.contextListeners) { HANDLER.executeInjection(contextListener); contextListener.contextInitialized(new ServletContextEvent(servletConfig.getServletContext())); }/* w w w. ja va2s.c om*/ }
From source file:org.exist.management.client.JMXServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); // Setup JMS client client = new JMXtoXML(); client.connect();/*from www.j av a 2 s . co m*/ // Register all known localhost addresses registerLocalHostAddresses(); // Get directory for token file final String jmxDataDir = client.getDataDir(); if (jmxDataDir == null) { dataDir = new File(config.getServletContext().getRealPath(WEBINF_DATA_DIR)); } else { dataDir = new File(jmxDataDir); } if (!dataDir.isDirectory() || !dataDir.canWrite()) { LOG.error("Cannot access directory " + WEBINF_DATA_DIR); } // Setup token and tokenfile obtainTokenFileReference(); LOG.info(String.format("JMXservlet token: %s", getToken())); }
From source file:com.legstar.host.servlet.InitiatorServlet.java
/** * Initialization of the servlet. Loads configuration file and creates an * instance of the engine handler./* w ww . j av a2s . c om*/ * * @param config the complete configuration hierarchy * @throws ServletException if an error occurs */ public void init(final ServletConfig config) throws ServletException { String configFileName = config.getInitParameter(CONFIG_PARAM); if (configFileName == null || configFileName.length() == 0) { throw new ServletException("Web.xml does not contain the " + CONFIG_PARAM + " parameter."); } LOG.info("Initializing with " + configFileName + " configuration file."); try { LegStarConfigCommons legStarConfig = new LegStarConfigCommons(configFileName); EngineHandler serverHandler = new EngineHandler(legStarConfig.getPoolingEngineConfig()); serverHandler.init(); ServletContext servletContext = config.getServletContext(); servletContext.setAttribute(ENGINE_HANDLER_ID, serverHandler); } catch (EngineStartupException e) { LOG.error("Failed to start engine.", e); throw new ServletException(e); } catch (LegStarConfigurationException e) { LOG.error("Failed to start engine.", e); throw new ServletException(e); } }
From source file:org.jboss.orion.openshift.server.proxy.JsonProxyServlet.java
/** * load the mapping rules from the servlet context; could use a Java DSL, the XML DSL or load from a database *///from w ww.ja v a 2 s. co m protected void loadRuleBase(ServletConfig servletConfig, HttpProxyRuleBase ruleBase) throws ServletException { OpenshiftCore.log("Loading JBoss Orion proxy servlet forwarding rules"); ruleBase.setMappingRules( JsonRuleBaseReader.parseJson(servletConfig.getServletContext().getResourceAsStream(PROXY_CONFIG))); }
From source file:org.wso2.bpel.Axis2BasedODEServer.java
public void init(ServletConfig config, AxisConfiguration axisConf) throws ServletException { init(config.getServletContext().getRealPath("/WEB-INF"), axisConf); }
From source file:org.apache.oodt.cas.product.rdf.RDFProductServlet.java
/** * Initializes the servlet./*from w w w . j a v a 2 s . c o m*/ */ public void init(ServletConfig config) throws ServletException { super.init(config); try { this.rdfConf = RDFUtils.initRDF(config); } catch (FileNotFoundException e) { LOG.log(Level.SEVERE, e.getMessage()); throw new ServletException(e.getMessage()); } String fileManagerUrl; try { fileManagerUrl = PathUtils .replaceEnvVariables(config.getServletContext().getInitParameter("filemgr.url")); } catch (Exception e) { throw new ServletException("Failed to get filemgr url : " + e.getMessage(), e); } if (fileManagerUrl == null) { // try the default port fileManagerUrl = "http://localhost:9000"; } fClient = null; try { fClient = new XmlRpcFileManagerClient(new URL(fileManagerUrl)); } catch (MalformedURLException e) { LOG.log(Level.SEVERE, "Unable to initialize file manager url in RDF Servlet: [url=" + fileManagerUrl + "], Message: " + e.getMessage()); } catch (ConnectionException e) { LOG.log(Level.SEVERE, "Unable to initialize file manager url in RDF Servlet: [url=" + fileManagerUrl + "], Message: " + e.getMessage()); } }