From: <bra...@us...> - 2010-10-01 18:15:39
|
Revision: 3266 http://archive-access.svn.sourceforge.net/archive-access/?rev=3266&view=rev Author: bradtofel Date: 2010-10-01 18:15:33 +0000 (Fri, 01 Oct 2010) Log Message: ----------- FEATURE: now includes default configuration file to control logging via java.util.logging Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/util/webapp/RequestFilter.java trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/web.xml Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/classes/logging.properties Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/util/webapp/RequestFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/util/webapp/RequestFilter.java 2010-10-01 16:20:35 UTC (rev 3265) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/util/webapp/RequestFilter.java 2010-10-01 18:15:33 UTC (rev 3266) @@ -19,7 +19,11 @@ */ package org.archive.wayback.util.webapp; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; +import java.util.logging.LogManager; import java.util.logging.Logger; import javax.servlet.Filter; @@ -33,12 +37,12 @@ import javax.servlet.http.HttpServletResponse; /** - * Top-Level integration point between a series of RequestHandler mappings and - * a generic ServletContext. This filter is assumed to be responsible for - * matching ALL requests received by the webapp ("*") and uses a RequestMapper - * to delegate incoming HttpServletRequests to the appropriate RequestHandler, - * via the doFilter() method. - * + * Top-Level integration point between a series of RequestHandler mappings and a + * generic ServletContext. This filter is assumed to be responsible for matching + * ALL requests received by the webapp ("*") and uses a RequestMapper to + * delegate incoming HttpServletRequests to the appropriate RequestHandler, via + * the doFilter() method. + * * @author brad */ public class RequestFilter implements Filter { @@ -46,20 +50,48 @@ .getName()); private RequestMapper mapper = null; private final static String CONFIG_PATH = "config-path"; - + private final static String LOGGING_CONFIG_PATH = "logging-config-path"; + public void init(FilterConfig config) throws ServletException { ServletContext servletContext = config.getServletContext(); + String logConfigPath = servletContext + .getInitParameter(LOGGING_CONFIG_PATH); + if (logConfigPath != null) { + String resolvedLogPath = servletContext.getRealPath(logConfigPath); + File logConfigFile = new File(resolvedLogPath); + if (logConfigFile.exists()) { + FileInputStream finp = null; + try { + finp = new FileInputStream(logConfigFile); + LogManager.getLogManager().readConfiguration(finp); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (finp != null) { + finp.close(); + } + } catch (IOException e) { + throw new ServletException(e); + } + } + } + } + String configPath = servletContext.getInitParameter(CONFIG_PATH); - if(configPath == null) { - throw new ServletException("Missing " + CONFIG_PATH - + " parameter"); + if (configPath == null) { + throw new ServletException("Missing " + CONFIG_PATH + " parameter"); } String resolvedPath = servletContext.getRealPath(configPath); - LOGGER.info("Initializing Spring config at: " + resolvedPath); - mapper = SpringReader.readSpringConfig(resolvedPath,servletContext); - LOGGER.info("Initialized Spring config at: " + resolvedPath); + LOGGER.info("Initializing Spring config at: " + resolvedPath); + mapper = SpringReader.readSpringConfig(resolvedPath, servletContext); + LOGGER.info("Initialized Spring config at: " + resolvedPath); } public void destroy() { @@ -68,18 +100,18 @@ LOGGER.info("Shutdown complete."); } - public void doFilter(ServletRequest request, ServletResponse response, + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { boolean handled = false; - - if(request instanceof HttpServletRequest) { - if(response instanceof HttpServletResponse) { + + if (request instanceof HttpServletRequest) { + if (response instanceof HttpServletResponse) { handled = mapper.handleRequest((HttpServletRequest) request, (HttpServletResponse) response); } } - if(!handled) { - chain.doFilter(request,response); + if (!handled) { + chain.doFilter(request, response); } } } Added: trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/classes/logging.properties =================================================================== --- trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/classes/logging.properties (rev 0) +++ trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/classes/logging.properties 2010-10-01 18:15:33 UTC (rev 3266) @@ -0,0 +1,26 @@ +handlers = java.util.logging.ConsoleHandler +java.util.logging.ConsoleHandler.level = ALL +java.util.logging.ConsoleHandler.formatter= org.archive.util.OneLineSimpleLogger +.level = WARNING +org.archive.wayback.level=WARNING +org.archive.wayback.webapp.AccessPoint.level=INFO +org.archive.wayback.util.webapp.level=ALL + + +# Background thread logging at INFO levels: +org.archive.wayback.accesscontrol.staticmap.StaticMapExclusionFilterFactory.level=INFO +org.archive.wayback.liveweb.URLtoARCCacher.level=INFO +org.archive.wayback.resourceindex.updater.LocalResourceIndexUpdater.level=INFO +org.archive.wayback.resourcestore.indexer.IndexQueueUpdater.level=INFO +org.archive.wayback.resourcestore.indexer.IndexWorker.level=INFO +org.archive.wayback.resourcestore.locationdb.ResourceFileLocationDBUpdater.level=INFO +org.archive.wayback.resourcestore.resourcefile.ResourceFileSourceUpdater.level=INFO + +# HttpClient is too chatty... only want to hear about severe problems +# For more on httpclient logging, +# see http://jakarta.apache.org/commons/httpclient/logging.html +org.apache.commons.httpclient.level = SEVERE + +# PerformanceLogger for timing of query, resource extraction, and replay +#org.archive.wayback.webapp.PerformanceLogger.level=ALL + Modified: trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/web.xml 2010-10-01 16:20:35 UTC (rev 3265) +++ trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/web.xml 2010-10-01 18:15:33 UTC (rev 3266) @@ -6,12 +6,40 @@ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> - <!-- General Installation information + <!-- + Wayback runs as a single Servlet Filter, which intercepts all incoming + requests. + + AccessPoints are defined in a Spring configuration file, and register + themselves to handle incoming requests with this Filter. If no + AccessPoint matches an incoming request, the filter does nothing, + falling back to normal request processing, but this is an exceptional + case: To enable "virtual" AccessPoints to share the common + static content (and especially .jsp files) directly under the webapp + directory, AccessPoints will generally strip leading path information, + and forward() the requests internally to the top level of the webapp + directory. To allow .jsp files to customize output based on the + particular AccessPoint which matched the request, references to the + AccessPoint, and other data structures are often stored in the + HttpServletRequest objects before forwarding these requests. In this + case, the AccessPoint will inform the common request Filter that + content has been returned, so "normal" request processing is skipped. + + In general, only 2 configurations are needed, which are both + webapp-relative paths to configuration. + + Specifically, this is a logging configuration .properties file, for + java.util.logging (logging-config-path) and a Spring XML configuration + file describing the set of AccessPoints objects (and their internal + objects) being served by this webapp (config-path). --> <context-param> + <param-name>logging-config-path</param-name> + <param-value>WEB-INF/classes/logging.properties</param-value> + </context-param> + <context-param> <param-name>config-path</param-name> <param-value>WEB-INF/wayback.xml</param-value> -<!-- <param-value>WEB-INF/memento.xml</param-value> --> </context-param> <filter> <filter-name>RequestFilter</filter-name> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |