cziegeler 01/12/14 08:12:40
Modified: src/org/apache/cocoon/transformation Tag: cocoon_20_branch
TraxTransformer.java
Log:
Cleaned up TraxTransformer code a little bit and exceptions are now propagated instead of
converted to a RuntimeException
Revision Changes Path
No revision
No revision
1.15.2.21 +43 -44 xml-cocoon2/src/org/apache/cocoon/transformation/TraxTransformer.java
Index: TraxTransformer.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/TraxTransformer.java,v
retrieving revision 1.15.2.20
retrieving revision 1.15.2.21
diff -u -r1.15.2.20 -r1.15.2.21
--- TraxTransformer.java 2001/11/15 11:20:40 1.15.2.20
+++ TraxTransformer.java 2001/12/14 16:12:40 1.15.2.21
@@ -103,7 +103,7 @@
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
* @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
- * @version CVS $Id: TraxTransformer.java,v 1.15.2.20 2001/11/15 11:20:40 cziegeler Exp
$
+ * @version CVS $Id: TraxTransformer.java,v 1.15.2.21 2001/12/14 16:12:40 cziegeler Exp
$
*/
public class TraxTransformer extends AbstractTransformer
implements Transformer, Composable, Recyclable, Configurable, Cacheable, Disposable {
@@ -149,38 +149,40 @@
public void configure(Configuration conf)
throws ConfigurationException {
if (conf != null) {
- Configuration child;
+ Configuration child;
- child = conf.getChild("use-request-parameters");
- this.useParameters = child.getValueAsBoolean(false);
- this._useParameters = this.useParameters;
- getLogger().debug("Use parameters is " + this.useParameters + " for " + this);
-
- child = conf.getChild("use-cookies");
- this.useCookies = child.getValueAsBoolean(false);
- this._useCookies = this.useCookies;
- getLogger().debug("Use cookies is " + this.useCookies + " for " + this);
-
- child = conf.getChild("use-browser-capabilities-db");
- this.useBrowserCap = child.getValueAsBoolean(false);
- this._useBrowserCap = this.useBrowserCap;
- getLogger().debug("Use browser capabilities is " + this.useBrowserCap + " for
" + this);
-
- child = conf.getChild("use-session-info");
- this.useSessionInfo = child.getValueAsBoolean(false);
- this._useSessionInfo = this.useSessionInfo;
- getLogger().debug("Use session info is " + this.useSessionInfo + " for " + this);
-
-
- child = conf.getChild("xslt-processor-role");
- String xsltRole = child.getValue(XSLTProcessor.ROLE);
- getLogger().debug("Use XSLTProcessor of role " + xsltRole);
-
- try {
- this.xsltProcessor = (XSLTProcessor)this.manager.lookup(xsltRole);
- } catch(Exception e) {
- throw new ConfigurationException("Cannot load XSLT processor", e);
- }
+ child = conf.getChild("use-request-parameters");
+ this.useParameters = child.getValueAsBoolean(false);
+ this._useParameters = this.useParameters;
+
+ child = conf.getChild("use-cookies");
+ this.useCookies = child.getValueAsBoolean(false);
+ this._useCookies = this.useCookies;
+
+ child = conf.getChild("use-browser-capabilities-db");
+ this.useBrowserCap = child.getValueAsBoolean(false);
+ this._useBrowserCap = this.useBrowserCap;
+
+ child = conf.getChild("use-session-info");
+ this.useSessionInfo = child.getValueAsBoolean(false);
+ this._useSessionInfo = this.useSessionInfo;
+
+ child = conf.getChild("xslt-processor-role");
+ String xsltRole = child.getValue(XSLTProcessor.ROLE);
+
+ if (this.getLogger().isDebugEnabled() == true) {
+ this.getLogger().debug("Use parameters is " + this.useParameters + " for
" + this);
+ this.getLogger().debug("Use cookies is " + this.useCookies + " for " +
this);
+ this.getLogger().debug("Use browser capabilities is " + this.useBrowserCap
+ " for " + this);
+ this.getLogger().debug("Use session info is " + this.useSessionInfo + "
for " + this);
+ this.getLogger().debug("Use XSLTProcessor of role " + xsltRole);
+ }
+
+ try {
+ this.xsltProcessor = (XSLTProcessor)this.manager.lookup(xsltRole);
+ } catch (ComponentException e) {
+ throw new ConfigurationException("Cannot load XSLT processor", e);
+ }
}
}
@@ -190,8 +192,9 @@
*/
public void compose(ComponentManager manager) throws ComponentException {
this.manager = manager;
- getLogger().debug("Looking up " + XSLTProcessor.ROLE);
- getLogger().debug("Looking up " + Browser.ROLE);
+ if (this.getLogger().isDebugEnabled() == true) {
+ getLogger().debug("Looking up " + Browser.ROLE);
+ }
this.browser = (Browser) manager.lookup(Browser.ROLE);
}
@@ -211,11 +214,16 @@
this.objectModel = objectModel;
this.inputSource = resolver.resolve(src);
xsltProcessor.setSourceResolver(resolver);
- getLogger().debug("Using stylesheet: '"+this.inputSource.getSystemId()+"' in "
+ this + ", last modified: " + this.inputSource.getLastModified());
_useParameters = par.getParameterAsBoolean("use-request-parameters", this.useParameters);
_useBrowserCap = par.getParameterAsBoolean("use-browser-capabilities-db", this.useBrowserCap);
_useCookies = par.getParameterAsBoolean("use-cookies", this.useCookies);
_useSessionInfo = par.getParameterAsBoolean("use-session-info", this.useSessionInfo);
+ if (this.getLogger().isDebugEnabled() == true) {
+ this.getLogger().debug("Using stylesheet: '"+this.inputSource.getSystemId()+"'
in " + this + ", last modified: " + this.inputSource.getLastModified());
+ }
+
+ /** Get a Transformer Handler */
+ this.transformerHandler = this.xsltProcessor.getTransformerHandler(inputSource);
}
/**
@@ -269,15 +277,6 @@
* Set the <code>XMLConsumer</code> that will receive XML data.
*/
public void setConsumer(XMLConsumer consumer) {
-
- /** Get a Transformer Handler */
- try {
- transformerHandler
- = xsltProcessor.getTransformerHandler(inputSource);
- } catch (Exception e){
- getLogger().error("Problem in getTransformer:", e);
- throw new RuntimeException("Problem in getTransformer:" + e.getMessage());
- }
HashMap map = getLogicSheetParameters();
if (map != null) {
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org
|