List of usage examples for javax.servlet FilterConfig getServletContext
public ServletContext getServletContext();
From source file:org.apache.hadoop.gateway.hdfs.dispatch.WebHdfsHaHttpClientDispatch.java
@Override public void init(FilterConfig filterConfig) throws ServletException { resourceRole = filterConfig.getInitParameter(RESOURCE_ROLE_ATTRIBUTE); LOG.initializingForResourceRole(resourceRole); haProvider = HaServletContextListener.getHaProvider(filterConfig.getServletContext()); HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(resourceRole); maxFailoverAttempts = serviceConfig.getMaxFailoverAttempts(); failoverSleep = serviceConfig.getFailoverSleep(); maxRetryAttempts = serviceConfig.getMaxRetryAttempts(); retrySleep = serviceConfig.getRetrySleep(); }
From source file:org.apache.struts2.dispatcher.FilterDispatcherCompatWeblogic61.java
/** * dummy setter for {@link #filterConfig}; this method * sets up the {@link org.apache.struts2.config.ServletContextSingleton} with * the servlet context from the filter configuration. * <p/>/*w w w .j av a 2 s . co m*/ * This is needed by Weblogic Server 6.1 because it * uses a slightly obsolete Servlet 2.3-minus spec * whose {@link Filter} interface requires this method. * <p/> * * @param filterConfig the filter configuration. */ public void setFilterConfig(FilterConfig filterConfig) { try { init(filterConfig); } catch (ServletException se) { log.error("Couldn't set the filter configuration in this filter", se); } ServletContextSingleton singleton = ServletContextSingleton.getInstance(); singleton.setServletContext(filterConfig.getServletContext()); }
From source file:org.xchain.framework.filter.UrlTranslationFilter.java
public void init(FilterConfig filterConfig) throws ServletException { servletContext = filterConfig.getServletContext(); if (filterConfig.getInitParameter(ENABLED_PARAM_NAME) != null) { this.enabled = Boolean.valueOf(filterConfig.getInitParameter(ENABLED_PARAM_NAME)).booleanValue(); }/*from w ww .j a v a 2s. c o m*/ // Logger whether the filter is enabled. if (log.isDebugEnabled()) { if (this.enabled) log.debug("UrlTranslationFilter is ENABLED"); else log.debug("UrlTranslationFilter is DISABLED"); } if (enabled) { try { URL configResourceUrl = getConfigurationURL(filterConfig); if (configResourceUrl == null) { throw new Exception("Configuration file could not be found."); } loadConfiguration(configResourceUrl); } catch (Exception ex) { if (log.isWarnEnabled()) { log.warn("Failed to configure UrlTranslationFilter.", ex); } enabled = false; } } }
From source file:cc.kune.core.server.searcheable.SearchEngineServletFilter.java
@Override public void init(final FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; enabled = true;// w w w .j av a 2 s . c o m // As this object is not created by guice, we cannot use injection, so // we store this object in context and we can retrieve it later filterConfig.getServletContext().setAttribute(SEARCH_ENGINE_FILTER_ATTRIBUTE, this); }
From source file:edu.cornell.mannlib.vitro.webapp.filters.VitroRequestPrep.java
@Override public void init(FilterConfig filterConfig) throws ServletException { _context = filterConfig.getServletContext(); Object o = _context.getAttribute("applicationBean"); if (o instanceof ApplicationBean) { _appbean = (ApplicationBean) o;/* w w w . j a v a 2s . co m*/ } else { _appbean = new ApplicationBean(); } log.debug("VitroRequestPrep: AppBean theme " + _appbean.getThemeDir()); }
From source file:optional.BasicFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; filterConfig.getServletContext(); String packagepath = filterConfig.getInitParameter(""); packagepath = ""; // configs//from w ww . j a v a 2 s . com // actions String path = filterConfig.getServletContext().getRealPath("/WEB-INF/classes" + packagepath); // Klassen finden ArrayList list = ActionPlugin.getClasses(path, packagepath); System.out.println("## looking for direct actions ##"); for (Iterator iterator = list.iterator(); iterator.hasNext();) { try { Class clazz = Class.forName((String) iterator.next()); if (!isInterfaceImplementer(clazz, DirectInterface.class)) { continue; } // store Actionclass and its configuration ConfigWrapper wrapper = new ConfigWrapper(); wrapper.setConfig((ActionConfig) clazz.getField("struts").get(clazz)); wrapper.setActionclass(clazz); wrapper.getConfig().setPath(getPathFromClassName(clazz.getName(), "Action")); System.out.println(wrapper.getConfig().getPath() + "\n" + clazz); actions.put(wrapper.getConfig().getPath(), wrapper); } catch (Exception e) { continue; } } System.out.println("## looking for direct actions DONE ##"); // request.setCharacterEncoding(encoding); // CharsetFilter // response.setCharacterEncoding(encoding); }
From source file:org.apache.hadoop.hdfsproxy.ProxyFilter.java
/** {@inheritDoc} */ public void init(FilterConfig filterConfig) throws ServletException { ServletContext context = filterConfig.getServletContext(); Configuration conf = new Configuration(false); conf.addResource("hdfsproxy-default.xml"); conf.addResource("ssl-server.xml"); conf.addResource("hdfsproxy-site.xml"); String nn = conf.get("hdfsproxy.dfs.namenode.address"); if (nn == null) { throw new ServletException("Proxy source cluster name node address not speficied"); }/*from w w w . j a va2s .co m*/ InetSocketAddress nAddr = NetUtils.createSocketAddr(nn); context.setAttribute("name.node.address", nAddr); context.setAttribute("name.conf", new Configuration()); context.setAttribute("org.apache.hadoop.hdfsproxy.conf", conf); LOG.info("proxyFilter initialization success: " + nn); }
From source file:com.att.nsa.filter.ContentLengthFilter.java
/** * @see Filter#init(FilterConfig)// w ww .ja v a 2s . c om */ public void init(FilterConfig fConfig) throws ServletException { // TODO Auto-generated method stub this.filterConfig = fConfig; log.info("Filter Content Length Initialize"); ApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(fConfig.getServletContext()); DefaultLength defLength = (DefaultLength) ctx.getBean("defLength"); DMaaPErrorMessages errorMessages = (DMaaPErrorMessages) ctx.getBean("DMaaPErrorMessages"); this.errorMessages = errorMessages; this.defaultLength = defLength; }
From source file:com.microsoft.aad.adal4jsample.BasicFilter.java
public void init(FilterConfig config) throws ServletException { clientId = config.getInitParameter("client_id"); authority = config.getServletContext().getInitParameter("authority"); tenant = config.getServletContext().getInitParameter("tenant"); clientSecret = config.getInitParameter("secret_key"); }
From source file:org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteResponseTest.java
@Test public void testResolve() throws Exception { UrlRewriteProcessor rewriter = EasyMock.createNiceMock(UrlRewriteProcessor.class); ServletContext context = EasyMock.createNiceMock(ServletContext.class); EasyMock.expect(context.getServletContextName()).andReturn("test-cluster-name").anyTimes(); EasyMock.expect(context.getInitParameter("test-init-param-name")).andReturn("test-init-param-value") .anyTimes();//from ww w .j a v a 2s .c om EasyMock.expect(context.getAttribute(UrlRewriteServletContextListener.PROCESSOR_ATTRIBUTE_NAME)) .andReturn(rewriter).anyTimes(); FilterConfig config = EasyMock.createNiceMock(FilterConfig.class); EasyMock.expect(config.getInitParameter("test-filter-init-param-name")) .andReturn("test-filter-init-param-value").anyTimes(); EasyMock.expect(config.getServletContext()).andReturn(context).anyTimes(); HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class); HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class); EasyMock.replay(rewriter, context, config, request, response); UrlRewriteResponse rewriteResponse = new UrlRewriteResponse(config, request, response); List<String> names = rewriteResponse.resolve("test-filter-init-param-name"); assertThat(names.size(), is(1)); assertThat(names.get(0), is("test-filter-init-param-value")); }