List of usage examples for javax.servlet ServletContext getInitParameter
public String getInitParameter(String name);
String
containing the value of the named context-wide initialization parameter, or null
if the parameter does not exist. From source file:com.norteksoft.security.web.listener.SecurityContextListener.java
public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); systemCode = context.getInitParameter("systemCode"); checkLicense(context);// w w w.j a v a2 s .c o m }
From source file:net.duckling.falcon.api.mstatic.VersionStartupListener.java
@Override public void contextInitialized(ServletContextEvent sce) { ServletContext context = sce.getServletContext(); String versionFile = context.getInitParameter("version-file"); String fullpath = context.getRealPath(versionFile); try {//from ww w. j av a 2s . c om String version = FileUtils.readFileToString(new File(fullpath)); if (version != null) { version = version.trim(); } else { version = "N/A"; } VersionAttributeHelper.setVersion(context, version); } catch (IOException e) { log.error("Reading version file failed.", e); } }
From source file:com.thoughtworks.go.spark.spa.spring.VelocityTemplateEngineFactory.java
@Override public void setServletContext(ServletContext servletContext) { if (servletContext.getInitParameter("rails.env").equals("development")) { this.modificationCheckInterval = 1; }/*www . j a v a2 s.c o m*/ }
From source file:com.kelveden.rastajax.servlet.DefaultJsonServlet.java
@Override public void init() throws ServletException { super.init(); final ServletContext context = getServletContext(); apiPackages = context.getInitParameter("rastajax.apipackages"); }
From source file:com.krawler.common.listeners.LocaleResolverBuilder.java
@Override public void contextInitialized(ServletContextEvent sce) { ServletContext context = sce.getServletContext(); String clName = context.getInitParameter(LOCALE_RESOLVER_CLASS_NAME_ATTR); String baseName = context.getInitParameter(MESSAGE_SOURCE_BASENAME_ATTR); try {// ww w . ja v a 2 s .c o m LocaleResolver obj = (LocaleResolver) Class.forName(clName).newInstance(); context.setAttribute(LocaleUtils.LOCALE_RESOLVER_NAME, obj); if (MessageSourceProxy.getMessageSource() == null && baseName != null) { MessageSourceProxy.setMessageSource(createMessageSource(baseName.split(","))); } } catch (Exception ex) { log.debug(ex.getMessage()); } }
From source file:com.openmeap.web.servlet.Log4JConfiguratorListener.java
@Override public void contextInitialized(ServletContextEvent arg0) { BasicConfigurator.configure();// w ww .j a va2s .co m ServletContext servletContext = arg0.getServletContext(); String xmlLoc = servletContext.getInitParameter("openmeap-log4j-xml"); if (xmlLoc == null) { return; } try { Resource res = new ClassPathResource(xmlLoc); DOMConfigurator.configure(XmlUtils.getDocument(res.getInputStream()).getDocumentElement()); } catch (Exception ioe) { servletContext.log("The configuration failed.", ioe); } }
From source file:de.ingrid.iplug.web.PlugdescriptionContextListener.java
public void contextInitialized(ServletContextEvent servletcontextevent) { ServletContext servletContext = servletcontextevent.getServletContext(); String pdFile = servletContext.getInitParameter("plugdescription.xml"); BeanFactory beanFactory = (BeanFactory) servletContext.getAttribute("beanFactory"); try {//from w w w .j av a2 s . c o m beanFactory.addBean("pd_file", new File(pdFile)); } catch (IOException e) { LOG.error("can not add plugdescription", e); } }
From source file:org.shangridocs.services.wikipedia.WikipediaResource.java
public WikipediaResource(@Context ServletContext sc) { wikipediaBaseUrlStr = sc.getInitParameter(WIKIPEDIA_BASE_URL); }
From source file:org.apache.myfaces.shared_ext202patch.util.StateUtils.java
/** * Does nothing if the user has disabled the SecretKey cache. This is * useful when dealing with a JCA provider whose SecretKey * implementation is not thread safe.//from w w w. j a va2 s. c o m * * Instantiates a SecretKey instance based upon what the user has * specified in the deployment descriptor. The SecretKey is then * stored in application scope where it can be used for all requests. */ public static void initSecret(ServletContext ctx) { if (ctx == null) throw new NullPointerException("ServletContext ctx"); if (log.isLoggable(Level.FINE)) log.fine("Storing SecretKey @ " + INIT_SECRET_KEY_CACHE); // Create and store SecretKey on application scope String cache = ctx.getInitParameter(INIT_SECRET_KEY_CACHE); if (cache == null) { cache = ctx.getInitParameter(INIT_SECRET_KEY_CACHE.toLowerCase()); } if (!"false".equals(cache)) { String algorithm = findAlgorithm(ctx); // you want to create this as few times as possible ctx.setAttribute(INIT_SECRET_KEY_CACHE, new SecretKeySpec(findSecret(ctx, algorithm), algorithm)); } if (log.isLoggable(Level.FINE)) log.fine("Storing SecretKey @ " + INIT_MAC_SECRET_KEY_CACHE); String macCache = ctx.getInitParameter(INIT_MAC_SECRET_KEY_CACHE); if (macCache == null) { macCache = ctx.getInitParameter(INIT_MAC_SECRET_KEY_CACHE.toLowerCase()); } if (!"false".equals(macCache)) { String macAlgorithm = findMacAlgorithm(ctx); // init mac secret and algorithm ctx.setAttribute(INIT_MAC_SECRET_KEY_CACHE, new SecretKeySpec(findMacSecret(ctx, macAlgorithm), macAlgorithm)); } }
From source file:leon.ssi.util.session.AppSessionListener.java
/** * set time out//w w w.j a v a2 s . co m */ public void sessionCreated(HttpSessionEvent se) { HttpSession session = null; try { session = se.getSession(); // get value ServletContext context = session.getServletContext(); String timeoutValue = context.getInitParameter("sessionTimeout"); int timeout = Integer.valueOf(timeoutValue); // set value session.setMaxInactiveInterval(timeout); logger.info("session max inactive interval has been set to " + timeout + " seconds."); } catch (Exception ex) { ex.printStackTrace(); } }