forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r476384 [1/3] - in /forrest/trunk/whiteboard/forrest2: ./ .settings/ core/ core/org/ core/org/apache/ core/org/apache/forrest/ core/org/apache/forrest/cli/ core/org/apache/forrest/core/ core/org/apache/forrest/core/document/ core/org/apache...
Date Sat, 18 Nov 2006 00:12:06 GMT
Author: rgardler
Date: Fri Nov 17 16:12:01 2006
New Revision: 476384

URL: http://svn.apache.org/viewvc?view=rev&rev=476384
Log:
First stab at an eperimental implementation of Forrest2. Please
see src/docs/readme.html

Added:
    forrest/trunk/whiteboard/forrest2/   (with props)
    forrest/trunk/whiteboard/forrest2/.classpath   (with props)
    forrest/trunk/whiteboard/forrest2/.project   (with props)
    forrest/trunk/whiteboard/forrest2/.settings/
    forrest/trunk/whiteboard/forrest2/.settings/org.jayasoft.ivyde.eclipse.prefs
    forrest/trunk/whiteboard/forrest2/.springBeans
    forrest/trunk/whiteboard/forrest2/core/
    forrest/trunk/whiteboard/forrest2/core/org/
    forrest/trunk/whiteboard/forrest2/core/org/apache/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/cli/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/cli/CLI.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/Controller.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractDocument.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractOutputDocument.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractSourceDocument.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AggregateInteralDocument.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultOutputDocument.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultSourceDocument.java
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DocumentFactory.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/IDocument.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/InternalDocument.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/XMLSourceDocument.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/LocationmapException.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/ProcessingException.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/SourceException.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/UnknownProtocolException.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/Location.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/LocationMap.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/AbstractInputPlugin.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/BaseOutputPlugin.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IOutputPlugin.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IPlugin.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/PassThroughInputPlugin.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTInputPlugin.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTOutputPlugin.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/AbstractReader.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/FileReader.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/HTTPReader.java   (with props)
    forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/IReader.java   (with props)
    forrest/trunk/whiteboard/forrest2/ivy.xml   (with props)
    forrest/trunk/whiteboard/forrest2/ivyconf.xml   (with props)
    forrest/trunk/whiteboard/forrest2/src/
    forrest/trunk/whiteboard/forrest2/src/conf/
    forrest/trunk/whiteboard/forrest2/src/conf/defaultForrestContext.xml   (with props)
    forrest/trunk/whiteboard/forrest2/src/conf/locationmap.xml   (with props)
    forrest/trunk/whiteboard/forrest2/src/docs/
    forrest/trunk/whiteboard/forrest2/src/docs/createAPlugin.html   (with props)
    forrest/trunk/whiteboard/forrest2/src/docs/examples/
    forrest/trunk/whiteboard/forrest2/src/docs/examples/affiliateProductCatalogue.html   (with props)
    forrest/trunk/whiteboard/forrest2/src/docs/howDoesItWork.html   (with props)
    forrest/trunk/whiteboard/forrest2/src/docs/readme.html   (with props)
    forrest/trunk/whiteboard/forrest2/src/docs/urlExtensions.html   (with props)
    forrest/trunk/whiteboard/forrest2/src/examples/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/forrestContext.xml   (with props)
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/locationmap.xml   (with props)
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/reader/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/reader/TradeDoublerReader.java   (with props)
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/xdocs/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/xdocs/exampleFeed.xml   (with props)
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/xslt/
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/xslt/tradeDoublerFeed-to-internal.xsl   (with props)
    forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/tradeDoubler.html/
    forrest/trunk/whiteboard/forrest2/src/examples/helloWorld/
    forrest/trunk/whiteboard/forrest2/src/examples/helloWorld/src/
    forrest/trunk/whiteboard/forrest2/src/examples/helloWorld/src/forrestContext.xml   (with props)
    forrest/trunk/whiteboard/forrest2/src/examples/helloWorld/src/locationmap.xml   (with props)
    forrest/trunk/whiteboard/forrest2/src/examples/helloWorld/src/xdocs/
    forrest/trunk/whiteboard/forrest2/src/examples/helloWorld/src/xdocs/helloWorld.xhtml2
    forrest/trunk/whiteboard/forrest2/test/
    forrest/trunk/whiteboard/forrest2/test/forrestContext.xml   (with props)
    forrest/trunk/whiteboard/forrest2/test/locationmap.xml   (with props)
    forrest/trunk/whiteboard/forrest2/test/org/
    forrest/trunk/whiteboard/forrest2/test/org/apache/
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/test/
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/test/core/
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/test/core/TestController.java   (with props)
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/test/core/plugins/
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/test/core/plugins/input/
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/test/core/plugins/input/HelloWorldInputPlugin.java   (with props)
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/test/core/readers/
    forrest/trunk/whiteboard/forrest2/test/org/apache/forrest/test/core/readers/HelloReader.java   (with props)
    forrest/trunk/whiteboard/forrest2/test/xdocs/
    forrest/trunk/whiteboard/forrest2/test/xdocs/samples/
    forrest/trunk/whiteboard/forrest2/test/xdocs/samples/xhtml2/
    forrest/trunk/whiteboard/forrest2/test/xdocs/samples/xhtml2/sample_simple.html   (with props)
    forrest/trunk/whiteboard/forrest2/test/xdocs/samples/xml/
    forrest/trunk/whiteboard/forrest2/test/xdocs/samples/xml/helloWorld.xml   (with props)
    forrest/trunk/whiteboard/forrest2/test/xdocs/samples/xslt/
    forrest/trunk/whiteboard/forrest2/test/xdocs/samples/xslt/internal-to-html.xsl   (with props)

