You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by rg...@apache.org on 2006/11/21 21:56:08 UTC

svn commit: r477879 - in /forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core: Controller.java locationMap/Location.java locationMap/LocationMap.java

Author: rgardler
Date: Tue Nov 21 12:56:07 2006
New Revision: 477879

URL: http://svn.apache.org/viewvc?view=rev&rev=477879
Log:
Add some useful log messages for debugging the locationmap

Modified:
    forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java
    forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/Location.java
    forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/LocationMap.java

Modified: forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java?view=diff&rev=477879&r1=477878&r2=477879
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java Tue Nov 21 12:56:07 2006
@@ -354,9 +354,11 @@
 				loc = sourceLocs.next();
 				if (sourceExists(requestURI, loc)) {
 					result.add(loc);
+					log.debug("Found valid location: " + loc.toString());
 				} else {
 					if (loc.isRequired()) {
 						isValid = false;
+						log.debug("Can't use this set of locations because one is required: " + loc.toString());
 					}
 				}
 			}

Modified: forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/Location.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/Location.java?view=diff&rev=477879&r1=477878&r2=477879
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/Location.java (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/Location.java Tue Nov 21 12:56:07 2006
@@ -214,5 +214,21 @@
 		}
 		return scheme;
 	}
+	
+	public String toString() {
+		StringBuffer sb = new StringBuffer();
+		if (isRequired()) {
+			sb.append("Required ");
+		} else {
+			sb.append("Optional ");
+		}
+		sb.append("location: ");
+		sb.append("Pattern: ");
+		sb.append(this.getRequestPattern());
+		sb.append(" SourceURI: ");
+		sb.append(this.getSourceURI().toASCIIString());
+		
+		return sb.toString();
+	}
 
 }

Modified: forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/LocationMap.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/LocationMap.java?view=diff&rev=477879&r1=477878&r2=477879
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/LocationMap.java (original)
+++ forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/locationMap/LocationMap.java Tue Nov 21 12:56:07 2006
@@ -29,6 +29,7 @@
 import java.util.Set;
 
 import org.apache.forrest.core.exception.LocationmapException;
+import org.apache.log4j.Logger;
 import org.apache.xerces.parsers.DOMParser;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -44,6 +45,8 @@
  * 
  */
 public class LocationMap {
+	Logger log = Logger.getLogger(LocationMap.class);
+	
 	private final Map<String, List<Location>> locations = new HashMap<String, List<Location>>();
 
 	/**
@@ -58,6 +61,7 @@
 	 */
 	public LocationMap(final String locationmapPath) throws URISyntaxException,
 			SAXException, IOException {
+		log.debug("Initialise locationmap from config file " + locationmapPath);
 		final File file = new File(locationmapPath);
 		final URL lmURL = file.toURL();
 
@@ -70,7 +74,9 @@
 		for (int i = 0; i < nodes.getLength(); i++) {
 			final Node element = nodes.item(i);
 			if (element.getNodeName().equals("location")) {
-				this.put(new Location(element));
+				Location loc = new Location(element);
+				this.put(loc);
+				log.debug("Adding " + loc.toString());
 			}
 		}
 	}
@@ -102,12 +108,16 @@
 	 */
 	public List<List<Location>> get(final URI requestURI)
 			throws MalformedURLException, LocationmapException {
+		log.debug("Getting potential locations for request of " + requestURI.toASCIIString());
 		final List<List<Location>> results = new ArrayList<List<Location>>();
 		final Set<String> locPatterns = this.locations.keySet();
 		for (final String pattern : locPatterns) {
 			try {
-				if (this.isMatch(pattern, requestURI))
-					results.add(this.locations.get(pattern));
+				if (this.isMatch(pattern, requestURI)) {
+					List<Location> locs = this.locations.get(pattern);
+					results.add(locs);
+					log.info(locs.size() + " potenatial location from pattern " + pattern);
+				}
 			} catch (final RESyntaxException e) {
 				throw new LocationmapException(
 						"Pattern is not a valid regular expression (" + pattern