You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by je...@apache.org on 2003/03/15 12:02:52 UTC
cvs commit: xml-forrest/src/java/components/org/apache/cocoon/transformation IdGeneratorTransformer.java XPathTransformer.java
jefft 2003/03/15 03:02:52
Modified: src/java/components/org/apache/cocoon/transformation
IdGeneratorTransformer.java XPathTransformer.java
Log:
IdGeneratorTransformer:
- Implement Disposable()
- Update to non-deprecated cache classes
- Improve error handling by properly using SAXException
XPathTransformer
- doc fix
Revision Changes Path
1.3 +16 -13 xml-forrest/src/java/components/org/apache/cocoon/transformation/IdGeneratorTransformer.java
Index: IdGeneratorTransformer.java
===================================================================
RCS file: /home/cvs/xml-forrest/src/java/components/org/apache/cocoon/transformation/IdGeneratorTransformer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IdGeneratorTransformer.java 15 Mar 2003 06:11:05 -0000 1.2
+++ IdGeneratorTransformer.java 15 Mar 2003 11:02:52 -0000 1.3
@@ -51,16 +51,17 @@
package org.apache.cocoon.transformation;
import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.ProcessingException;
import org.apache.excalibur.xml.xpath.XPathProcessor;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.source.impl.validity.NOPValidity;
+import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.caching.Cacheable;
-import org.apache.cocoon.caching.CacheValidity;
-import org.apache.cocoon.caching.NOPCacheValidity;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.xml.XMLUtils;
import org.apache.cocoon.util.HashUtil;
@@ -121,7 +122,7 @@
*/
public class IdGeneratorTransformer
extends AbstractDOMTransformer
- implements Cacheable, Configurable
+ implements CacheableProcessingComponent, Configurable, Disposable
{
/** XPath Processor */
@@ -193,8 +194,8 @@
newDoc = addIds(doc, elementXPath, idXPath);
} catch (SAXException se) {
// Really ought to be able to propagate these to caller
- getLogger().error("Error when transforming XML", se);
- throw new RuntimeException("Error transforming XML. See error log for details: "+se);
+ getLogger().error("Error when transforming XML: "+se.getMessage(), se.getException());
+ throw new RuntimeException("Error transforming XML. See error log for details: "+se.getMessage()+". Nested exception: "+se.getException().getMessage());
}
return newDoc;
}
@@ -211,7 +212,7 @@
try {
id = processor.evaluateAsString(sect, idXPath);
} catch (Exception e) {
- throw new RuntimeException("'id' XPath expression '"+idXPath+"' does not return a text node: "+e);
+ throw new SAXException("'id' XPath expression '"+idXPath+"' does not return a text node: "+e, e);
}
getLogger().info("## Got id "+id);
if (!sect.hasAttribute(this.idAttr)) {
@@ -251,19 +252,21 @@
* @return A hash of the element and id parameters, thus uniquely
* identifying this IdGenerator amongst it's peers.
*/
- public long generateKey() {
- return HashUtil.hash(this.elementXPath+this.idXPath);
+ public Serializable generateKey() {
+ return ""+HashUtil.hash(this.elementXPath+this.idXPath);
}
+
/**
* Generate the validity object.
*
- * @return An "always valid" CacheValidity object. This transformer has no
+ * @return An "always valid" SourceValidity object. This transformer has no
* inputs other than the incoming SAX events.
*/
- public CacheValidity generateValidity() {
- return new NOPCacheValidity();
+ public SourceValidity generateValidity() {
+ return new NOPValidity();
}
+
/**
* Recycle the component.
1.4 +2 -2 xml-forrest/src/java/components/org/apache/cocoon/transformation/XPathTransformer.java
Index: XPathTransformer.java
===================================================================
RCS file: /home/cvs/xml-forrest/src/java/components/org/apache/cocoon/transformation/XPathTransformer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XPathTransformer.java 15 Mar 2003 06:11:43 -0000 1.3
+++ XPathTransformer.java 15 Mar 2003 11:02:52 -0000 1.4
@@ -382,7 +382,7 @@
/**
* Generate the validity object.
*
- * @return An "always valid" CacheValidity object. This transformer has no
+ * @return An "always valid" SourceValidity object. This transformer has no
* inputs other than the incoming SAX events.
*/
public SourceValidity generateValidity() {