List of usage examples for javax.servlet ServletConfig getInitParameter
public String getInitParameter(String name);
From source file:servlets.DocumentViewer.java
@Override public void init(ServletConfig config) throws ServletException { String propFileName = config.getInitParameter("configFile"); this.prop = new Properties(); try {//from w ww .jav a 2 s . c o m prop.load(new FileReader(propFileName)); String indexDir = prop.getProperty("index"); reader = DirectoryReader.open(FSDirectory.open(new File(indexDir))); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:org.ldaptive.servlets.AbstractServletSearchTemplatesExecutor.java
@Override public void initialize(final ServletConfig config) { final String springContextPath = config.getInitParameter(SPRING_CONTEXT_PATH) != null ? config.getInitParameter(SPRING_CONTEXT_PATH) : DEFAULT_SPRING_CONTEXT_PATH; logger.debug("{} = {}", SPRING_CONTEXT_PATH, springContextPath); final ApplicationContext context = new ClassPathXmlApplicationContext(springContextPath); setSearchExecutor(context.getBean(AggregatePooledSearchExecutor.class)); logger.debug("searchExecutor = {}", getSearchExecutor()); final Map<String, PooledConnectionFactory> factories = context .getBeansOfType(PooledConnectionFactory.class); setConnectionFactories(factories.values().toArray(new PooledConnectionFactory[factories.size()])); logger.debug("connectionFactories = {}", Arrays.toString(getConnectionFactories())); final Map<String, SearchTemplates> templates = context.getBeansOfType(SearchTemplates.class); setSearchTemplates(templates.values().toArray(new SearchTemplates[templates.size()])); logger.debug("searchTemplates = {}", Arrays.toString(getSearchTemplates())); ignorePattern = config.getInitParameter(IGNORE_PATTERN) != null ? Pattern.compile(config.getInitParameter(IGNORE_PATTERN)) : null;//w ww. j av a2 s . c o m logger.debug("{} = {}", IGNORE_PATTERN, ignorePattern); }
From source file:de.bermuda.arquillian.example.ContentTypeProxyServlet.java
@Override public void init() { client = new HttpClient(); String url = "http://soap.bermuda.de/soapAction:8080"; ServletConfig config = getServletConfig(); if (config != null && config.getInitParameter("url") != null) { log.debug("Using Config Param"); url = config.getInitParameter("url"); }/*from w ww . ja v a2 s . c o m*/ try { serviceURL = new URL(url); } catch (MalformedURLException e) { log.error("URL invalid", e); } }
From source file:de.micromata.genome.gwiki.model.config.GWikiAbstractSpringContextBootstrapConfigLoader.java
@Override public GWikiDAOContext loadConfig(ServletConfig config) { if (config != null && StringUtils.isBlank(fileName) == true) { fileName = config .getInitParameter("de.micromata.genome.gwiki.model.config.GWikiBootstrapConfigLoader.fileName"); supportsJndi = StringUtils.equals(config.getInitParameter("de.micromata.genome.gwiki.supportsJndi"), "true"); }/*from w w w. j a va2 s . co m*/ ConfigurableApplicationContext actx = createApplicationContext(config, getApplicationContextName()); actx.addBeanFactoryPostProcessor(new GWikiDAOContextPropertyPlaceholderConfigurer(config, supportsJndi)); actx.refresh(); beanFactory = actx; GWikiDAOContext daoContext = (GWikiDAOContext) actx.getBean("GWikiBootstrapConfig"); daoContext.setBeanFactory(beanFactory); return daoContext; }
From source file:org.uberfire.server.UberfireImageServlet.java
private String getConfig(final ServletConfig config, final String key) { final String keyValue = config.getInitParameter(key); if (keyValue != null && keyValue.isEmpty()) { return null; }//from w w w .j a va 2 s . c o m return keyValue; }
From source file:com.npower.wurfl.WurflServletInit.java
public void init(ServletConfig config) throws ServletException { super.init(config); wurflSourceClassName = config.getInitParameter("WurflSourceClass"); if (wurflSourceClassName == null || wurflSourceClassName.trim().length() == 0) { throw new ServletException( "Missing WURFLSourceClass parameter in web.xml for WurflServletInit servlet."); }//www . j a va 2 s . co m // To fire up WURFL initialize try { getObjectsManager(); } catch (Exception e) { log.fatal(e.getMessage(), e); throw new ServletException(e.getMessage(), e); } }
From source file:de.thischwa.pmcms.server.ZipProxyServlet.java
@Override public void init(ServletConfig config) throws ServletException { zipPathToSkip = config.getInitParameter("zipPathToSkip"); String fileParam = config.getInitParameter("file"); if (StringUtils.isBlank(fileParam)) throw new IllegalArgumentException("No file parameter found!"); File file = null;/*from w w w . j a v a2 s .com*/ zipInfo = new HashMap<String, ZipEntry>(); try { file = new File(config.getInitParameter("file")); if (!file.exists()) { throw new ServletException(String.format("Zip-file not found: %s", file.getPath())); } zipFile = new ZipFile(file); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry ze = entries.nextElement(); String entryName = ze.getName(); if (zipPathToSkip != null) entryName = entryName.substring(zipPathToSkip.length() + 1); if (entryName.startsWith("/")) entryName = entryName.substring(1); zipInfo.put(entryName, ze); } logger.debug("Found entries in zip: " + zipInfo.size()); } catch (IOException e) { throw new ServletException("Couldn't read the zip file: " + e.getMessage(), e); } logger.info(String.format("ZipProxyServlet initialzed with file [%s] and path to skip [%s]", file.getPath(), zipPathToSkip)); }
From source file:com.metaparadigm.jsonrpc.JSONRPCServlet.java
@Override public void init(ServletConfig config) { if ("0".equals(config.getInitParameter("auto-session-bridge"))) auto_session_bridge = false;/*from w w w.j a va 2s .c om*/ if ("0".equals(config.getInitParameter("keepalive"))) keepalive = false; log.info("auto_session_bridge=" + auto_session_bridge + ", keepalive=" + keepalive); }
From source file:talend.ext.images.server.ImageDeleteServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); outputFormat = config.getInitParameter("output-format"); //$NON-NLS-1$ }
From source file:ch.frankel.vaadin.spring.SpringApplicationServlet.java
/** * Get and stores in the servlet the application bean's name in the Spring's * context. It's expected to be configured as a the servlet * <code>init-param</code> named applicationBeanName. If no * param is found, the default is "application". * //from ww w .j a va 2 s. c o m * @see AbstractApplicationServlet#init(ServletConfig) */ @Override public void init(ServletConfig config) throws ServletException { super.init(config); String name = config.getInitParameter("applicationBeanName"); this.name = name == null ? DEFAULT_APP_BEAN_NAME : name; }