You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gi...@locus.apache.org on 2000/08/16 07:08:21 UTC
cvs commit: xml-cocoon/src/org/apache/cocoon/sitemap ErrorGenerator.java ResourcePipeline.java SitemapOutputComponent.java
giacomo 00/08/15 22:08:21
Modified: conf Tag: xml-cocoon2 sitemap.xmap
samples/documents Tag: xml-cocoon2 welcome.xml
src/org/apache/cocoon/components/language/markup/sitemap/java
Tag: xml-cocoon2 sitemap.xsl
src/org/apache/cocoon/reading Tag: xml-cocoon2
AbstractReader.java ResourceReader.java
src/org/apache/cocoon/serialization Tag: xml-cocoon2
AbstractSerializer.java FO2PDFSerializer.java
ImageSerializer.java SVGSerializer.java
src/org/apache/cocoon/sitemap Tag: xml-cocoon2
ErrorGenerator.java ResourcePipeline.java
SitemapOutputComponent.java
Added: samples/documents Tag: xml-cocoon2 error-giving-page.xml
samples/resources/images Tag: xml-cocoon2
cocoonBackTrasp.gif
samples/stylesheets Tag: xml-cocoon2 cool-error2html.xsl
cool-status.xsl
Log:
Improved ErrorGenerator by Nicola Ken Barozzi.
New samples in welcome page (Error page and Status).
Added getMimeType method to SitemapOutputComponent (and to all the Components that depend on the SitemapOutputComponent Interface)
Revision Changes Path
No revision
No revision
1.1.2.6 +8 -2 xml-cocoon/conf/Attic/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon/conf/Attic/sitemap.xmap,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- sitemap.xmap 2000/08/02 22:48:25 1.1.2.5
+++ sitemap.xmap 2000/08/16 05:08:06 1.1.2.6
@@ -111,7 +111,7 @@
<map:match pattern="^status$">
<map:generate type="status" src="status"/>
- <map:transform src="stylesheets/simple-status.xsl"/>
+ <map:transform src="stylesheets/cool-status.xsl"/>
<map:serialize>
<parameter name="contentType" value="text/html"/>
</map:serialize>
@@ -125,8 +125,14 @@
</map:serialize>
</map:match>
+ <map:match pattern="^generror$">
+ <map:generate src="documents/error-giving-page.xml"/>
+ <map:transform src="stylesheets/simple-welcome2html.xsl"/>
+ <map:serialize/>
+ </map:match>
+
<map:handle-errors>
- <map:transform src="stylesheets/simple-error2html.xsl"/>
+ <map:transform src="stylesheets/cool-error2html.xsl"/>
<map:serialize/>
</map:handle-errors>
No revision
No revision
1.1.2.2 +8 -0 xml-cocoon/samples/documents/Attic/welcome.xml
Index: welcome.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/samples/documents/Attic/welcome.xml,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- welcome.xml 2000/06/06 23:20:00 1.1.2.1
+++ welcome.xml 2000/08/16 05:08:09 1.1.2.2
@@ -23,8 +23,16 @@
</sample>
</group>
<group name="Dynamic Content Examples">
+ <sample name="Status Page" url="status">
+ Simple status page example.
+ </sample>
<sample name="Simple XSP" url="simple_dynamic_page">
Simple XSP example.
+ </sample>
+ </group>
+ <group name="Error Page Example">
+ <sample name="Error Page" url="generror">
+ Simple error page example.
</sample>
</group>
</samples>
No revision
No revision
1.1.2.1 +15 -0 xml-cocoon/samples/documents/Attic/error-giving-page.xml
No revision
No revision
1.1.2.1 +15 -0 xml-cocoon/samples/resources/images/Attic/cocoonBackTrasp.gif
<<Binary file>>
No revision
No revision
1.1.2.1 +110 -0 xml-cocoon/samples/stylesheets/Attic/cool-error2html.xsl
1.1.2.1 +71 -0 xml-cocoon/samples/stylesheets/Attic/cool-status.xsl
No revision
No revision
1.1.2.20 +70 -11 xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
Index: sitemap.xsl
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -u -r1.1.2.19 -r1.1.2.20
--- sitemap.xsl 2000/08/04 21:11:14 1.1.2.19
+++ sitemap.xsl 2000/08/16 05:08:14 1.1.2.20
@@ -2,7 +2,7 @@
<!-- Sitemap Core logicsheet for the Java language -->
<!--
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.19 $ $Date: 2000/08/04 21:11:14 $
+ * @version CVS $Revision: 1.1.2.20 $ $Date: 2000/08/16 05:08:14 $
-->
<xsl:stylesheet
@@ -61,9 +61,9 @@
}
private Parameters emptyParam = new Parameters();
+ private Generator generator_error_handler = null;
+ private Configuration generator_config_error_handler = null;
- private Generator generator_error_handler = new ErrorGenerator();
-
<!-- generate variables for all components -->
/** The generators */
<xsl:for-each select="/map:sitemap/map:components/map:generators/map:generator">
@@ -157,6 +157,14 @@
this.sitemapManager.setConfiguration(conf);
try {
<!-- configure all components -->
+ /* Configure special ErrorGenerator */
+ confBuilder.startDocument ();
+ confBuilder.endDocument ();
+ Configuration cconf2 = confBuilder.getConfiguration();
+ generator_config_error_handler = cconf2;
+ generator_error_handler =
+ (Generator) load_component ("org.apache.cocoon.sitemap.ErrorGenerator", cconf2);
+
/* Configure generators */
<xsl:call-template name="config-components">
<xsl:with-param name="name">generator</xsl:with-param>
@@ -229,6 +237,7 @@
List listOfLists = (List)(new ArrayList());
List list = null;
Parameters param = null;
+ Dictionary objectModel = environment.getObjectModel();
<xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
<xsl:variable name="pipeline-position" select="position()"/>
try {
@@ -237,7 +246,7 @@
<xsl:choose>
<xsl:when test="(./map:handle-errors)">
try {
- return error_process_<xsl:value-of select="$pipeline-position"/> (environment, e);
+ return error_process_<xsl:value-of select="$pipeline-position"/> (environment, objectModel, e);
} catch (Exception ex) {
System.out.println (ex.toString());
ex.printStackTrace(System.out);
@@ -256,7 +265,7 @@
<xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
<xsl:variable name="pipeline-position" select="position()"/>
<xsl:if test="(./map:handle-errors)">
- private boolean error_process_<xsl:value-of select="$pipeline-position"/> (Environment environment, Exception e)
+ private boolean error_process_<xsl:value-of select="$pipeline-position"/> (Environment environment, Dictionary objectModel, Exception e)
throws Exception {
ResourcePipeline pipeline = new ResourcePipeline ();
pipeline.setComponentManager (this.manager);
@@ -310,7 +319,7 @@
</xsl:choose>
</xsl:for-each>
</xsl:variable>
- if ((list = <xsl:value-of select="$matcher-name"/> ("<xsl:value-of select="$pattern-value"/>", environment.getObjectModel())) != null) {
+ if ((list = <xsl:value-of select="$matcher-name"/> ("<xsl:value-of select="$pattern-value"/>", objectModel)) != null) {
listOfLists.add (list);
<xsl:apply-templates/>
}
@@ -352,7 +361,7 @@
</xsl:choose>
</xsl:for-each>
</xsl:variable>
- if (<xsl:value-of select="$selector-name"/> ("<xsl:value-of select="$test-value"/>", environment.getObjectModel())) {
+ if (<xsl:value-of select="$selector-name"/> ("<xsl:value-of select="$test-value"/>", objectModel)) {
<xsl:apply-templates/>
}
</xsl:for-each>
@@ -378,24 +387,74 @@
<xsl:with-param name="method">addTransformer</xsl:with-param>
<xsl:with-param name="prefix">transformer</xsl:with-param>
</xsl:call-template>
- </xsl:template> <!-- match="map:transormer" -->
+ </xsl:template> <!-- match="map:transformer" -->
<xsl:template match="map:serialize">
+ <xsl:variable name="default-serializer-type">
+ <xsl:value-of select="/map:sitemap/map:components/map:serializers/@default"/>
+ </xsl:variable>
+ <xsl:variable name="this-type">
+ <xsl:choose>
+ <xsl:when test="@type">
+ <xsl:value-of select="@type"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$default-serializer-type"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="default-mime-type">
+ <xsl:value-of select="/map:sitemap/map:components/map:serializers/map:serializer[@name=$this-type]/@mime-type"/>
+ </xsl:variable>
<xsl:call-template name="setup-component">
- <xsl:with-param name="default-component" select="/map:sitemap/map:components/map:serializers/@default"/>
+ <xsl:with-param name="default-component" select="$default-serializer-type"/>
<xsl:with-param name="method">setSerializer</xsl:with-param>
<xsl:with-param name="prefix">serializer</xsl:with-param>
- <xsl:with-param name="mime-type" select="@mime-type"/>
+ <xsl:with-param name="mime-type">
+ <xsl:choose>
+ <xsl:when test="@mime-type">
+ <xsl:value-of select="@mime-type"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$default-mime-type"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
</xsl:call-template>
return pipeline.process (environment);
</xsl:template> <!-- match="map:serialize" -->
<xsl:template match="map:read">
+ <xsl:variable name="default-reader-type">
+ <xsl:value-of select="/map:sitemap/map:components/map:readers/@default"/>
+ </xsl:variable>
+ <xsl:variable name="this-type">
+ <xsl:choose>
+ <xsl:when test="@type">
+ <xsl:value-of select="@type"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$default-reader-type"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="default-mime-type">
+ <xsl:value-of select="/map:sitemap/map:components/map:readers/map:reader[@name=$this-type]/@mime-type"/>
+ </xsl:variable>
<xsl:call-template name="setup-component">
<xsl:with-param name="default-component" select="/map:sitemap/map:components/map:readers/@default"/>
<xsl:with-param name="method">setReader</xsl:with-param>
<xsl:with-param name="prefix">reader</xsl:with-param>
- <xsl:with-param name="mime-type" select="@mime-type"/>
+ <xsl:with-param name="mime-type">
+ <xsl:choose>
+ <xsl:when test="@mime-type">
+ <xsl:value-of select="@mime-type"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$default-mime-type"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
</xsl:call-template>
return pipeline.process (environment);
</xsl:template> <!-- match="map:read" -->
No revision
No revision
1.1.2.3 +10 -1 xml-cocoon/src/org/apache/cocoon/reading/Attic/AbstractReader.java
Index: AbstractReader.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/reading/Attic/AbstractReader.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- AbstractReader.java 2000/08/04 21:11:55 1.1.2.2
+++ AbstractReader.java 2000/08/16 05:08:15 1.1.2.3
@@ -17,7 +17,7 @@
/**
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/08/04 21:11:55 $
+ * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/08/16 05:08:15 $
*/
public abstract class AbstractReader implements Reader {
/** The current <code>EntityResolver</code>. */
@@ -47,5 +47,14 @@
*/
public void setOutputStream(OutputStream out) {
this.out=out;
+ }
+
+ /**
+ * Get the mime-type of the output of this <code>Serializer</code>
+ * This default implementation returns null to indicate that the
+ * mime-type specified in the sitemap is to be used
+ */
+ public String getMimeType() {
+ return null;
}
}
1.1.2.3 +13 -1 xml-cocoon/src/org/apache/cocoon/reading/Attic/ResourceReader.java
Index: ResourceReader.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/reading/Attic/ResourceReader.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- ResourceReader.java 2000/08/04 21:11:56 1.1.2.2
+++ ResourceReader.java 2000/08/16 05:08:16 1.1.2.3
@@ -17,6 +17,7 @@
import java.util.Dictionary;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
import org.apache.cocoon.ProcessingException;
@@ -25,7 +26,7 @@
/**
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/08/04 21:11:56 $
+ * @version CVS $Revision: 1.1.2.3 $ $Date: 2000/08/16 05:08:16 $
*/
public class ResourceReader extends AbstractReader {
@@ -59,5 +60,16 @@
res.setDateHeader("Last-Modified", file.lastModified());
res.setHeader("Accept-Ranges","bytes");
out.write ( buffer );
+ }
+ /**
+ * Returns the mime-type of the resource in process.
+ */
+ public String getMimeType () {
+ ServletContext ctx = (ServletContext) objectModel.get("context");
+ if (ctx != null) {
+ return ctx.getMimeType(this.source);
+ } else {
+ return null;
+ }
}
}
No revision
No revision
1.1.2.5 +10 -1 xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractSerializer.java
Index: AbstractSerializer.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/AbstractSerializer.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- AbstractSerializer.java 2000/08/04 21:12:01 1.1.2.4
+++ AbstractSerializer.java 2000/08/16 05:08:17 1.1.2.5
@@ -18,7 +18,7 @@
*
* @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
* (Apache Software Foundation, Exoffice Technologies)
- * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/08/04 21:12:01 $
+ * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/08/16 05:08:17 $
*/
public abstract class AbstractSerializer extends AbstractXMLConsumer
implements Serializer {
@@ -30,5 +30,14 @@
*/
public void setOutputStream(OutputStream out) {
this.output=new BufferedOutputStream(out);
+ }
+
+ /**
+ * Get the mime-type of the output of this <code>Serializer</code>
+ * This default implementation returns null to indicate that the
+ * mime-type specified in the sitemap is to be used
+ */
+ public String getMimeType() {
+ return null;
}
}
1.1.2.6 +10 -1 xml-cocoon/src/org/apache/cocoon/serialization/Attic/FO2PDFSerializer.java
Index: FO2PDFSerializer.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/FO2PDFSerializer.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- FO2PDFSerializer.java 2000/08/04 21:12:01 1.1.2.5
+++ FO2PDFSerializer.java 2000/08/16 05:08:17 1.1.2.6
@@ -27,7 +27,7 @@
*
* @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
* (PWR Organisation & Entwicklung)
- * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/08/04 21:12:01 $
+ * @version CVS $Revision: 1.1.2.6 $ $Date: 2000/08/16 05:08:17 $
*
*/
public class FO2PDFSerializer extends DocumentHandlerWrapper
@@ -65,4 +65,13 @@
throw new SAXException (e);
}
}
+
+ /**
+ * Get the mime-type of the output of this <code>Serializer</code>
+ * This default implementation returns null to indicate that the
+ * mime-type specified in the sitemap is to be used
+ */
+ public String getMimeType() {
+ return null;
+ }
}
1.1.2.5 +10 -1 xml-cocoon/src/org/apache/cocoon/serialization/Attic/ImageSerializer.java
Index: ImageSerializer.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/ImageSerializer.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- ImageSerializer.java 2000/08/04 21:12:02 1.1.2.4
+++ ImageSerializer.java 2000/08/16 05:08:17 1.1.2.5
@@ -50,7 +50,7 @@
* @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
* @author Copyright 1999 © <a href="http://www.apache.org">The Apache
* Software Foundation</a>. All rights reserved.
- * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/08/04 21:12:02 $
+ * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/08/16 05:08:17 $
*/
public class ImageSerializer extends DOMBuilder implements Serializer, Composer {
@@ -342,5 +342,14 @@
if(newy>=i.getHeight()) break;
}
return(true);
+ }
+
+ /**
+ * Get the mime-type of the output of this <code>Serializer</code>
+ * This default implementation returns null to indicate that the
+ * mime-type specified in the sitemap is to be used
+ */
+ public String getMimeType() {
+ return null;
}
}
1.1.2.5 +10 -1 xml-cocoon/src/org/apache/cocoon/serialization/Attic/SVGSerializer.java
Index: SVGSerializer.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/serialization/Attic/SVGSerializer.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- SVGSerializer.java 2000/08/04 21:12:02 1.1.2.4
+++ SVGSerializer.java 2000/08/16 05:08:17 1.1.2.5
@@ -51,7 +51,7 @@
* @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
* @author Copyright 1999 © <a href="http://www.apache.org">The Apache
* Software Foundation</a>. All rights reserved.
- * @version CVS $Revision: 1.1.2.4 $ $Date: 2000/08/04 21:12:02 $
+ * @version CVS $Revision: 1.1.2.5 $ $Date: 2000/08/16 05:08:17 $
*/
public class SVGSerializer extends DOMBuilder implements Serializer, Composer {
@@ -139,5 +139,14 @@
} catch(IOException e) {
throw new SAXException("IOException writing image ",e);
}
+ }
+
+ /**
+ * Get the mime-type of the output of this <code>Serializer</code>
+ * This default implementation returns null to indicate that the
+ * mime-type specified in the sitemap is to be used
+ */
+ public String getMimeType() {
+ return null;
}
}
No revision
No revision
1.1.2.2 +34 -35 xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ErrorGenerator.java
Index: ErrorGenerator.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ErrorGenerator.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ErrorGenerator.java 2000/08/02 22:48:29 1.1.2.1
+++ ErrorGenerator.java 2000/08/16 05:08:19 1.1.2.2
@@ -19,7 +19,6 @@
import java.io.PipedReader;
import java.io.PipedWriter;
import java.io.PrintWriter;
-//import java.io.*;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -32,8 +31,8 @@
* Generates an XML representation of the current notification.
*
* @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
- * @created 31 luglio 2000
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/08/02 22:48:29 $
+ * @created 31 July 2000
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/08/16 05:08:19 $
*/
public class ErrorGenerator extends ComposerGenerator {
@@ -57,10 +56,10 @@
}
/**
- * Generate the status information in XML format.
+ * Generate the notification information in XML format.
*
- *@exception SAXException Description of Exception
- *@throws SAXException when there is a problem creating the
+ *@exception SAXException Description of problem there is creating the output SAX events.
+ *@throws SAXException when there is a problem creating the
* output SAX events.
*/
public void generate() throws SAXException {
@@ -69,10 +68,10 @@
/**
- * Generate the status information in XML format.
+ * Start generation of the notification information of a <code>Throwable</code> in XML format.
*
- *@param t Description of Parameter
- *@exception SAXException Description of Exception
+ *@param t The Exception to report
+ *@exception SAXException Description of problem there is creating the output SAX events.
*@throws SAXException when there is a problem creating the
* output SAX events.
*/
@@ -93,11 +92,11 @@
/**
- * Generate the main status document.
+ * Generate the notification information of a <code>Throwable</code> in XML format.
*
- *@param ch Description of Parameter
- *@param t Description of Parameter
- *@exception SAXException Description of Exception
+ *@param ch The ContentHandler to use.
+ *@param t The Exception to report
+ *@exception SAXException Description of problem there is creating the output SAX events.
*/
private void genError(ContentHandler ch,
Throwable t) throws SAXException {
@@ -141,16 +140,17 @@
/**
- * Description of the Method
+ * Generate notification information in XML format.
*
- *@param ch Description of Parameter
- *@param type Description of Parameter
- *@param title Description of Parameter
- *@param source Description of Parameter
- *@param message Description of Parameter
- *@param description Description of Parameter
- *@param extraDescriptions Description of Parameter
- *@exception SAXException Description of Exception
+ *@param ch The ContentHandler to use.
+ *@param type The type of notification.
+ *@param title The title of the notification.
+ *@param source The source where the notification comes from.
+ *@param message The notification.
+ *@param description A more detailed description of the notification.
+ *@param extraDescriptions A Hashtable containing extra notifications that do not fit
+ * in other parameters. The keys are the parameter names, the values are the notifications.
+ *@exception SAXException Description of problem there is creating the output SAX events.
*/
private void genNotify(ContentHandler ch, String type,
String title, String source, String message, String description,
@@ -173,11 +173,12 @@
ch.endElement(URI, "source", "source");
ch.startElement(URI, "message", "message", new AttributesImpl());
- ch.characters(message.toCharArray(), 0, message.length());
+ if (message != null)
+ ch.characters(message.toCharArray(), 0, message.length());
ch.endElement(URI, "message", "message");
ch.startElement(URI, "description", "description",
- new AttributesImpl());
+ new AttributesImpl());
ch.characters(description.toCharArray(), 0, description.length());
ch.endElement(URI, "description", "description");
@@ -194,11 +195,8 @@
ch.startElement(URI, "extra", "extra", atts);
ch.characters(extra.toCharArray(), 0, extra.length());
ch.endElement(URI, "extra", "extra");
-
}
-
-
// End root element.
ch.endElement(URI, "notify", "notify");
}
@@ -206,21 +204,21 @@
/**
- * Description of the Class
+ * A thread that prints the stackTrace of a <code>Throwable</code> object
+ * to a PrintWriter.
*
- *@author nicola_ken
- *@created 31 luglio 2000
+ * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
+ * @created 31 July 2000
*/
class ReadThread extends Thread {
PrintWriter CurrentWriter;
Throwable t;
-
/**
* Constructor for the ReadThread object
*
- *@param CurrentWriter Description of Parameter
- *@param t Description of Parameter
+ *@param CurrentWriter The <code>PrintWriter</code> to print the stacktrace to.
+ *@param t The <code>Throwable</code> object containing the stackTrace.
*/
ReadThread(PrintWriter CurrentWriter, Throwable t) {
this.CurrentWriter = CurrentWriter;
@@ -229,7 +227,9 @@
/**
- * Main processing method for the ReadThread object
+ * Main processing method for the ReadThread object.
+ * A thread that prints the stackTrace of a <code>t</code>
+ * to <code>CurrentWriter</code>.
*/
public void run() {
t.printStackTrace(CurrentWriter);
@@ -238,4 +238,3 @@
}
}
-
1.1.2.13 +31 -20 xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ResourcePipeline.java
Index: ResourcePipeline.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ResourcePipeline.java,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -u -r1.1.2.12 -r1.1.2.13
--- ResourcePipeline.java 2000/08/04 21:12:11 1.1.2.12
+++ ResourcePipeline.java 2000/08/16 05:08:19 1.1.2.13
@@ -14,6 +14,7 @@
import org.apache.avalon.Configuration;
import org.apache.avalon.Configurable;
import org.apache.avalon.ComponentManager;
+import org.apache.avalon.Component;
import org.apache.avalon.Composer;
import org.apache.avalon.utils.Parameters;
@@ -30,7 +31,7 @@
/**
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.12 $ $Date: 2000/08/04 21:12:11 $
+ * @version CVS $Revision: 1.1.2.13 $ $Date: 2000/08/16 05:08:19 $
*/
public class ResourcePipeline implements Composer {
private Generator generator = null;
@@ -62,10 +63,7 @@
Configuration conf, Parameters param)
throws InstantiationException, IllegalAccessException {
this.generator = (Generator)generator.getClass().newInstance();
- if (this.generator instanceof Composer)
- ((Composer)this.generator).setComponentManager (manager);
- if (this.generator instanceof Configurable)
- ((Configurable)this.generator).setConfiguration (conf);
+ this.initComponent (this.generator, conf);
this.generatorSource = source;
this.generatorParam = param;
}
@@ -84,10 +82,7 @@
Configuration conf, Parameters param, String mimeType)
throws InstantiationException, IllegalAccessException {
this.reader = (Reader)reader.getClass().newInstance();
- if (this.reader instanceof Composer)
- ((Composer)this.reader).setComponentManager (manager);
- if (this.reader instanceof Configurable)
- ((Configurable)this.reader).setConfiguration (conf);
+ this.initComponent (this.reader, conf);
this.readerSource = source;
this.readerParam = param;
this.readerMimeType = mimeType;
@@ -103,10 +98,7 @@
Configuration conf, Parameters param, String mimeType)
throws InstantiationException, IllegalAccessException {
this.serializer = (Serializer)serializer.getClass().newInstance();
- if (this.serializer instanceof Composer)
- ((Composer)this.serializer).setComponentManager (manager);
- if (this.serializer instanceof Configurable)
- ((Configurable)this.serializer).setConfiguration (conf);
+ this.initComponent (this.serializer, conf);
this.serializerSource = source;
this.serializerParam = param;
this.serializerMimeType = mimeType;
@@ -116,10 +108,7 @@
Configuration conf, Parameters param)
throws InstantiationException, IllegalAccessException {
Transformer transfmr = (Transformer)transformer.getClass().newInstance();
- if (transfmr instanceof Composer)
- ((Composer)transfmr).setComponentManager (manager);
- if (transfmr instanceof Configurable)
- ((Configurable)transfmr).setConfiguration (conf);
+ this.initComponent (transfmr, conf);
this.transformers.add (transfmr);
this.transformerSources.add (source);
this.transformerParams.add (param);
@@ -127,11 +116,17 @@
public boolean process (Environment environment)
throws ProcessingException, IOException, SAXException {
+ String mime_type=null;
if (generator == null) {
if (reader != null) {
- if (readerMimeType != null)
- environment.setContentType (readerMimeType);
reader.setup ((EntityResolver)environment, environment.getObjectModel(), readerSource, readerParam);
+ mime_type = this.reader.getMimeType();
+ if (mime_type != null) {
+ environment.setContentType (mime_type);
+ } else if (readerMimeType != null) {
+ environment.setContentType (readerMimeType);
+ } else {
+ }
reader.setOutputStream (environment.getOutputStream());
reader.generate();
} else {
@@ -155,12 +150,28 @@
producer = transformer;
}
- if (serializerMimeType != null)
+ mime_type = this.serializer.getMimeType();
+ if (mime_type != null)
+ environment.setContentType (mime_type);
+ else if (serializerMimeType != null)
environment.setContentType (serializerMimeType);
serializer.setOutputStream (environment.getOutputStream());
producer.setConsumer (serializer);
generator.generate();
}
return true;
+ }
+
+ /**
+ * Initializes a Component (inversion of control)
+ *
+ * @param comp <code>Component</code> to initialize
+ * @param conf <code>Configuration</code> of the <code>Component</code>
+ */
+ private void initComponent (Component comp, Configuration conf) {
+ if (comp instanceof Composer)
+ ((Composer)comp).setComponentManager (manager);
+ if (comp instanceof Configurable)
+ ((Configurable)comp).setConfiguration (conf);
}
}
1.1.2.2 +6 -1 xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapOutputComponent.java
Index: SitemapOutputComponent.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/SitemapOutputComponent.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- SitemapOutputComponent.java 2000/08/04 21:12:12 1.1.2.1
+++ SitemapOutputComponent.java 2000/08/16 05:08:19 1.1.2.2
@@ -15,7 +15,7 @@
/**
*
* @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/08/04 21:12:12 $
+ * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/08/16 05:08:19 $
*/
public interface SitemapOutputComponent extends Component {
@@ -24,4 +24,9 @@
* be serialized.
*/
public void setOutputStream(OutputStream out) throws IOException;
+
+ /**
+ * Get the mime-type of the output of this <code>Component</code>.
+ */
+ public String getMimeType();
}