Propchange: forrest/trunk/whiteboard/forrest2/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov 17 16:12:01 2006
@@ -0,0 +1,2 @@
+
+bin

Added: forrest/trunk/whiteboard/forrest2/.classpath
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/.classpath?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/.classpath (added)
+++ forrest/trunk/whiteboard/forrest2/.classpath Fri Nov 17 16:12:01 2006
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="core"/>
+	<classpathentry kind="src" path="test"/>
+	<classpathentry kind="src" path="src/conf"/>
+	<classpathentry kind="src" path="src/examples/helloWorld/src"/>
+	<classpathentry kind="src" path="src/examples/affiliateProductCatalogue/src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry kind="con" path="org.jayasoft.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/ivy.xml/*"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/org.saafe.catalogue"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Propchange: forrest/trunk/whiteboard/forrest2/.classpath
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/.project
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/.project?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/.project (added)
+++ forrest/trunk/whiteboard/forrest2/.project Fri Nov 17 16:12:01 2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>forrest2</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.genuitec.eclipse.springframework.springbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.genuitec.eclipse.springframework.springnature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Propchange: forrest/trunk/whiteboard/forrest2/.project
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/.settings/org.jayasoft.ivyde.eclipse.prefs
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/.settings/org.jayasoft.ivyde.eclipse.prefs?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/.settings/org.jayasoft.ivyde.eclipse.prefs (added)
+++ forrest/trunk/whiteboard/forrest2/.settings/org.jayasoft.ivyde.eclipse.prefs Fri Nov 17 16:12:01 2006
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#Sun Oct 22 02:10:00 BST 2006
+acceptedTypes=[inherited]
+eclipse.preferences.version=1
+ivy_conf_path=file\:/D\:/projectWorkspace/forrest2/ivyconf.xml
+retreive.pattern=none

Added: forrest/trunk/whiteboard/forrest2/.springBeans
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/.springBeans?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/.springBeans (added)
+++ forrest/trunk/whiteboard/forrest2/.springBeans Fri Nov 17 16:12:01 2006
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<configExtensions>
+		<configExtension>xml</configExtension>
+	</configExtensions>
+	<configs>
+	</configs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/cli/CLI.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/cli/CLI.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/cli/CLI.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/cli/CLI.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.cli;
+
+import java.net.URI;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.forrest.core.Controller;
+import org.apache.forrest.core.document.AbstractOutputDocument;
+
+/**
+ * A command line interface for Forrest.
+ * 
+ */
+public class CLI {
+	private static final Log log = LogFactory.getLog(CLI.class);
+
+	/**
+	 * @param args
+	 */
+	public static void main(final String[] args) {
+		System.out.println("Forrest 2 Command Line Interface");
+		System.out.println("================================");
+
+		if (args[0].equals("--help")) {
+			displayHelp();
+			return;
+		}
+
+		try {
+			AbstractOutputDocument doc = null;
+			System.out.println("\n Processing request for " + args[0]);
+			final URI requestURI = new URI(args[0]);
+			final Controller controller = new Controller();
+			doc = controller.getOutputDocument(requestURI);
+
+			System.out.println("\n Resulting document for request " + args[0]
+					+ " is:\n");
+			System.out.println(doc.getContentAsString());
+
+		} catch (final Exception e) {
+			e.printStackTrace();
+			log.error(e);
+			System.exit(1);
+		}
+	}
+
+	/**
+	 * Outputs a short description on how to use the CLI.
+	 */
+	private static void displayHelp() {
+		System.out.println("Help");
+		System.out.println("====");
+		System.out.println("CLI [URI]");
+		System.out.println("URI is the request URI that you wish to process");
+		System.out
+				.println("The default behaviour is to process the request and output the results to the System.out");
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/cli/CLI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/Controller.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/Controller.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/Controller.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/Controller.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,402 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.forrest.core.document.AbstractOutputDocument;
+import org.apache.forrest.core.document.AbstractSourceDocument;
+import org.apache.forrest.core.document.AggregateInteralDocument;
+import org.apache.forrest.core.document.DefaultOutputDocument;
+import org.apache.forrest.core.document.IDocument;
+import org.apache.forrest.core.document.InternalDocument;
+import org.apache.forrest.core.exception.LocationmapException;
+import org.apache.forrest.core.exception.ProcessingException;
+import org.apache.forrest.core.locationMap.Location;
+import org.apache.forrest.core.locationMap.LocationMap;
+import org.apache.forrest.core.plugin.AbstractInputPlugin;
+import org.apache.forrest.core.plugin.BaseOutputPlugin;
+import org.apache.forrest.core.plugin.PassThroughInputPlugin;
+import org.apache.forrest.reader.IReader;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+import org.xml.sax.SAXException;
+
+/**
+ * The Controller manages all things Forrest. It is responsible for:
+ * 
+ * <ol>
+ * <li>resolving the input document(s)</li>
+ * <li>loading the input document(s)</li>
+ * <li>selecting an appropriate input plugin(s)</li>
+ * <li>processing the input document with the selected plugin</li>
+ * <li>selecting an appropriate output plugin</li>
+ * <li>processing the internal document with the output plugin</li>
+ * <li>streaming the results to the client</li>
+ * </ol>
+ * 
+ * 
+ */
+public class Controller {
+
+	private final String sourceURLExtension = ".forrestSource";
+
+	private final String internalURLExtension = ".forrestInternal";
+
+	private final Map<URI, List<Location>> sourceLocationsCache = new HashMap<URI, List<Location>>();
+
+	private final Map<URI, List<AbstractSourceDocument>> sourceDocsCache = new HashMap<URI, List<AbstractSourceDocument>>();
+
+	private final Map<URI, List<InternalDocument>> internalDocsCache = new HashMap<URI, List<InternalDocument>>();
+
+	private final Map<URI, AbstractOutputDocument> outputDocCache = new HashMap<URI, AbstractOutputDocument>();
+
+	private LocationMap locationMap;
+
+	private AbstractXmlApplicationContext context;
+
+	/**
+	 * Create a controller that uses the locationmap definition file at the
+	 * provided location.
+	 * 
+	 * @param locationmapPath -
+	 *            path to the locationmap definition file
+	 * @throws URISyntaxException
+	 * @throws IOException
+	 *             If the locationmap cannot be loaded
+	 * @throws SAXException
+	 *             If the locationmap is invalid
+	 * 
+	 */
+	public Controller(final String locationmapPath, final String contextPath)
+			throws URISyntaxException, SAXException, IOException {
+		final File file = new File(contextPath);
+		if (file.exists()) {
+			this.context = new FileSystemXmlApplicationContext(file
+					.getAbsolutePath());
+		} else {
+			this.context = new ClassPathXmlApplicationContext(
+					"defaultForrestContext.xml");
+		}
+		this.initLocationmap(locationmapPath);
+	}
+
+	/**
+	 * Create a controller that uses the default location for the locationmap
+	 * definition file and forrest context file. That is "src/locationmap.xml"
+	 * and "src/forrestContext.xml" respectively..
+	 * 
+	 * @throws URISyntaxException
+	 * @throws IOException
+	 *             If the locationmap cannot be loaded
+	 * @throws SAXException
+	 *             If the locationmap is invalid
+	 * 
+	 */
+	public Controller() throws URISyntaxException, SAXException, IOException {
+		this("src/locationmap.xml", "src/forrestContext.xml");
+	}
+
+	/**
+	 * Initialises the locationmap for use.
+	 * 
+	 * @throws URISyntaxException
+	 * @throws IOException
+	 * @throws SAXException
+	 * @FIXME read the locationmap from a config file.
+	 */
+	private void initLocationmap(final String locationmapPath)
+			throws URISyntaxException, SAXException, IOException {
+		this.locationMap = new LocationMap(locationmapPath);
+	}
+
+	/**
+	 * Process a request for the resource identified by a given URI.
+	 * 
+	 * @param requestURI
+	 * @throws IOException
+	 * @throws LocationmapException
+	 * @throws ProcessingException
+	 */
+	private AbstractOutputDocument processRequest(final URI requestURI)
+			throws IOException, LocationmapException, ProcessingException {
+		final List<Location> sourceLocs = this.resolveSources(requestURI);
+		this.sourceLocationsCache.put(requestURI, sourceLocs);
+
+		final List<AbstractSourceDocument> sourceDocs = this
+				.loadSourceDocuments(sourceLocs);
+		this.sourceDocsCache.put(requestURI, sourceDocs);
+
+		final List<InternalDocument> internalDocs = this
+				.processInputPlugins(sourceDocs);
+		this.internalDocsCache.put(requestURI, internalDocs);
+
+		final AbstractOutputDocument output = this
+				.processOutputPlugins(requestURI);
+		this.outputDocCache.put(requestURI, output);
+		return output;
+	}
+
+	/**
+	 * Process each of the documents supplied with the appropriate input plugins
+	 * to get a document in our internal format.
+	 * 
+	 * @param sourceDocuments
+	 * @throws IOException
+	 */
+	private List<InternalDocument> processInputPlugins(
+			final List<AbstractSourceDocument> sourceDocuments)
+			throws IOException {
+		final List<InternalDocument> results = new ArrayList<InternalDocument>(
+				sourceDocuments.size());
+		for (int i = 0; i < sourceDocuments.size(); i++) {
+			final AbstractSourceDocument doc = sourceDocuments.get(i);
+			AbstractInputPlugin plugin;
+			try {
+				plugin = (AbstractInputPlugin) this.context.getBean(doc
+						.getType());
+			} catch (final NoSuchBeanDefinitionException e) {
+				plugin = new PassThroughInputPlugin();
+			}
+			results.add((InternalDocument) plugin.process(doc));
+		}
+		return results;
+	}
+
+	/**
+	 * Aggregate all the internal documents into a single document and then
+	 * process it will the appropraite output plugin for the given requestURI.
+	 * 
+	 * @param requestURI
+	 * @throws IOException
+	 * @throws ProcessingException
+	 * @throws IOException
+	 */
+	private AbstractOutputDocument processOutputPlugins(final URI requestURI)
+			throws ProcessingException, IOException {
+		IDocument doc = null;
+		final List<InternalDocument> intDocs = this
+				.getInternalDocuments(requestURI);
+		if (intDocs.size() > 1) {
+			doc = new AggregateInteralDocument(intDocs);
+		} else {
+			doc = intDocs.get(0);
+		}
+
+		BaseOutputPlugin plugin = new BaseOutputPlugin();
+		final String[] names = this.context.getBeanNamesForType(plugin
+				.getClass());
+		for (int i = 0; i < names.length; i = i + 1) {
+			plugin = (BaseOutputPlugin) this.context.getBean(names[i]);
+			if (plugin.isMatch(requestURI)) {
+				break;
+			} else {
+				plugin = null;
+			}
+		}
+		if (plugin == null) {
+			plugin = new BaseOutputPlugin();
+		}
+
+		return (AbstractOutputDocument) plugin.process(doc);
+	}
+
+	/**
+	 * Load each of the source documents.
+	 * 
+	 * @throws MalformedURLException
+	 * 
+	 * @fixme cache the resource
+	 * @fixme handle document types other than HTML
+	 * @fixme resource handlers should be provided from a factory class
+	 */
+	private List<AbstractSourceDocument> loadSourceDocuments(
+			final List<Location> sourceLocations) throws MalformedURLException {
+		final List<AbstractSourceDocument> results = new ArrayList<AbstractSourceDocument>(
+				sourceLocations.size());
+
+		for (int i = 0; i < sourceLocations.size(); i++) {
+			final Location location = sourceLocations.get(i);
+			IReader reader;
+			reader = (IReader) this.context.getBean(location.getSourceURI()
+					.getScheme());
+			results.add(reader.read(location));
+		}
+		return results;
+	}
+
+	/**
+	 * Resolve the input documents for a given request.
+	 * 
+	 * @param requestURI
+	 * @return
+	 * @throws LocationmapException
+	 * @throws MalformedURLException
+	 *             if the Request URI is not valid
+	 * @FIXME handle fall through if the first location is not correct
+	 */
+	private List<Location> resolveSources(final URI requestURI)
+			throws LocationmapException, MalformedURLException {
+		final List<List<Location>> possibleLocs = this.locationMap
+				.get(requestURI);
+		if (possibleLocs == null || possibleLocs.size() == 0)
+			throw new LocationmapException(
+					"Unable to find a source location for " + requestURI);
+		// TODO: we need to test for the validity of a location and return the
+		// first matching one instead of returning the first location regardless
+		return possibleLocs.get(0);
+	}
+
+	/**
+	 * Get the source URLs for a given request URI.
+	 * 
+	 * @param requestURI
+	 * @return
+	 * @throws IOException
+	 * @throws LocationmapException
+	 * @throws ProcessingException
+	 */
+	public List<Location> getSourceLocations(final URI requestURI)
+			throws IOException, LocationmapException, ProcessingException {
+		List<Location> locs = this.sourceLocationsCache.get(requestURI);
+		if (locs == null) {
+			this.processRequest(requestURI);
+			locs = this.sourceLocationsCache.get(requestURI);
+		}
+		return locs;
+	}
+
+	/**
+	 * Get the source documents for a given request URI.
+	 * 
+	 * @param requestURI
+	 * @return
+	 * @throws ProcessingException
+	 * @throws MalformedURLException
+	 * @throws IOException
+	 */
+	public List<AbstractSourceDocument> getSourceDocuments(final URI requestURI)
+			throws MalformedURLException, ProcessingException {
+		List<AbstractSourceDocument> sources = this.sourceDocsCache
+				.get(requestURI);
+		if (sources == null)
+			try {
+				this.processRequest(requestURI);
+				sources = this.sourceDocsCache.get(requestURI);
+			} catch (final Exception e) {
+				throw new ProcessingException(
+						"Unable to retrieve the source documents for "
+								+ requestURI, e);
+			}
+		return sources;
+	}
+
+	/**
+	 * Get the internal format documents for a given request URI.
+	 * 
+	 * @param requestURI
+	 * @return
+	 * @throws ProcessingException
+	 * @throws MalformedURLException
+	 * @throws IOException
+	 */
+	public List<InternalDocument> getInternalDocuments(final URI requestURI)
+			throws ProcessingException {
+		List<InternalDocument> internalDocs = this.internalDocsCache
+				.get(requestURI);
+		if (internalDocs == null)
+			try {
+				this.processRequest(requestURI);
+				internalDocs = this.internalDocsCache.get(requestURI);
+			} catch (final Exception e) {
+				throw new ProcessingException(
+						"Unable to create the internal representation of the source documents for "
+								+ requestURI.toString(), e);
+			}
+
+		return internalDocs;
+	}
+
+	/**
+	 * Get the output format documents for a given request URI.
+	 * 
+	 * @param requestURI
+	 * @return
+	 * @throws ProcessingException
+	 * @throws MalformedURLException
+	 * @throws IOException
+	 */
+	public AbstractOutputDocument getOutputDocument(final URI requestURI)
+			throws MalformedURLException, ProcessingException {
+		if (requestURI.getPath().endsWith(this.sourceURLExtension)) {
+			final List<AbstractSourceDocument> sources = this
+					.getSourceDocuments(requestURI);
+			final StringBuffer content = new StringBuffer();
+			for (final AbstractSourceDocument doc : sources) {
+				try {
+					content.append(doc.getContentAsString());
+				} catch (final IOException e) {
+					content
+							.append("<error>Unable to read source document for ");
+					content.append(requestURI);
+					content.append("</error>");
+				}
+			}
+			final DefaultOutputDocument output = new DefaultOutputDocument(
+					content.toString());
+			return output;
+		} else if (requestURI.getPath().endsWith(this.internalURLExtension)) {
+			final List<InternalDocument> docs = this
+					.getInternalDocuments(requestURI);
+			final StringBuffer content = new StringBuffer();
+			for (final InternalDocument doc : docs) {
+				try {
+					content.append(doc.getContentAsString());
+				} catch (final IOException e) {
+					content
+							.append("<error>Unable to read source document for ");
+					content.append(requestURI);
+					content.append("</error>");
+				}
+			}
+			final DefaultOutputDocument output = new DefaultOutputDocument(
+					content.toString());
+			return output;
+		}
+
+		AbstractOutputDocument output = this.outputDocCache.get(requestURI);
+		if (output == null)
+			try {
+				output = this.processRequest(requestURI);
+			} catch (final Exception e) {
+				throw new ProcessingException(
+						"Unable to create the output documents for "
+								+ requestURI + " because " + e.getMessage(), e);
+			}
+		return output;
+	}
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/Controller.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+import java.io.IOException;
+import java.util.Date;
+
+public abstract class AbstractDocument implements IDocument {
+	private Date lastModified;
+
+	String content;
+
+	public AbstractDocument() {
+	}
+
+	public AbstractDocument(final String string) {
+		this.content = string;
+	}
+
+	public String getContentAsString() throws IOException {
+		return this.content;
+	}
+
+	/**
+	 * Set the content of this document. The last modified date will also be
+	 * updated.
+	 * 
+	 * @param content
+	 */
+	public void setContent(final String content) {
+		this.content = content;
+		this.lastModified = new Date();
+	}
+
+	/**
+	 * Get the date and time that this IDocument was last modified. In the case
+	 * of a AbstractSourceDocument this will be the time the source was last
+	 * retrieved. In the case of an Internal IDocument this will be the last
+	 * time the source was processed by the input plugins to generate the
+	 * internal document. In the case of an outputDocument this will be the last
+	 * time the Internal IDocument was last processed using the output plugins.
+	 * 
+	 * @return
+	 */
+	public Date getLastModified() {
+		return this.lastModified;
+	}
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractOutputDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractOutputDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractOutputDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractOutputDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+import java.net.URI;
+
+/**
+ * An output document is a single document that has been processed by Forrest
+ * and is now ready to be returned to the client.
+ */
+public abstract class AbstractOutputDocument extends AbstractDocument {
+
+	private URI requestURI;
+
+	/**
+	 * Get the URI that was used to request this document.
+	 * 
+	 * @return
+	 */
+	public URI getRequestURI() {
+		return this.requestURI;
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractOutputDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractSourceDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractSourceDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractSourceDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractSourceDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+
+/**
+ * A source document is a single input document as retrieved from its source
+ * location.
+ * 
+ */
+public abstract class AbstractSourceDocument extends AbstractDocument {
+	String type;
+
+	@Override
+	public String getContentAsString() throws IOException {
+		if (this.isComplete() == false) {
+			this.load();
+		}
+		return super.getContentAsString();
+	}
+
+	/**
+	 * Loads the remainder of the content from the input stream.
+	 * 
+	 * @throws IOException
+	 * 
+	 */
+	private void load() throws IOException {
+		final StringBuffer fileData = new StringBuffer(1000);
+		final BufferedReader reader = this.getReader();
+		char[] buf = new char[1000];
+		int numRead = 0;
+		while ((numRead = reader.read(buf)) != -1) {
+			final String readData = String.valueOf(buf, 0, numRead);
+			fileData.append(readData);
+			buf = new char[1000];
+		}
+		this.addContent(fileData.toString());
+		this.setComplete(true);
+		reader.close();
+	}
+
+	/**
+	 * Adds some conntent to the end of the current content.
+	 * 
+	 * @param newContent
+	 */
+	private void addContent(final String newContent) {
+		this.content = this.content + newContent;
+	}
+
+	private boolean isComplete;
+
+	private BufferedReader reader;
+
+	/**
+	 * Indicate whether the complete document is available or not.
+	 * 
+	 * @param b
+	 */
+	protected void setComplete(final boolean b) {
+		this.isComplete = b;
+	}
+
+	/**
+	 * Indicates whether the complete document is available or not. If it is not
+	 * avilable then the rest can be read using the load() method.
+	 * 
+	 * @param b
+	 */
+	public boolean isComplete() {
+		return this.isComplete;
+	}
+
+	/**
+	 * Set the reader from which the remains of a partially loaded file can be
+	 * read.
+	 * 
+	 * @param reader
+	 */
+	protected void setReader(final BufferedReader reader) {
+		this.reader = reader;
+	}
+
+	protected BufferedReader getReader() {
+		return this.reader;
+	}
+
+	/**
+	 * Gets a string that defines the type of document this is. This value is
+	 * used to identify which input plugin will be used top generate the
+	 * internal document for further processing. This string is usually a
+	 * mime-type, but may be any unique string.
+	 * 
+	 * @return
+	 */
+	public String getType() {
+		return this.type;
+	}
+
+	public void setType(final String type) {
+		this.type = type;
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AbstractSourceDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AggregateInteralDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AggregateInteralDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AggregateInteralDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AggregateInteralDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A colelction of intenral documents that are to be processed as a single
+ * document by the output plugins.
+ * 
+ * @FIXME when aggregating content ensure that the result is XHTML2 compliant
+ * 
+ */
+public class AggregateInteralDocument extends InternalDocument {
+
+	private List<InternalDocument> documents;
+
+	/**
+	 * Create a new Aggregate document containing all the supplied internal
+	 * documents.
+	 * 
+	 * @param intDocs
+	 */
+	public AggregateInteralDocument(final List<InternalDocument> internalDocs) {
+		this.documents = internalDocs;
+	}
+
+	@Override
+	public String getContentAsString() throws IOException {
+		final StringBuffer result = new StringBuffer("<aggregate>");
+		for (int i = 0; i < this.documents.size(); i++) {
+			result.append(this.documents.get(i).getContentAsString());
+		}
+		result.append("</aggregate>");
+		return result.toString();
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/AggregateInteralDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultOutputDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultOutputDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultOutputDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultOutputDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+/**
+ * The most basic of output documents. The document itself is nothing more than
+ * a String.
+ * 
+ */
+public class DefaultOutputDocument extends AbstractOutputDocument {
+
+	public DefaultOutputDocument(final String content) {
+		this.setContent(content);
+	}
+
+	@Override
+	public String getContentAsString() {
+		return this.content;
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultOutputDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultSourceDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultSourceDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultSourceDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DefaultSourceDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+import java.io.BufferedReader;
+
+/**
+ * A basic source document. It holds the document as a string.
+ * 
+ */
+public class DefaultSourceDocument extends AbstractSourceDocument {
+
+	public DefaultSourceDocument(final String content) {
+		this.setContent(content);
+		this.setComplete(true);
+	}
+
+	/**
+	 * Create a new stringSourceDocument that has partial data read from a
+	 * reader, and partial data left to be read.
+	 * 
+	 * @param fileData
+	 * @param reader
+	 * @param type
+	 *            The mime type of the document. May be null if unkown.
+	 */
+	public DefaultSourceDocument(final String fileData,
+			final BufferedReader reader, final String type) {
+		this.setContent(fileData);
+		this.setReader(reader);
+		this.setComplete(false);
+		this.setType(type);
+	}
+
+	public DefaultSourceDocument(final String content, final String type) {
+		this.setContent(content);
+		this.setComplete(true);
+		this.setType(type);
+	}
+}
\ No newline at end of file

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DocumentFactory.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DocumentFactory.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DocumentFactory.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DocumentFactory.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * The document factory creates instances of various types of document.
+ * 
+ */
+public class DocumentFactory {
+
+	/**
+	 * Reads as much of the supplied input stream as needed in order to identify
+	 * the type of document that should be created. Then it creates the document
+	 * and returns it.
+	 * 
+	 * @FIXME At present the whole file is read
+	 * 
+	 * @param is
+	 * @return
+	 * @throws IOException
+	 *             If there is a problem reading the document content from the
+	 *             InputStream
+	 */
+	public static AbstractSourceDocument getSourceDocumentFor(
+			final InputStream is) throws IOException {
+		return readFile(is);
+	}
+
+	/**
+	 * Read a string from an InputStream. Each time a chunk of the file is read
+	 * we try and work out what type of document we have. Once we know what it
+	 * is we return an IDocument instance that contains the data read so far and
+	 * the reader used to read the rest of the data.
+	 * 
+	 * @param is
+	 */
+	private static AbstractSourceDocument readFile(final InputStream is)
+			throws java.io.IOException {
+		AbstractSourceDocument doc = null;
+		final StringBuffer fileData = new StringBuffer(1024);
+		final BufferedReader reader = new BufferedReader(new InputStreamReader(
+				is));
+		char[] buf = new char[1000];
+		int numRead = 0;
+		String type = null;
+		while ((numRead = reader.read(buf)) != -1 && type == null) {
+			final String readData = String.valueOf(buf, 0, numRead);
+			fileData.append(readData);
+			buf = new char[1024];
+			if (fileData.toString().contains("<?xml")) {
+				type = getXMLDocumentType(fileData.toString());
+				if (type != null) {
+					doc = new XMLSourceDocument(fileData.toString(), reader,
+							type);
+				}
+			}
+		}
+		if (type == null) {
+			if (fileData.toString().contains("<?xml")) {
+				doc = new XMLSourceDocument(fileData.toString(), reader,
+						"application/xml");
+			} else {
+				doc = new DefaultSourceDocument(fileData.toString(), reader,
+						null);
+			}
+		}
+		return doc;
+	}
+
+	/**
+	 * Given a string that identifies the start of an XML document we look ahead
+	 * to see if there is a Doctype or a namespace definition that enables to
+	 * narrow down the type of XML document this is. If there is no clue to the
+	 * specific type of XML document we return null.
+	 * 
+	 * See http://www.ietf.org/rfc/rfc3023.txt for more inforamtion about XML
+	 * mime types and how to identify them.
+	 * 
+	 * @param string
+	 * @return
+	 */
+	private static String getXMLDocumentType(final String content) {
+		String type = null;
+		if (content.contains("http://www.w3.org/2002/06/xhtml2")) {
+			type = "org.w3c.xhtml2";
+		} else if (content.contains("http://forrest.apache.org/helloWorld.dtd")) {
+			type = "org.apache.forrest.hellowWorld";
+		}
+		return type;
+	}
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/DocumentFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/IDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/IDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/IDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/IDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+import java.io.IOException;
+
+/**
+ * A document contains all the necessary information for processing a resource.
+ * 
+ */
+public interface IDocument {
+
+	/**
+	 * Get the content of the document as a String.
+	 * 
+	 * @return
+	 * @throws IOException
+	 */
+	public String getContentAsString() throws IOException;
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/IDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/InternalDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/InternalDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/InternalDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/InternalDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+/**
+ * An InternalDocument is a document that has been converted from a Source
+ * IDocument into the internal Forrest XML format for processing.
+ * 
+ */
+public class InternalDocument extends AbstractDocument {
+
+	public InternalDocument() {
+	}
+
+	public InternalDocument(final String content) {
+		this.setContent(content);
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/InternalDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/XMLSourceDocument.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/XMLSourceDocument.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/XMLSourceDocument.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/XMLSourceDocument.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.document;
+
+import java.io.BufferedReader;
+
+/**
+ * A representation of an XML document.
+ * 
+ * @FIXME: at this time this is nothing more than a simple string representation
+ *         of the document
+ */
+public class XMLSourceDocument extends DefaultSourceDocument {
+
+	public XMLSourceDocument(final String fileData,
+			final BufferedReader reader, final String type) {
+		super(fileData, reader, type);
+	}
+
+	public XMLSourceDocument(final String content, final String type) {
+		super(content, type);
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/document/XMLSourceDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/LocationmapException.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/LocationmapException.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/LocationmapException.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/LocationmapException.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.exception;
+
+public class LocationmapException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 8900976832922111062L;
+
+	public LocationmapException(final String message) {
+		super(message);
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/LocationmapException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/ProcessingException.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/ProcessingException.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/ProcessingException.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/ProcessingException.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.exception;
+
+public class ProcessingException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -5175336575758457083L;
+
+	public ProcessingException(final String message, final Exception e) {
+		super(message, e);
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/ProcessingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/SourceException.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/SourceException.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/SourceException.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/SourceException.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.exception;
+
+/**
+ * Thrown when there is an unrecoverable error processing a source document.
+ * 
+ */
+public class SourceException extends RuntimeException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -7163983081957477821L;
+
+	public SourceException(final String message, final Throwable cause) {
+		super(message, cause);
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/SourceException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/UnknownProtocolException.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/UnknownProtocolException.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/UnknownProtocolException.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/UnknownProtocolException.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.exception;
+
+/**
+ * Thrown if we are trying to handle a URL with an unrecognised protocol.
+ * 
+ */
+public class UnknownProtocolException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 6071505540149764130L;
+
+	public UnknownProtocolException(final String message) {
+		super(message);
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/exception/UnknownProtocolException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/Location.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/Location.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/Location.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/Location.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.locationMap;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * A location is a possible source location for a given request URI. There may
+ * be more than one location for any request URI, each of the possible locations
+ * may be optional or requried.
+ * 
+ */
+public class Location {
+	private String requestPattern;
+
+	private boolean isRequired;
+
+	private URI sourceURI;
+
+	public Location(final String pattern, final URL sourceURL,
+			final boolean isRequired) throws URISyntaxException {
+		this.init(pattern, sourceURL.toURI(), isRequired);
+	}
+
+	/**
+	 * Construct a new Location from an XML node.
+	 * 
+	 * @param element
+	 * @throws URISyntaxException
+	 * @throws IOException
+	 */
+	public Location(final Node element) throws URISyntaxException, IOException {
+		String pattern = null;
+		String url = null;
+		boolean isOptional = false;
+
+		final NamedNodeMap atts = element.getAttributes();
+		pattern = atts.getNamedItem("pattern").getNodeValue();
+		final NodeList children = element.getChildNodes();
+		for (int i = 0; i < children.getLength(); i++) {
+			final Node child = children.item(i);
+			if (child.getNodeName().equals("source")) {
+				url = child.getAttributes().getNamedItem("href").getNodeValue();
+				final Node required = child.getAttributes().getNamedItem(
+						"required");
+				if (required != null) {
+					isOptional = required.getNodeValue().equals("false");
+				}
+			}
+		}
+		if (url.contains("classpath:")) {
+			final String path = url.substring(url.lastIndexOf(':') + 1);
+			final URL resourceURL = this.getClass().getResource(path);
+			if (resourceURL == null)
+				throw new IOException("Cannot find the resource: " + path);
+			URI uri;
+			if (url.indexOf("classpath:") != 0) {
+				final String psudeoProtocol = url.substring(0, url
+						.indexOf("classpath:") - 1);
+				final String ssp = resourceURL.toURI().toURL().toExternalForm();
+				uri = new URI(psudeoProtocol, ssp, null);
+			} else {
+				uri = resourceURL.toURI();
+			}
+			this.init(pattern, uri, isOptional);
+		} else {
+			this.init(pattern, new URI(url), isOptional);
+		}
+	}
+
+	private void init(final String pattern, final URI uri,
+			final boolean isOptional) throws URISyntaxException {
+		if (pattern == null)
+			throw new IllegalArgumentException(
+					"requestURIPattern cannot be null");
+		if (uri == null)
+			throw new IllegalArgumentException("sourceURI cannot be null");
+		this.setRequestPattern(pattern);
+		this.setSourceURI(uri);
+		this.setRequired(this.isRequired);
+	}
+
+	public boolean isRequired() {
+		return this.isRequired;
+	}
+
+	public void setRequired(final boolean isRequired) {
+		this.isRequired = isRequired;
+	}
+
+	public String getRequestPattern() {
+		return this.requestPattern;
+	}
+
+	public void setRequestPattern(final String pattern) {
+		this.requestPattern = pattern;
+	}
+
+	public URL getSourceURL() throws MalformedURLException {
+		return this.getSourceURI().toURL();
+	}
+
+	public void setSourceURL(final URL sourceURL) throws URISyntaxException {
+		this.setSourceURI(sourceURL.toURI());
+	}
+
+	public URI getSourceURI() {
+		return this.sourceURI;
+	}
+
+	public void setSourceURI(final URI sourceURI) {
+		this.sourceURI = sourceURI;
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/Location.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/LocationMap.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/LocationMap.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/LocationMap.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/LocationMap.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.locationMap;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.forrest.core.exception.LocationmapException;
+import org.apache.xerces.parsers.DOMParser;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import com.sun.org.apache.regexp.internal.RE;
+import com.sun.org.apache.regexp.internal.RESyntaxException;
+
+/**
+ * A locationmap is a collection of all mappings from a request URI to source
+ * URLs.
+ * 
+ */
+public class LocationMap {
+	private final Map<String, List<Location>> locations = new HashMap<String, List<Location>>();
+
+	/**
+	 * Create a new locationmap, configured by the file at the given path within
+	 * the classpath.
+	 * 
+	 * @param locationmapPath
+	 * @throws URISyntaxException
+	 * @throws MalformedURLException
+	 * @throws IOException
+	 * @throws SAXException
+	 */
+	public LocationMap(final String locationmapPath) throws URISyntaxException,
+			SAXException, IOException {
+		final File file = new File(locationmapPath);
+		final URL lmURL = file.toURL();
+
+		final DOMParser parser = new DOMParser();
+		parser.parse(lmURL.toString());
+		final Document doc = parser.getDocument();
+		final Node root = doc.getDocumentElement();
+		final NodeList nodes = root.getChildNodes();
+
+		for (int i = 0; i < nodes.getLength(); i++) {
+			final Node element = nodes.item(i);
+			if (element.getNodeName().equals("location")) {
+				this.put(new Location(element));
+			}
+		}
+	}
+
+	/**
+	 * Adds a location to the possible locations for a given requestURI.
+	 * 
+	 * @param requestURI
+	 * @param location
+	 */
+	public void put(final Location location) {
+		List<Location> sourceLocations = this.locations.get(location
+				.getRequestPattern());
+		if (sourceLocations == null)
+			sourceLocations = new ArrayList<Location>();
+		if (sourceLocations.contains(location) == false)
+			sourceLocations.add(location);
+		this.locations.put(location.getRequestPattern(), sourceLocations);
+	}
+
+	/**
+	 * Get the all matching sets of locations for the given URI.
+	 * 
+	 * @param requestURI
+	 * @return
+	 * @throws MalformedURLException
+	 *             if the Request URI is invalid
+	 * @throws LocationmapException
+	 */
+	public List<List<Location>> get(final URI requestURI)
+			throws MalformedURLException, LocationmapException {
+		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));
+			} catch (final RESyntaxException e) {
+				throw new LocationmapException(
+						"Pattern is not a valid regular expression (" + pattern
+								+ "): " + e.getMessage());
+			}
+		}
+		return results;
+	}
+
+	/**
+	 * Test to see if this location is applicable to a given request URI.
+	 * 
+	 * @param requestURI
+	 * @return
+	 * @throws MalformedURLException
+	 * @throws MalformedURLException
+	 *             if the request URI cannot be converted to a valid URL
+	 * @throws RESyntaxException
+	 *             if the pattern supplied is not a valid regular expression
+	 * @FIXME use pattern matching to test for a match
+	 */
+	public boolean isMatch(final String pattern, final URI requestURI)
+			throws MalformedURLException, RESyntaxException {
+		URL url;
+		try {
+			url = requestURI.toURL();
+		} catch (final IllegalArgumentException e) {
+			// we'll assume that this is not an absolute URL and therefore
+			// refers to a file
+			url = new URL("file://" + requestURI);
+		}
+		final String urlString = url.toExternalForm();
+
+		final RE r = new RE(pattern);
+		return r.match(urlString);
+	}
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/locationMap/LocationMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/AbstractInputPlugin.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/AbstractInputPlugin.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/AbstractInputPlugin.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/AbstractInputPlugin.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.plugin;
+
+/**
+ * An output plugin processes an internal document and produces a document ready
+ * for output.
+ * 
+ * @TODO it seems that there are no implemented methods left here, perhaps we
+ *       should deprecate it
+ */
+public abstract class AbstractInputPlugin implements IPlugin {
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/AbstractInputPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/BaseOutputPlugin.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/BaseOutputPlugin.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/BaseOutputPlugin.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/BaseOutputPlugin.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.plugin;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.apache.forrest.core.document.DefaultOutputDocument;
+import org.apache.forrest.core.document.IDocument;
+import org.apache.regexp.RE;
+
+/**
+ * A base output plugin from which all other output plugins should be etended.
+ * This plugin does not actually do anything, it is essentially a pass through
+ * plugin.
+ * 
+ */
+public class BaseOutputPlugin implements IOutputPlugin {
+
+	String requestURIPattern;
+
+	/**
+	 * Get the pattern that a requestURI must match for this plugin to be
+	 * applied to the internal documents.
+	 */
+	public String getPattern() {
+		return this.requestURIPattern;
+	}
+
+	/**
+	 * Set the URI pattern this plugin should match befre being applied.
+	 * 
+	 * @param requestURIPattern
+	 */
+	public void setPattern(final String requestURIPattern) {
+		this.requestURIPattern = requestURIPattern;
+	}
+
+	/**
+	 * Tests to see if there is match between this plugins request URI pattern
+	 * and a given request URI.
+	 * 
+	 * @param requestURI
+	 * @return
+	 * @fixme implement proper matching
+	 */
+	public boolean isMatch(final URI requestURI) {
+		final RE r = new RE(this.getPattern());
+		return r.match(requestURI.getPath());
+	}
+
+	public IDocument process(final IDocument doc) throws IOException {
+		return new DefaultOutputDocument(doc.getContentAsString());
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/BaseOutputPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IOutputPlugin.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IOutputPlugin.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IOutputPlugin.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IOutputPlugin.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.plugin;
+
+public interface IOutputPlugin extends IPlugin {
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IOutputPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IPlugin.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IPlugin.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IPlugin.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IPlugin.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.plugin;
+
+import java.io.IOException;
+
+import org.apache.forrest.core.document.IDocument;
+
+public interface IPlugin {
+
+	/**
+	 * Process an input document producing a document in the internal Forrest
+	 * format.
+	 * 
+	 * @param doc
+	 * @return
+	 * @throws IOException
+	 */
+	public IDocument process(IDocument doc) throws IOException;
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/IPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/PassThroughInputPlugin.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/PassThroughInputPlugin.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/PassThroughInputPlugin.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/PassThroughInputPlugin.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.core.plugin;
+
+import java.io.IOException;
+
+import org.apache.forrest.core.document.IDocument;
+import org.apache.forrest.core.document.InternalDocument;
+
+/**
+ * This is plugin does not process the content in any way, it simply repackages
+ * the sourceDocument as an internal document. It will be applied if no other
+ * plugin is available that is suitable for the source document.
+ * 
+ */
+public class PassThroughInputPlugin extends AbstractInputPlugin {
+
+	public IDocument process(final IDocument doc) throws IOException {
+		return new InternalDocument(doc.getContentAsString());
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/PassThroughInputPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message