Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added new producer for processing document sent as request

payload. Also allowed Cocoon to be called as an external module
even if this is clearly a dirty hack.


git-svn-id: https://svn.apache.org/repos/asf/cocoon/branches/cocoon-1@1045450 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 87c374778fe5baa3c7f0fd312195b9fa2be83a3d 1 parent 3635537
Stefano Mazzocchi stefanom authored
6 trunk/CVSROOT/changes.xml
View
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.2 1999-11-30 16:29:50 stefano Exp $
+ $Id: changes.xml,v 1.3 1999-12-01 11:27:47 stefano Exp $
-->
<changes title="Cocoon History of Changes">
@@ -16,6 +16,10 @@
</devs>
<release version="1.6-dev" date="">
+ <action dev="SM" type="add" due-to="Gerrit Hiddink" due-to-email="grit@wwcn.org">
+ Add new producer for POST document processing, also useful for use of
+ Cocoon as a module (see EngineWrapper).
+ </action>
<action dev="SM" type="fix" due-to="Ambarish Chaudhari" due-to-email="ambarish.chaudhari@ecapsol.com">
Fixed null problem in MemoryStore for command line operation.
</action>
55 trunk/CVSROOT/src/org/apache/cocoon/EngineWrapper.java
View
@@ -1,4 +1,4 @@
-/*-- $Id: EngineWrapper.java,v 1.3 1999-11-09 02:29:14 dirkx Exp $ --
+/*-- $Id: EngineWrapper.java,v 1.4 1999-12-01 11:27:48 stefano Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -61,20 +61,32 @@ developed by the Apache Software Foundation (http://www.apache.org/)."
* This class implements wrapping methods that allow the engine to be
* called even from other APIs or standalone applications.
*
+ * NOTE: this is a dirty hack and I know it. The problem is that Cocoon is
+ * a servlet and the servlet API are not that easy to deal with when you
+ * enter other modes of operation (like command line or RMI).
+ *
+ * We will need to clean this up and remove the need of direct
+ * HttpServletRequest/Response emulation when we integrate with Stylebook.
+ * But I have more important stuff to do right now.
+ *
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version $Revision: 1.3 $ $Date: 1999-11-09 02:29:14 $
+ * @version $Revision: 1.4 $ $Date: 1999-12-01 11:27:48 $
*/
public class EngineWrapper extends Engine {
-
+
public EngineWrapper(Configurations confs) throws Exception {
super(confs);
}
- public void handle(PrintWriter out, String document) throws Exception {
- this.handle(new HttpServletRequestImpl(document), new HttpServletResponseImpl(out));
+ public void handle(PrintWriter out, File pathToDocument) throws Exception {
+ this.handle(new HttpServletRequestImpl(pathToDocument), new HttpServletResponseImpl(out));
+ }
+
+ public void handle(PrintWriter out, File documentPath, String document) throws Exception {
+ this.handle(new HttpServletRequestImpl(documentPath, document), new HttpServletResponseImpl(out));
}
-
+
/**
* Dummy implementation of the HttpServletRequest class to create a
* fake but funtional request for the main engine.
@@ -82,10 +94,21 @@ public void handle(PrintWriter out, String document) throws Exception {
*/
public class HttpServletRequestImpl implements HttpServletRequest {
- private String pathTranslated;
+ private String pathTranslated = "/";
+ private String document = null;
- public HttpServletRequestImpl(String pathTranslated) {
- this.pathTranslated = pathTranslated;
+ public HttpServletRequestImpl(File path) {
+ this(path, null);
+ }
+
+ public HttpServletRequestImpl(File pathTranslated, String document) {
+ if (path != null) {
+ this.pathTranslated = pathTranslated.toString();
+ }
+
+ if (document != null) {
+ this.document = document;
+ }
}
public String getPathTranslated() {
@@ -96,7 +119,18 @@ public String getPathTranslated() {
// with FileProducer. Check this when Servlet 2.2 are in place.
public String getPathInfo() { return ""; }
- public String getParameter(String name) { return null; }
+ public String getParameter(String name) {
+ if ((data != null) && (name.equalsIgnoreCase("producer"))) {
+ return "org.apache.cocoon.producer.ProducerFromRequest";
+ } else {
+ return null;
+ }
+ }
+
+ public BufferedReader getReader () throws IOException {
+ return (document == null) ? null : new BufferedReader(new StringReader(document));
+ }
+
public Enumeration getParameterNames() { return null; }
public String[] getParameterValues(String name) { return null; }
public int getContentLength() { return -1; }
@@ -109,7 +143,6 @@ public String getPathTranslated() {
public String getRemoteHost() { return null; }
public ServletInputStream getInputStream() throws IOException { return null; }
public Object getAttribute(String name) { return null; }
- public BufferedReader getReader () throws IOException { return null; }
public String getCharacterEncoding () { return null; }
public Cookie[] getCookies() { return null; }
public String getMethod() { return null; }
4 trunk/CVSROOT/src/org/apache/cocoon/cocoon.properties
View
@@ -40,7 +40,9 @@ producer.parameter = producer
# The syntax for this is
# producer.type.xxx = full.class.name
# where "xxx" is the producer indentier used in the request
-producer.type.file = org.apache.cocoon.producer.FileProducer
+producer.type.file = org.apache.cocoon.producer.ProducerFromFile
+producer.type.request = org.apache.cocoon.producer.ProducerFromRequest
+
producer.type.dummy = org.apache.cocoon.example.DummyProducer
# When producer indication is present in the request
Please sign in to comment.
Something went wrong with that request. Please try again.