forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r476384 [2/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
Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTInputPlugin.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTInputPlugin.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTInputPlugin.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTInputPlugin.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,108 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.forrest.core.document.IDocument;
+import org.apache.forrest.core.document.InternalDocument;
+
+/**
+ * A plugin that performs an XSLT transformation on a source documents to create
+ * an internal representation of the document.
+ * 
+ */
+public class XSLTInputPlugin extends AbstractInputPlugin {
+
+	private URL xsltURL;
+
+	public XSLTInputPlugin() {
+		super();
+	}
+
+	/**
+	 * Create an XSLTInputPlugin. If the xsltURL supplied contains a ':' then it
+	 * is assumed it is a complete URL otherwise it is assumed that it is a
+	 * classpath referenced file.
+	 * 
+	 * @param xsltURL
+	 * @throws MalformedURLException
+	 */
+	public XSLTInputPlugin(final String xsltURL) throws MalformedURLException {
+		if (xsltURL.contains(":")) {
+			this.setXsltURL(new URL(xsltURL));
+		} else {
+			this.setXsltURL(this.getClass().getResource(xsltURL));
+			if (this.getXsltURL() == null)
+				throw new MalformedURLException(
+						"Unable to get an URL for the resource " + xsltURL);
+		}
+	}
+
+	public IDocument process(final IDocument doc) throws IOException {
+		final TransformerFactory tFactory = TransformerFactory.newInstance();
+
+		try {
+			final URI uri = this.getXsltURL().toURI();
+			final String path = uri.getSchemeSpecificPart();
+			final File xslt = new File(path);
+			Transformer transformer;
+			transformer = tFactory.newTransformer(new StreamSource(xslt));
+			final StringReader reader = new StringReader(doc
+					.getContentAsString());
+			final StreamSource in = new StreamSource(reader);
+			final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+			final StreamResult out = new StreamResult(outStream);
+			transformer.transform(in, out);
+			return new InternalDocument(outStream.toString());
+		} catch (final TransformerConfigurationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		} catch (final TransformerException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		} catch (final URISyntaxException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	public URL getXsltURL() {
+		return this.xsltURL;
+	}
+
+	public void setXsltURL(final URL xsltURL) {
+		this.xsltURL = xsltURL;
+	}
+}

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

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTOutputPlugin.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTOutputPlugin.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTOutputPlugin.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/core/plugin/XSLTOutputPlugin.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,92 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.forrest.core.document.DefaultOutputDocument;
+import org.apache.forrest.core.document.IDocument;
+
+/**
+ * A plugin that performs an XSLT transformation on the internal documents to
+ * create the output document.
+ * 
+ */
+public class XSLTOutputPlugin extends BaseOutputPlugin {
+
+	private String xsltPath;
+
+	private XSLTOutputPlugin() {
+		super();
+	}
+
+	public XSLTOutputPlugin(final String requestURI) {
+		this.setPattern(requestURI);
+	}
+
+	@Override
+	public IDocument process(final IDocument doc) throws IOException {
+		final TransformerFactory tFactory = TransformerFactory.newInstance();
+
+		try {
+			final String xsltURL = this.getClass().getResource(
+					this.getXsltPath()).toExternalForm();
+			final File xslt = new File(new URI(xsltURL));
+			Transformer transformer;
+			transformer = tFactory.newTransformer(new StreamSource(xslt));
+			final StringReader reader = new StringReader(doc
+					.getContentAsString());
+			final StreamSource in = new StreamSource(reader);
+			final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+			final StreamResult out = new StreamResult(outStream);
+			transformer.transform(in, out);
+			return new DefaultOutputDocument(outStream.toString());
+		} catch (final TransformerConfigurationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		} catch (final TransformerException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		} catch (final URISyntaxException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	public String getXsltPath() {
+		return this.xsltPath;
+	}
+
+	public void setXsltPath(final String xsltURL) {
+		this.xsltPath = xsltURL;
+	}
+}

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

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/AbstractReader.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/AbstractReader.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/AbstractReader.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/AbstractReader.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,25 @@
+/*
+ * 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.reader;
+
+public abstract class AbstractReader implements IReader {
+
+	public AbstractReader() {
+		this.init();
+	}
+
+}

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

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/FileReader.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/FileReader.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/FileReader.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/FileReader.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,64 @@
+/*
+ * 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.reader;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.forrest.core.document.AbstractSourceDocument;
+import org.apache.forrest.core.document.DocumentFactory;
+import org.apache.forrest.core.exception.SourceException;
+import org.apache.forrest.core.locationMap.Location;
+
+/**
+ * An File reader reads a resource using the file protocol, i.e. it will read
+ * from local storage.
+ * 
+ */
+public class FileReader extends AbstractReader {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.forrest.reader.IReader#init()
+	 */
+	public void init() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.forrest.reader.IReader#read(org.apache.forrest.test.core.locationMap.Location)
+	 */
+	public AbstractSourceDocument read(final Location location) {
+		AbstractSourceDocument result = null;
+		try {
+			final InputStream is = new FileInputStream(new File(location
+					.getSourceURL().toURI()));
+			result = DocumentFactory.getSourceDocumentFor(is);
+		} catch (final Exception e) {
+			if (location.isRequired())
+				throw new SourceException("Source URL is invalid", e);
+		}
+		return result;
+	}
+
+	public String getScheme() {
+		return "file";
+	}
+}

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

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/HTTPReader.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/HTTPReader.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/HTTPReader.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/HTTPReader.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,82 @@
+/*
+ * 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.reader;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.forrest.core.document.AbstractSourceDocument;
+import org.apache.forrest.core.document.DefaultSourceDocument;
+import org.apache.forrest.core.exception.SourceException;
+import org.apache.forrest.core.locationMap.Location;
+import org.w3c.tidy.Tidy;
+
+/**
+ * An HTTP reader reads a resource using the HTTP protocol.
+ * 
+ */
+public class HTTPReader extends AbstractReader {
+	private HttpClient client;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.forrest.reader.IReader#init()
+	 */
+	public void init() {
+		this.client = new HttpClient(new MultiThreadedHttpConnectionManager());
+		this.client.getHttpConnectionManager().getParams()
+				.setConnectionTimeout(30000);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.forrest.reader.IReader#read(org.apache.forrest.test.core.locationMap.Location)
+	 */
+	public AbstractSourceDocument read(final Location location)
+			throws MalformedURLException {
+		InputStream is;
+		DefaultSourceDocument result = null;
+		final ByteArrayOutputStream out = new ByteArrayOutputStream();
+		final GetMethod get = new GetMethod(location.getSourceURL()
+				.toExternalForm());
+		get.setFollowRedirects(true);
+		try {
+			this.client.executeMethod(get);
+			is = get.getResponseBodyAsStream();
+			final Tidy tidy = new Tidy();
+			tidy.setXHTML(true);
+			tidy.parseDOM(is, out);
+			result = new DefaultSourceDocument(out.toString());
+		} catch (final Exception e) {
+			if (location.isRequired())
+				throw new SourceException("Source URL is invalid", e);
+		} finally {
+			get.releaseConnection();
+		}
+		return result;
+	}
+
+	public String getScheme() {
+		return "http";
+	}
+}

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

Added: forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/IReader.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/IReader.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/IReader.java (added)
+++ forrest/trunk/whiteboard/forrest2/core/org/apache/forrest/reader/IReader.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,51 @@
+/*
+ * 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.reader;
+
+import java.net.MalformedURLException;
+
+import org.apache.forrest.core.document.AbstractSourceDocument;
+import org.apache.forrest.core.locationMap.Location;
+
+public interface IReader {
+
+	/**
+	 * Initialise the reader. This method is called by the readers constructors
+	 * and should prepare the reader for operation.
+	 * 
+	 */
+	abstract void init();
+
+	/**
+	 * Read a resource from a given location. If the resource cannot be read,
+	 * but it is an optional location then return null, if it cannot be read and
+	 * it is a required location throw SourceException.
+	 * 
+	 * @param location
+	 * @return
+	 * @throws MalformedURLException
+	 */
+	public abstract AbstractSourceDocument read(Location location)
+			throws MalformedURLException;
+
+	/**
+	 * Get the scheme that this reader handles.
+	 * 
+	 * @return
+	 */
+	public abstract String getScheme();
+}
\ No newline at end of file

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

Added: forrest/trunk/whiteboard/forrest2/ivy.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/ivy.xml?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/ivy.xml (added)
+++ forrest/trunk/whiteboard/forrest2/ivy.xml Fri Nov 17 16:12:01 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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.
+-->
+<ivy-module version="1.0">
+    <info 
+        organisation="SAAfE"
+        module="forreest2"
+        status="integration">
+	</info>
+	<dependencies>
+	    <dependency org="apache" name="commons-httpclient" rev="latest.milestone" />
+	    <dependency org="apache" name="commons-codec" rev="latest.release" />
+	    <dependency org="apache" name="commons-logging" rev="latest.release"/>
+	    <dependency org="apache" name="regexp" rev="latest.milestone" />
+	    <dependency org="apache" name="xerces" rev="latest.release"/>
+	    <dependency org="jtidy" name="jtidy" rev="latest.release"/>
+	    <dependency org="springframework" name="core" rev="latest.release"/>
+	</dependencies>
+</ivy-module>

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

Added: forrest/trunk/whiteboard/forrest2/ivyconf.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/ivyconf.xml?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/ivyconf.xml (added)
+++ forrest/trunk/whiteboard/forrest2/ivyconf.xml Fri Nov 17 16:12:01 2006
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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.
+-->
+<ivyconf>
+  <property name="local.repo.dir" value="C:\Documents and Settings\Ross Gardler\.ivy\local"/>
+  <property name="ibiblio-maven2-root" value="http://www.ibiblio.org/maven2/"/>
+  
+  <conf defaultResolver="default"/>
+  <resolvers>
+    <ivyrep name="ivyrep" ivyroot="http://ivyrep.jayasoft.org/"/>
+    <ivyrep name="ivyrepsandbox" ivyroot="http://opensvn.csie.org/ivyrepsandbox/"/>
+    <ibiblio name="ibiblio-maven2"
+                root="${ibiblio-maven2-root}"
+                pattern="${ibiblio-maven2-pattern}"
+                m2compatible="true"
+                namespace="ibiblio-maven2"
+    /> 
+    <filesystem name="local-repository">
+      <ivy pattern="${local.repo.dir}/[organisation]/[module]/ivy-[revision].xml"/>      
+      <artifact pattern="${local.repo.dir}/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"/>
+    </filesystem>
+      
+    <chain name="default" returnFirst="true">
+      <resolver ref="local-repository"/>
+      <ivyrep name="ivyrep"/>
+      <ivyrep name="ivyrepsandbox"/>
+      <ibiblio name="ibiblio-maven2"/>
+    </chain>
+  </resolvers>
+</ivyconf>
\ No newline at end of file

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

Added: forrest/trunk/whiteboard/forrest2/src/conf/defaultForrestContext.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/conf/defaultForrestContext.xml?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/conf/defaultForrestContext.xml (added)
+++ forrest/trunk/whiteboard/forrest2/src/conf/defaultForrestContext.xml Fri Nov 17 16:12:01 2006
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>	
+	
+	<!-- ============================================= -->
+	<!--               Input Plugins                   -->
+	<!-- ============================================= -->
+
+	<!-- ============================================= -->
+	<!--               Output Plugins                  -->
+	<!-- ============================================= -->
+
+	<bean id="html"
+		class="org.apache.forrest.core.plugin.XSLTOutputPlugin">
+		<property name="pattern" value="html" />
+		<property name="xsltPath"
+			value="/xdocs/samples/xslt/internal-to-html.xsl" />
+	</bean>
+
+	<!-- ============================================= -->
+	<!--                  Readers                      -->
+	<!-- ============================================= -->
+
+	<bean id="http" class="org.apache.forrest.reader.HTTPReader"></bean>
+	<bean id="file" class="org.apache.forrest.reader.FileReader"></bean>
+
+</beans>

Propchange: forrest/trunk/whiteboard/forrest2/src/conf/defaultForrestContext.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/conf/locationmap.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/conf/locationmap.xml?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/conf/locationmap.xml (added)
+++ forrest/trunk/whiteboard/forrest2/src/conf/locationmap.xml Fri Nov 17 16:12:01 2006
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<locationmap>
+  <location pattern="http://localhost:8888/xhtml/testPage.html">
+    <source href="classpath:/xdocs/samples/xhtml2/sample_complete.html"/>
+  </location>
+    
+  <location pattern="http://localhost:8888/test/helloWorld.html">
+    <source href="classpath:/xdocs/samples/xml/helloWorld.xml"/>
+  </location>
+</locationmap>
\ No newline at end of file

Propchange: forrest/trunk/whiteboard/forrest2/src/conf/locationmap.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/docs/createAPlugin.html
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/docs/createAPlugin.html?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/docs/createAPlugin.html (added)
+++ forrest/trunk/whiteboard/forrest2/src/docs/createAPlugin.html Fri Nov 17 16:12:01 2006
@@ -0,0 +1,236 @@
+<!--
+  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.
+-->
+<html>
+<body>
+
+<h1>How to create an input plugin</h1>
+
+<p>The first thing to do when creating an input plugin is to decide if
+you can best achieve your objectives using XSLT or Java. Generally, if
+your input document is an XML document then you should use XSLT, 
+otherwise you will need to use Java.</p>
+
+<h2>Creating an XSLT Plugin</h2>
+
+<p>Creating an XSLT plugin is a matter of creating an XSLT stylesheet
+and registering a copy of the XSLTInputPlugin that will use your
+stylesheet.</p>
+
+<p>An XSLT plugin has two defining properties. One is the URL
+of the XSLT file to be used, the other is a property that defines
+what type of document can be processed by this plugin.</p>
+
+<h3>Register the Plugin</h3>
+
+<p>Plugins are registered with Forrest2 using the Spring Framework.
+This means that you need to add an entry to the forrestContext.xml
+file, such as:</p>
+
+<![CDATA[  <bean id="helloWorldXSLTInput"
+    class="org.apache.forrest.test.core.plugins.input.HelloWorldInputPlugin"/>]]>
+
+<p>The Forrest controller will read all the files that it finds in the classpath tat
+match this naming convention.</p>
+
+
+
+<h2>Creating an Java Plugin</h2>
+
+<h3>Create a new java project to house your plugin</h3>
+
+<h3>Create a class file that will be the controller for the plugin.</h3>
+<p>This should extend the abstact class <br/>
+	org.apache.forrest.core.plugins.input.AbstractInputPlugin</p>
+
+<p>You must implement the following two methods:</p>
+<div class="code"><pre>
+	public IDocument process(IDocument doc)
+	public String getInputType()
+</pre></div>
+
+<p>The getInputType method returns a string that uniquely identifies 
+the document type that this plugin is able to process. It is advisable
+to follow a naming convention here. We suggest:</p>
+
+<p>If the document has a suitably unique mime-type then use that.</p>
+
+<p>If the document is an XML document with a Doctype then use the URI
+of that doctype.</p>
+
+<p>If the above guidelines do not suggest a suitable type string then 
+we recomend you us a notation similar to the naming of java classes.
+For example org.foo.document.type.</p>
+
+<p>The process method should create an instance of an 
+	org.apache.forrest.core.document.InternalDocument by performing whatever
+	process is required to generate an internal Forrest document from the
+	source docuemnt.</p>
+
+<h3>Register the Plugin</h3>
+
+<p>Plugins are registered with Forrest2 using the Spring Framework.
+This means that you need to add an entry to the forrestContext.xml
+file, such as:</p>
+
+<![CDATA[  <bean id="helloWorldInput"
+    class="org.apache.forrest.test.core.plugins.input.HelloWorldInputPlugin"/>]]>
+
+<p>The Forrest controller will read all the files that it finds in the classpath tat
+match this naming convention.</p>
+
+
+
+
+=================
+An Example Plugin
+=================
+
+So lets look at a plugin example. Of course, we will start with 
+the traditional HelloWorld example. This plugin will produce 
+a document with a "Hello World" message. The contents of the source 
+document is irrelevant in this case.
+
+Here's the plugin class:
+
+package org.apache.forrest.test.core.plugins.input;
+
+import org.apache.forrest.core.document.IDocument;
+import org.apache.forrest.core.document.InternalDocument;
+import org.apache.forrest.core.plugin.AbstractInputPlugin;
+
+/**
+ * A very simple plugin that alwasy produces a Hello World document,
+ * regardless of the input document.
+ *
+ */
+public class HelloWorldInputPlugin extends AbstractInputPlugin {
+
+	public static final String CONTENT = "<html xmlns=\"http://www.w3.org/2002/06/xhtml2\" xml:lang=\"en\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2002/06/xhtml2/ http://www.w3.org/MarkUp/SCHEMA/xhtml2.xsd\">  <head>    <title>XHTML 2 Simple Sample Page</title>   </head>  <body>  <h>Hellow World</h>  </body></html>";
+
+	public IDocument process(IDocument doc) {
+		return new InternalDocument(CONTENT);
+	}
+
+	@Override
+	public String getInputType() {
+		return "http://forrest.apache.org/helloWorld.dtd";
+	}
+}
+
+Once registered with the InputPluginFactory we can provide an instance of the
+org.apache.forrest.test.document.HelloWorldPluginTest class and Forrest will
+then use this plugin to produce a new InternalDocument with a simple Hello 
+World message.
+
+==============================
+How to create an Output Plugin
+==============================
+
+TODO
+
+======================
+How to create a Reader
+======================
+
+A reader is respponsible for creating the initial source content. Forrest provides
+a set of generic readers that can retrieve a document from the network or from the
+filesystem. These documents will oftern need to be processed by an input plugin to
+create a document in Forrests internal format.
+
+<p>To read a document from a non-standard resource, for example, to read a document
+from a relational database, we will need to implement a custom reader. To do this
+we extend <code>org.apache.forrest.reader.AbstractReader</code>. This abstract class
+requires the following methods to be implemented:</p>
+
+<code><![CDATA[
+    /**
+	 * Initialise the reader. This method is called by the readers
+	 * constructors and should prepare the reader for operation.
+	 *
+	 */
+	abstract void init();
+
+	/**
+	 * Read a resource from a given location. If the resource
+	 * cannot be read, but it is an optional location then return null,
+	 * if it cannot be read and it is a required location throw
+	 * SourceException.
+	 * 
+	 * @param location
+	 * @return
+	 */
+	public abstract AbstractSourceDocument read(Location location);
+
+	/**
+	 * Get the scheme that this reader handles.
+	 * @return
+	 */
+	public abstract String getscheme();
+]]></code>
+
+<p>The init() method provides any necessary configuration. This method is called once during
+creation of the reader object. The read(Location location) method performs the actual "read"
+of the document. The getscheme() method defines a scheme or psuedo scheme that this
+reader will respond to. It is used by Forrest core to select the correct reader for a given
+location. We will discuss this method in more detail first, then we will look at the read
+method.</p>
+
+<p>The scheme can be any string that represents the type of reader we are building. For 
+example, if we are building a reader that will provide documents representing products in 
+a catalogue database then we may choose a scheme of "product" (note that we don't
+include the ':'). This will then be used
+in the locationmap to indicate a product document. For example, we may have a location
+defined as: </p>
+
+<code><![CDATA[
+  <location pattern="http://localhost:8888/test/product.html">
+    <source href="product:/1"/>
+  </location>
+]]></code>
+
+<p>This entry means that a request for <code>http://localhost:8888/test/product.html</code>
+will result in a request to the reader assigned the <code>product</code> scheme. To
+actually read the document Forrest will call the <code>read(Location location)</code>
+method.</p>
+
+<p>The <code>read(Location location)</code> method will process the request in whatever
+way is appropriate for that particular scheme. In this case it will communicate with
+the database to retrieve the product with ID 1.</p>
+
+Register Reader
+---------------
+
+----
+NOTE
+----
+At present a plugin needs to add itself by editing the core config documents. This will
+change shortly.
+
+Once you have built your reader then you need to register it with Forrest. This is done
+by adding an entry to the <code>applicationContext-readers.xml</code>. The entry should
+look something like this:
+
+<code><![CDATA[
+  <bean id="product" 
+    class="org.foo.forrest.reader.ProductReader">
+  </bean>
+]]></code>
+
+<p>Note that the beans id is the same as the scheme defined in the reader. This
+is how Forrest will lookup the correct reader for any given location.</p>
+</body>
+</html>
\ No newline at end of file

Propchange: forrest/trunk/whiteboard/forrest2/src/docs/createAPlugin.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/docs/examples/affiliateProductCatalogue.html
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/docs/examples/affiliateProductCatalogue.html?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/docs/examples/affiliateProductCatalogue.html (added)
+++ forrest/trunk/whiteboard/forrest2/src/docs/examples/affiliateProductCatalogue.html Fri Nov 17 16:12:01 2006
@@ -0,0 +1,186 @@
+<!--
+  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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Affiliates Product Catalogue</title>
+</head>
+<body>
+<h3>Affiliates Product Catalogue</h3>
+
+<p class="todo">In this example we create an input plugin to use
+product feeds from affiliate programs (in this case
+TradeDoubler). This is then coupled with an output plugin
+that presents this data as an HTML page for inclusion in
+a web site.</p>
+
+<h4>About the Product Feed</h4>
+
+<p><a href="http://www.tradedoubler.com">Trade Doubler</a> is an 
+affiliate programme in which some members provide XML feeds 
+of their products. To retrieve these feeds you will need to 
+register on the tradedoubler site. However, in order to see
+this example in action we have provided a sample document
+in <span class="source">src/examples/affiliateProductCatalogue/src/xdocs/exampleFeed.xml</span>.</p>
+
+<h4>Creating a TradeDoubler Reader</h4>
+
+<p>TradeDoubler XML feeds are not Valid XML documents, that
+is they do not have a DTD definition within them. This means
+that we have to create a Reader to read these documents for 
+us and assign a type to them so that Forrest knows how to 
+process them in subsequent stages.</p>
+
+<p>In a production system this reader would pull the feed from
+the TradeDoubler site, however, since we want to run this
+example without creating a TradeDoubler account we will create
+simple file reader that will retrieve our example feed document.
+The code for this reader is provided in 
+<span class="source">src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/reader/TradeDoubler.java</span>.</p>
+
+<p>Note that this reader returns a document with the type
+<span class="source">org.apache.forrest.example.affiliateProductCatalogue.TradeDoublerProductFeed</span>.
+We will need to use this type value to select the correct
+input plugin to use. If you wanted to convert this example
+to work with real live trade doubler accounts you would
+need to extend te httpReader in the same way that this class
+extends the fileReader.</p>
+
+<p>Having written a reader for our TradeDoubler we must register it
+with Forrest. Just add the following line to your forrestContext.xml
+file.</p>
+
+<code><![CDATA[
+	<bean id="tradeDoubler"
+		class="org.apache.forrest.examples.affiliateProductCatalogue.reader.TradeDoubler" />
+]]></code>
+
+<p>This bean definition registers our new reader with the psudo protocol
+<span class="source">tradeDoubler</span>. So, lets add a locationmap entry
+to read our example feed:</p>
+
+<code><![CDATA[
+  <location pattern="tradeDoubler.*">
+    <source href="tradeDoubler:classpath:/xdocs/exampleFeed.xml"/>
+  </location>
+]]></code>
+
+<p>Notice how we use the <span class="source">tradeDoubler</span> psuedo protocol
+to tell Forrest which reader to use.</p>
+
+<h5>Checking our Progress</h5>
+
+<p>At this point we can check everything works. We should be
+able to retrieve our source document by requesting 
+<span class="source">tradeDoubler.forrestSource</span>. We'll
+ use the CLI to test this.</p>
+
+<p class="code">
+cd [FORREST_HOME]/src/examples/afiliateProductCatalogue
+java -jar [FORREST_HOME]/forrest.jar org.apache.forrest.cli.CLI tradeDoubler.forrestSource
+</p>
+
+<h4>Creating the Input Plugin</h4>
+
+<p class="note">A more complete description of creating an Input
+plugin is provided in the <a href="createAPlugin.html">Create a Plugin</a>
+How To.</p>
+
+<p>Since the TradeDoubler feeds are XML our input plugin is just
+a standard XSL transformation. Such plugins can be created without
+having to write any Java code, but we will, of course, need
+an XSLT file to convert from the XML product feed to Forrests
+internal format.</p>
+
+<p>Our XSLT is found in <span class="source">src/examples/affiliateProductCatalogue/src/xslt/tradeDoublerFeed-to-internal.xsl</span>
+to define our input plugin we just need to add the following to
+forresContext.xml</p>
+
+<code><![CDATA[
+	<bean id="org.apache.forrest.example.affiliateProductCatalogue.TradeDoublerProductFeed"
+		class="org.apache.forrest.core.plugin.XSLTInputPlugin">
+		<property name="xsltURL"
+			value="/src/xslt/tradeDoublerFeed-to-internal.xsl" />
+	</bean>
+]]></code>
+
+<p>Note how we use an ID that is the same as the document type
+created by our reader.</p>
+
+<h5>Checking our Progress</h5>
+
+<p>Now we can check that the internal document generation
+works OK. We should be
+able to retrieve our internal document by requesting 
+<span class="source">tradeDoubler.forrestInternal</span>. 
+Use the CLI to test this:</p>
+
+<p class="code">
+cd [FORREST_HOME]/src/examples/afiliateProductCatalogue
+java -jar [FORREST_HOME]/forrest.jar org.apache.forrest.cli.CLI tradeDoubler.forrestInternal
+</p>
+
+<h>Generating HTML</h>
+
+<p>Since an HTML output plugin is only an XSLT transformation
+we need only configure a version of the XSLTOutputPlugin. To do
+this we need to add the following to our forrestContext.xml:</p>
+
+<code><![CDATA[
+	<bean id="htmlOutputPlugin"
+		class="org.apache.forrest.core.plugin.XSLTOutputPlugin">
+		<property name="pattern" value=".*(html|htm)" />
+		<property name="xsltPath"
+			value="/xdocs/samples/xslt/internal-to-html.xsl" />
+	</bean>
+]]></code>
+
+<p class="todo">The above location of the xsltPath will need
+to change to someting more permanent.</p>
+
+<p>In this case the id attribute, unlike with readers and 
+input plugins, can be any unique value. The pattern property
+defines which request URLs should be processed by this output
+plugin. In this case, any URL ending in either "html" or 
+"htm" will be processed by this plugin. This property
+is a Regular Expression so you can define some very complex
+pattern matching rules here.</p>
+
+<h5>Checking our Progress</h5>
+
+<p>Now we can check that the html document generation
+works OK. We should be
+able to retrieve our html document by requesting 
+<span class="source">tradeDoubler.html</span>. 
+Use the CLI to test this:</p>
+
+<p class="code">
+cd [FORREST_HOME]/src/examples/afiliateProductCatalogue
+java -jar [FORREST_HOME]/forrest.jar org.apache.forrest.cli.CLI tradeDoubler.html
+</p>
+
+<p>Whilst we are at it, lets check the other potential URL for
+this document:</p>
+
+<p class="code">
+cd [FORREST_HOME]/src/examples/afiliateProductCatalogue
+java -jar [FORREST_HOME]/forrest.jar org.apache.forrest.cli.CLI tradeDoubler.htm
+</p>
+
+</body>
+</html>
\ No newline at end of file

Propchange: forrest/trunk/whiteboard/forrest2/src/docs/examples/affiliateProductCatalogue.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/docs/howDoesItWork.html
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/docs/howDoesItWork.html?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/docs/howDoesItWork.html (added)
+++ forrest/trunk/whiteboard/forrest2/src/docs/howDoesItWork.html Fri Nov 17 16:12:01 2006
@@ -0,0 +1,133 @@
+<!--
+  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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>How Does It Work</title>
+</head>
+<body>
+
+<h1>Overview</h1>
+
+<p>Forrest uses three major components in its processing:</p>
+
+<ol>
+  <li>Readers - read source documents</li>
+  <li>Input Plugins - converts source documents to 
+  the internal Forrest format</li>
+  <li>Output Plugins - converts internal format documents to
+  the requried output format</li>
+</ol>
+
+<p>Different implementations of each of these components
+allow different processing to take place. For example,
+different readers will retrieve the source document using
+different methods, such as HTTP, FTP or SSH. Different 
+input plugins will allow different types of source document
+to be processed and different output plugins will provide
+different output formats such as HTML, PDF or OpenOffice.org</p>
+
+<p>In the followin sections we will examine how the Forrest
+controller selets which reader, input and ouput plugins to use
+for any particular request.</p>
+
+<h2>Selecting Readers</h2>
+
+<p>Which reader is used to read a source document is defined
+by the protocol used in the location URL. Note that this
+has nothing to do with the request URL, it is defined in
+the locationmap for the Forrest content object. So, for example,
+if the source location of a file is defined as 
+<span class="source">file://foo/bar.html</span> the reader
+defined to handle "file:" requests will be used.</p>
+
+<p>To define a reader for a specific protocol we add a bean 
+definition to our content objects forestContext.xml file. 
+The ID of the bean should be the name of the protocol we wish
+process with this reader. For example:</p>
+
+<p class="source"><![CDATA[
+  	<bean id="file" class="org.apache.forrest.reader.FileReader"></bean>
+]]></p>
+
+<h3>What Source Type?</h3>
+
+<p>A reader creates a source document object that is used in
+the next stage of processing. This source document is an object
+that extends <span class="source">AbstractSourceDocument</span>.
+A method <span class="source">getType</span> returns a string
+identifying the type of document represented. This string is
+used in the next stage of processing, which is selecting an
+Input plugin to convert the source document to our internal
+format.</p>
+
+<p>A <span class="source">DocumnetFactory</span> is provided
+by core that attempts to identify the source document type.
+This factory is used by the default readers provided by core.
+However, in some cases, such as when an XML document does not
+provide a DTD definition that can be used to identify the
+document type, you will need to create a custom reader that
+returns the correct document type. In this case the utility
+class <span class="source">DefaultSourceDocument</span> 
+will probably be useful (see the 
+<span class="source">setType</span> method).</p>
+
+<h2>Selecting Input Plugins</h2>
+
+<p>Each input plugin will process a single type of source 
+document. Each document is defined by a "type", this is 
+set by the reader that reads the document. In many cases
+this will be a MIME type, but where no suitably specific
+MIME type exists, such as an XML document, an arbitrary 
+string can be used.</p>
+
+<p>When selecting an input plugin to be used the documents
+type is utilised to lookup the correct input plugin. To 
+facilitate this lookup we again use the ID of the input
+plugins bean as defined in the forrestContext.xml file. For
+example, the following will process documents of type bar:</p>
+
+<p class="source"><![CDATA[
+	<bean id="bar" class="bar.Foo"/>
+]]></p>
+
+<h2>Selecting an Output Plugin</h2>
+
+<p>An output plugin is selected by looking at the request URL
+of the. This URL is matched against an output plugin by looking
+at an "pattern" property in the bean that implements the plugin.
+The first bean that is found where the request URL matches the
+supplied pattern will be used to process the output. 
+In addition to the pattern property an output plugin 
+specifies an XSLT file that is used to convert the internal 
+format to our desired output format.</p>
+
+<p>For example, the following output plugin will be used
+to proces requests ending in either ".html" or ".htm".</p>
+
+<p class="source"><![CDATA[
+	<bean id="html"
+		class="org.apache.forrest.core.plugin.XSLTOutputPlugin">
+		<property name="pattern" value=".*\.html|.*\.htm" />
+		<property name="xsltPath"
+			value="/xdocs/samples/xslt/internal-to-html.xsl" />
+	</bean>
+]]></p>
+
+</body>
+</html>
\ No newline at end of file

Propchange: forrest/trunk/whiteboard/forrest2/src/docs/howDoesItWork.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/docs/readme.html
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/docs/readme.html?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/docs/readme.html (added)
+++ forrest/trunk/whiteboard/forrest2/src/docs/readme.html Fri Nov 17 16:12:01 2006
@@ -0,0 +1,452 @@
+<!--
+  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.
+-->
+<html>
+<head>
+<title>Welcome to Forrest 2</title>
+</head>
+<body>
+<div class="note">
+<p>This document is written as though this is approved as a Forrest
+2 implementation, however, it is important to note that this is only an
+experiment at this time. The Apache Forrest project is using this
+implementation as a discussion tool. This code should therefore be
+considered as PRE-ALPHA and should not be used for anything other than
+experimentation.</p>
+</div>
+
+<h1>Forrest 2.0</h1>
+
+<p>Forrest2 is a complete rewrite of the XML publishing framework
+Apache Forrest.</p>
+
+<p>It draws on the lessons learned during development and use of
+earlier verions of Forrest, but it takes the opportunity to simplify the
+implementation and use wherever possible.</p>
+
+<p>Forrest2 is no longer built upon Apache Cocoon, it is a plain
+Java application.</p>
+
+<p>This may prompt you to ask "does this mean we lose the power of
+the Apache Cocoon framework?" The answer to that question is an emphatic
+no. You see, Apache Cocoon can still be used by Forrest, but you are no
+longer tied to it as was the case with earlier versions.</p>
+
+<p>Breaking away from Cocoon means that embedding Forrest2 in
+another application is much easier. In fact, since the new Forrest can
+be packaged as a Cocoon generator it is, ironically enough, easier to
+use in another Cocoon application than the original Forrest was. At the
+same time it is easier to embed Forrest in any other type of
+application.</p>
+
+<p>The core of Forrest2 is only a few megabytes in size (and can
+doubtless be trimmed even further). This compares very favourably with
+40Mb+ for Cocoon based versions of Forrest.</p>
+
+<p>Furthermore, the removal of Cocoon as the core framework means
+that extending Forrest no longer requires an understanding of Cocoon, in
+fact, Forrest2 can be extended very easily with just about any
+technology (including Cocoon). It is now possible to extend Forrest in
+any way you desire, all you need to do is expose your services via a
+REST style API.</p>
+
+<p>Of course, it's easier to use too...</p>
+
+<h1>Using Forrest 2.0</h1>
+
+<h2>Background Concepts</h2>
+
+<p>Forrest 2.0 builds on the concept of input and output plugins
+that were introduced in Forrest 0.7. An input plugin processes a source
+document and coverts it to an internal format for use within Forrest.
+This internal format is a subset of XHTML2. The internal document is
+further processed by zero or more output plugins which provide further
+processing to create the final output documents, in whatever format is
+required.</p>
+
+<p>Forrest 2.0 also utilises the Locationmap, utilised extensively
+in Forrest 0.8. This is a configuration file that maps request URL's to
+source documents. Thus allowing the client URL space to be completely
+decoupled from the surce URI space.</p>
+
+<h2>Hello World Example</h2>
+
+<div class="note"><p>Code for all examples in this document can be found in the src/examples
+directory of the core distribution.</p></div>
+
+<p>As is traditional we will work from the simplest possible use case and build up the
+complexity as we explore Forrest 2.0 in use. Of course, we will start with the most
+simplistic "Hello World" example we can.</p>
+
+<p>This simple case means we provide a "Hello World" document in a subset of XHTML2,
+i.e. it will already be in a format suitable for use within Forrest. We will
+require an output of this document in XHTML2.</p>
+
+<p>Hmmm... that sounds pretty pointless, what will Forrest actually do in this use 
+case?</p>
+
+<p>This use case will illustrate the decoupling of the client URL space from the
+source URI space. In so doing it will show how to configure a basic instance
+of Forrest 2.0.</p>
+
+<p>So, we want to alow the user to request the document "helloWorld.xhtml2" and recieve
+and XHTML2 document generated from a source document located at
+"src/xdocs/helloWorld.xhtml2".</p>
+
+<h3>Source Document</h3>
+
+<p>There is nothing magical about the source document. It's a simple XHMTL2 document:</p>
+
+<div class="code"><![CDATA[
+<?xml-stylesheet type="text/css" 
+                 href="http://www.w3.org/MarkUp/style/xhtml2.css"?>
+
+
+<html xmlns="http://www.w3.org/2002/06/xhtml2" xml:lang="en"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.w3.org/2002/06/xhtml2/ http://www.w3.org/MarkUp/SCHEMA/xhtml2.xsd">
+<head>
+<title>XHTML 2 Hello World</title>
+</head>
+<body>
+<h>
+Hello World
+</h>
+</body>
+</html>
+]]>
+</div>
+
+<p>This document is stored in "src/xdocs/helloWorld.xhtml2"</p>
+
+<h3>Locationmap</h3>
+
+<p>The locationmap, in its simplest form, is used to map the
+client URI to the actual location of the source document. In this case
+we need the following locationmap:</p>
+
+<div class="code"><[![CDATA
+<?xml version="1.0"?>
+<locationmap>
+<location pattern="helloWorld.xhtml2">
+<source href="classpath:/xdocs/helloWorld.xhtml2" />
+</location>
+</locationmap>
+]]></div>
+
+<p>Note the use of the "classpath:" protocol. This means that Forrest will
+search the classpath for the resource. Valid protocols in Forrest core
+are:</p>
+
+<ul>
+  <li>file:</li>
+  <li>http:</li>
+  <li>lasspath:</li>
+</ul>
+
+<p>These protocols can be extended by
+adding additional readers, we'll discuss this later.</p>
+
+<p>The locationmap
+document is stored in "src/locationmap.xml"</p>
+
+<h3>Running Forrest</h3>
+
+<p>There are a number of ways of running Forrest. Perhaps
+the most convenient is the Forrest webapp. This is not a part of core
+though, so we will focus on the command line version for now.</p>
+
+<p>The class
+org.apache.forrest.cli.CLI implements the command line. The simplest way
+of running the command line is with:</p>
+
+<div class="code">
+java -jar forrest.jar org.apache.forrest.cli.CLI [REQUEST_URI]
+</div>
+
+<p>So, in this instance we would
+run the following command from within the src/examples/helloWorld
+directory:</p>
+
+<div class="code">
+java -jar [FORREST_HOME]/forrest.jar org.apache.forrest.cli.CLI hellowWorld.xhtml2
+</div>
+
+<p>This command dumps
+the results document to System.out, so you will see the source document
+displayed on the screen.</p>
+
+<p>In this example forrest does not do any
+internal processing because we request an XHTML2 document. In the next
+example we'll look at how we can get Forrest to do some output
+processing for us.</p>
+
+<h2>HTML Hello World Example</h2>
+
+<p>In
+this example we will use the same XHTML2 input document, but we want to
+retrieve an HTML version of that document for display in a standard
+browser. To achieve this we will have Forrest process the document using
+an HTML output plugin. This output plugin will convert the XHTML2
+internal document into an HTML document.</p>
+
+<p>Forrest 2.0 core includes an
+output plugin that will convert from the internal XHTML2 format to HTML.
+This is the only output plugin bundled with Forrest2 core. We need to ensure 
+Forrest uses this plugin for this example. To do this
+all we need to do is add a new entry to our locationmap and request the file
+"helloWorld.html" (note the changed extension).</p>
+
+<h3>Locationmap</h3>
+
+<p>Recall that the locationmap maps request URLs to source files. In our
+first example we added a mapping from "helloWorld.xhtml2" to
+"classpath:/xdocs/helloWorld.xhtml2". In this example we will
+be requesting "helloWorld.html", so we need a new mapping. Add the following to
+your locationmap:</p>
+
+<div class="code"><![CDATA[
+<location pattern="helloWorld.html">
+<source href="classpath:/xdocs/helloWorld.xhtml2" />
+</location>
+]]></div>
+
+<p>This will work just fine, but we now have two mappings that use the 
+helloWorld.xhtml2 source file. Surely there is a way to express these two 
+matches in a more concise way.</p>
+
+<div class="todo">Explain that we could use pattern="helloWorld.*" for both cases
+since the source file is the same . The pattern is a regular expression.</div>
+
+<p>That's it, there is no need to tell Forrest that it must process a request for
+helloWorld.html with the HTML output plugin since, by default, the plugin will
+be activated for any request ending in ".html". Since it is a goal of Forrest 
+to remove the need to predefine
+the client URL space you will not be suprised to learn that it is not
+necessary to use an ".html" extension to trigger the html output plugin.
+It is possible to configure the trigger as any part of a request URL,
+for example, we may use something like "/html/helloWorld". Discussion of
+how to configure this is outside the scope of this example.</p>
+
+
+<h2>Embedding Forrest</h2>
+
+<p>The main driver
+behind writing Forrest 2.0 was to make it more embeddable. Earlier
+versions of Forrest were built on top of Cocoon and therefore it
+was difficult and/or computationally expensive to embed forrest in anything that
+was not based on Cocoon. Forrest 2.0 Core provides two main techniques for
+embedding. First, you can use the CLI to pipe results to other
+applications in your command shell. Secondly, Forrest 2.0 exposes a
+simple Java API that allows it to be controlled programatically.</p>
+
+<p>If
+neither of these solutions suits your use case, for example, you are not
+using Java and do not want to rely on shell scripts, then there is a
+separate web application that exposes Forrest via a REST style interface.</p>
+
+<p>Of course, it would be perfectly possible to create other extensions
+that enable Forrest to be embedded in other ways, such via a SOAP
+interface.</p>
+
+<h3>Embedding using the CLI</h3>
+
+<div class="todo">simple example of piping results to another
+shell command Java</div>
+
+<h3>Embedding using the Java API</h3>
+
+<p>All you need to do to embed Forrest using he Java API is
+instantiate an instance of the Forrest Controller class, then you 
+request the document required. For example:</p> 
+
+<div class="code"><pre>
+Controller controller = new Controller();
+AbstractOutputDocument doc = controller.getOutputDocument(requestURI);
+</pre></div>
+
+<p>That's it! At least it is for most use cases.</p>
+
+<p>As a more complete example lets look at the 
+core of a simple CLI class (with exception handling removed for
+clarity):</p>
+
+<div class="code">
+<pre>
+public static void main(String[] args) { 
+  try { 
+    URI requestURI = new URI(args[0]);
+    Controller controller = new Controller();
+    AbstractOutputDocument doc;
+    doc = controller.getOutputDocument(requestURI);
+    System.out.println(doc.getContentAsString());
+  } catch (...) { 
+    ... 
+  } }
+</pre></div>
+
+<p>As another example, here is the doGet method of a servlet that will route requests to
+Forrest and stream the results back to the requesting client.</p>
+
+<div class="todo"> show the webapp servlet class.</div>
+
+<h2>Running Forrest 2.0 as a Webapp</h2>
+
+<div class="todo">HTML Hello World example run in
+the webapp.</div> 
+
+<h2>Extending Forrest</h2>
+
+<p>There are three key ways to extend Forrest:</p>
+
+<ul>
+  <li>readers - read source documents</li>
+  <li>input plugins - convert source documents to internal documents</li>
+  <li>output plugins - convert internal documents to output documents</li>
+</ul>
+
+<p>To give you an idea of
+what you can do with each of these lets consider a few hypothetical
+examples of each type of extension.</p>
+
+<h3>Readers</h3>
+
+<p>Readers add
+protocols to the locationmap, thus allowing different methods of reading
+source documents. For example, we may build a relational database reader.</p>
+
+<p>This reader reads a document from a
+relational database and provide it in an XML format. It adds a
+locationmap protocol of "db:" and is configured from within the URL, e.g.
+"db:user@dbserver.domain.co.uk/catalogue:product.id=AL292"</p>
+
+<p>The above URL will return an XML representation of the product with ID
+"AL292" from the database "catalogue" on the server at "dbserver.domain.co.uk".
+The database is accessed using the username "user".</p>
+
+<h3>Input Plugins</h3>
+
+<p>Input plugins take some kind of input document and convert
+them to an XHTML2 internal document for further processing. For example 
+we could have an input plugin that converts OpenOffice.org documents
+to Forrest documents.</p>
+
+
+<h3>Output Plugins</h3>
+
+<p>Output Plugins convert an internal document into
+the final output format that is required. For example a PDF Output Plugin
+converts an internal document into a PDF document.</p>
+
+<h2>Configuring Forrest</h2>
+
+<p>Forrest uses the Spring
+framework to manage its configuration. If you need to add one or more
+readers or plugins to Forrest core you need to create a Spring context
+file in your project. This will be stored at 
+"PROJECT_HOME/src/forrestContext.xml".</p>
+
+<h1>Extended Examples</h1>
+
+<p>This set of examples extend the
+reading, input and output capabilites of Forrest to perform more complex
+tasks than are capable with Forrest Core. They therefore demonstrate the use
+of additional readers and plugins.</p>
+
+<h2>HTML From Plain Text Hello World</h2>
+
+<p>This example illustrates the use
+of an input plugin.</p>
+
+<div class="todo">an example showing the creation of an HTML
+document from a plain text source document.</div>
+
+<h2>PDF From Plain Text Hello World</h2>
+
+<p>This example illustrates the use
+of an output plugin in conjunction with the input plugin from the previous
+example.</p>
+
+<p>an example showing the creation of an PDF
+document from a plain text source document.</p>
+
+<h3>Hello Username</h3>
+
+<p>This example illustates the use of a reader to extract
+information about the execution environment.</p>
+
+<h3>Affiliates Product Catalogue</h3>
+
+<p>In <a href="example/affiliateProductDatabase.html">this example</a>
+we create an input plugin to use
+product feeds from affiliate programs (in this case
+TradeDoubler). This is then coupled with an output plugin
+that presents this data as an HTML page for inclusion in
+a web site or as a PDF document for printing.</p>
+
+<h3>Extended Product Catalogue</h3>
+
+<p class="todo">In this example, we extend the affiliate
+product catalogue example by adding business logic to the
+reader. In the previous version all products in the feed
+appeared in the catalogue. In this new version we are able
+to provide keywords that must be present in the product
+title or description for it to appear in the catalogue.</p>
+
+<p>This example illustrates how an Input plugin can extend
+the functioanlity of an existing plugin.</p>
+
+<h3>ECommerce Application</h3>
+
+<p class="todo">This example illustrates how
+Apache Forrest can be embedded in a Wicket web application (Wicket is 
+a Java web application framework. The Wicket
+application handles all dynamic funtions, such as the management of a
+shopping cart and "clever" Ajax search functionality, whilst Forrest
+handles the generation of semi-static content, such as product
+description pages. It builds on the previous example in which
+Forrest generated content from an Product Catalogue.</p>
+
+<p>Here we are using Wicket to generate many parts of an
+HTML page, such as the navigation. This is because we happen to like
+Wickets approach to the building of web pages from components. However,
+with a little imagination we are sure you can see how to use your
+favourite templating technology to do this. Some suggested alternatives to wicket
+rendering would be:</p>
+
+<ul>
+  <li>jxTemplate</li>
+  <li>Tiles</li>
+  <li>Cocoon</li>
+  <li>Dispatcher</li>
+</ul>
+
+<p>The use of Forrest to generate content
+allows us to leverage the mulitple output plugins provided by Forrest to
+present content in many different formats, such as web page, PDF, voice
+etc.</p>
+
+<h3>Extended Product Catalogue</h3>
+
+<p class="todo">We will now extend the product catalgoue to enable the embedding of
+third party product feeds as well as products from our own database. To
+do this we will retrieve a feed from TradeDoubler.co.uk and embed the
+results in our product catalogue. This example will illustrate the
+aggregation of content from multiple sources, in different source
+formats into a single output document available in multiple formats.</p>
+
+</body>
+</html>

Propchange: forrest/trunk/whiteboard/forrest2/src/docs/readme.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/docs/urlExtensions.html
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/docs/urlExtensions.html?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/docs/urlExtensions.html (added)
+++ forrest/trunk/whiteboard/forrest2/src/docs/urlExtensions.html Fri Nov 17 16:12:01 2006
@@ -0,0 +1,52 @@
+<!--
+  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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>URL Extensions</title>
+</head>
+<body>
+<p>It is common to use extensions in URLs to indicate the
+type of document requried. For example, URLs ending with
+"*.html" or "*.htm" usually return an HTML document. With
+Forrest the use of extensions is not necessary, we can
+use any pattern matching technique, for example, "html/foo"
+or "web/foo" could be used to return HTML pages.</p>
+
+<p>Nevertheless, Forrest does use a few special URL
+extensions to indicate special types of requuest. These are
+used to retrieve documents from various stages of the processig
+pipeline and to retrieve debug information about the
+pipeline. These extensions are:</p>
+
+<ul>
+  <li class="todo">*.forrestSource - will return the document directly from
+  the reader, that is with no processing at all</li>
+  <li class="todo">*.forrestInternal - will return the document after
+  it has been processed by the input plugins</li>
+</ul>
+
+<p class="todo">We need to make these extensions configurable. 
+Perhaps from the forrestContext.xml file. This would mean the 
+controller will need to be loaded via spring and Forrest core
+will require a bootstrap class to initialise everything. This
+would probably be a good idea as it will allow different 
+controllers to be created should the need arise.</p>
+
+</body>
+</html>
\ No newline at end of file

Propchange: forrest/trunk/whiteboard/forrest2/src/docs/urlExtensions.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/forrestContext.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/forrestContext.xml?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/forrestContext.xml (added)
+++ forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/forrestContext.xml Fri Nov 17 16:12:01 2006
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+
+	<!-- ============================================= -->
+	<!--                 Readers					   -->
+	<!-- ============================================= -->
+
+	<bean id="tradeDoubler"
+		class="org.apache.forrest.examples.affiliateProductCatalogue.reader.TradeDoublerReader" />
+	
+	<!-- ============================================= -->
+	<!--               Input Plugins                   -->
+	<!-- ============================================= -->
+
+	<bean id="org.apache.forrest.example.affiliateProductCatalogue.TradeDoublerProductFeed"
+		class="org.apache.forrest.core.plugin.XSLTInputPlugin">
+		<property name="xsltURL"
+			value="/src/xslt/tradeDoublerFeed-to-internal.xsl" />
+	</bean>
+
+	<!-- ============================================= -->
+	<!--               Output Plugins                  -->
+	<!-- ============================================= -->
+
+	<bean id="htmlOutputPlugin"
+		class="org.apache.forrest.core.plugin.XSLTOutputPlugin">
+		<property name="pattern" value=".*(html|htm)" />
+		<property name="xsltPath"
+			value="/xdocs/samples/xslt/internal-to-html.xsl" />
+	</bean>
+
+	<!-- ============================================= -->
+	<!--                  Readers                      -->
+	<!-- ============================================= -->
+
+	<bean id="http" class="org.apache.forrest.reader.HTTPReader"></bean>
+	<bean id="file" class="org.apache.forrest.reader.FileReader"></bean>
+
+</beans>

Propchange: forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/forrestContext.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/locationmap.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/locationmap.xml?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/locationmap.xml (added)
+++ forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/locationmap.xml Fri Nov 17 16:12:01 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<locationmap>
+  <location pattern="tradeDoubler.*">
+    <source href="tradeDoubler:classpath:/xdocs/exampleFeed.xml"/>
+  </location>
+</locationmap>
\ No newline at end of file

Propchange: forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/locationmap.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/reader/TradeDoublerReader.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/reader/TradeDoublerReader.java?view=auto&rev=476384
==============================================================================
--- forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/reader/TradeDoublerReader.java (added)
+++ forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/reader/TradeDoublerReader.java Fri Nov 17 16:12:01 2006
@@ -0,0 +1,47 @@
+/*
+ * 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.examples.affiliateProductCatalogue.reader;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.forrest.core.document.AbstractSourceDocument;
+import org.apache.forrest.core.document.DefaultSourceDocument;
+import org.apache.forrest.core.locationMap.Location;
+import org.apache.forrest.reader.FileReader;
+
+public class TradeDoublerReader extends FileReader {
+
+	@Override
+	public AbstractSourceDocument read(final Location location) {
+		DefaultSourceDocument doc = null;
+		final URI psudeoURI = location.getSourceURI();
+		final String ssp = psudeoURI.getSchemeSpecificPart();
+		URI uri;
+		try {
+			uri = new URI(ssp);
+			location.setSourceURI(uri);
+			doc = (DefaultSourceDocument) super.read(location);
+			doc
+					.setType("org.apache.forrest.example.affiliateProductCatalogue.TradeDoublerProductFeed");
+		} catch (final URISyntaxException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return doc;
+	}
+}

Propchange: forrest/trunk/whiteboard/forrest2/src/examples/affiliateProductCatalogue/src/org/apache/forrest/examples/affiliateProductCatalogue/reader/TradeDoublerReader.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message