You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2002/06/07 15:15:10 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation CIncludeTransformer.java I18nTransformer.java LogTransformer.java
cziegeler 2002/06/07 06:15:10
Modified: src/java/org/apache/cocoon/acting ResourceExistsAction.java
ScriptAction.java
src/java/org/apache/cocoon/caching PipelineCacheKey.java
src/java/org/apache/cocoon/generation PhpGenerator.java
src/java/org/apache/cocoon/reading JSPReader.java
src/java/org/apache/cocoon/samples/xmlform WizardAction.java
src/java/org/apache/cocoon/transformation
CIncludeTransformer.java I18nTransformer.java
LogTransformer.java
Log:
Changed some components to use the new source resolving
Revision Changes Path
1.6 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/acting/ResourceExistsAction.java
Index: ResourceExistsAction.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/ResourceExistsAction.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ResourceExistsAction.java 22 Feb 2002 06:59:26 -0000 1.5
+++ ResourceExistsAction.java 7 Jun 2002 13:15:09 -0000 1.6
@@ -53,8 +53,8 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.environment.Redirector;
-import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
+import org.apache.excalibur.source.Source;
import java.util.Collections;
import java.util.HashMap;
@@ -66,7 +66,7 @@
* null otherwise. It has only been tested with context urls.
*
* @author <a href="mailto:balld@apache.org">Donald Ball</a>
- * @version CVS $Id: ResourceExistsAction.java,v 1.5 2002/02/22 06:59:26 cziegeler Exp $
+ * @version CVS $Id: ResourceExistsAction.java,v 1.6 2002/06/07 13:15:09 cziegeler Exp $
*/
public class ResourceExistsAction extends ComposerAction implements ThreadSafe {
@@ -74,13 +74,13 @@
String urlstring = parameters.getParameter("url",null);
Source src = null;
try {
- src = resolver.resolve(urlstring);
+ src = resolver.resolveURI(urlstring);
src.getInputStream();
} catch (Exception e) {
getLogger().debug("ResourceExistsAction: exception: ",e);
return null;
} finally {
- if (src != null) src.recycle();
+ resolver.release( src );
}
return EMPTY_MAP;
}
1.9 +4 -6 xml-cocoon2/src/java/org/apache/cocoon/acting/ScriptAction.java
Index: ScriptAction.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/ScriptAction.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ScriptAction.java 22 Feb 2002 06:59:26 -0000 1.8
+++ ScriptAction.java 7 Jun 2002 13:15:09 -0000 1.9
@@ -62,8 +62,8 @@
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
+import org.apache.excalibur.source.Source;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
@@ -76,7 +76,7 @@
* A simple action that executes any script that can be run by the BSF
*
* @author <a href="mailto:jafoster@uwaterloo.ca">Jason Foster</a>
- * @version CVS $Id: ScriptAction.java,v 1.8 2002/02/22 06:59:26 cziegeler Exp $
+ * @version CVS $Id: ScriptAction.java,v 1.9 2002/06/07 13:15:09 cziegeler Exp $
*/
public class ScriptAction
@@ -97,7 +97,7 @@
String scriptName = source;
// Locate the appropriate file on the filesytem
- src = resolver.resolve(scriptName);
+ src = resolver.resolveURI(scriptName);
String systemID = src.getSystemId();
if (this.getLogger().isDebugEnabled()) {
@@ -151,13 +151,11 @@
{
return ( null );
}
- } catch (ProcessingException e) {
- throw e;
} catch (Exception e) {
throw new ProcessingException(
"Exception in ScriptAction.act()", e);
} finally {
- if (src != null) src.recycle();
+ resolver.release( src );
} // try/catch
} // public Map act(...)
} // public class ScriptAction
1.17 +5 -4 xml-cocoon2/src/java/org/apache/cocoon/caching/PipelineCacheKey.java
Index: PipelineCacheKey.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/caching/PipelineCacheKey.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- PipelineCacheKey.java 5 Jun 2002 07:33:24 -0000 1.16
+++ PipelineCacheKey.java 7 Jun 2002 13:15:09 -0000 1.17
@@ -58,7 +58,7 @@
* It consists of one or more {@link ComponentCacheKey}s.
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: PipelineCacheKey.java,v 1.16 2002/06/05 07:33:24 cziegeler Exp $
+ * @version CVS $Id: PipelineCacheKey.java,v 1.17 2002/06/07 13:15:09 cziegeler Exp $
*/
public final class PipelineCacheKey
implements java.io.Serializable {
@@ -134,10 +134,11 @@
public int hashCode() {
// FIXME - this is not very safe
if (this.hashCode == 0) {
- for(int i=0; i < this.keys.size(); i++) {
+ final int len = this.keys.size();
+ for(int i=0; i < len; i++) {
this.hashCode += this.keys.get(i).hashCode();
}
- if (this.keys.size() % 2 == 0) this.hashCode++;
+ if (len % 2 == 0) this.hashCode++;
}
return this.hashCode;
}
@@ -146,8 +147,8 @@
* Clone the object (but not the component keys)
*/
public PipelineCacheKey copy() {
- PipelineCacheKey pck = new PipelineCacheKey(this.keys.size());
final int len = this.keys.size();
+ PipelineCacheKey pck = new PipelineCacheKey(len);
for(int i=0; i < len; i++) {
pck.keys.add(this.keys.get(i));
}
1.7 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/generation/PhpGenerator.java
Index: PhpGenerator.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/PhpGenerator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PhpGenerator.java 22 Feb 2002 07:03:51 -0000 1.6
+++ PhpGenerator.java 7 Jun 2002 13:15:09 -0000 1.7
@@ -52,8 +52,8 @@
import org.apache.avalon.excalibur.xml.Parser;
import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.http.HttpEnvironment;
+import org.apache.excalibur.source.Source;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -74,7 +74,7 @@
* results into SAX events.
*
* @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
- * @version CVS $Id: PhpGenerator.java,v 1.6 2002/02/22 07:03:51 cziegeler Exp $
+ * @version CVS $Id: PhpGenerator.java,v 1.7 2002/06/07 13:15:09 cziegeler Exp $
*/
public class PhpGenerator extends ServletGenerator {
@@ -169,7 +169,7 @@
Source inputSource = null;
Parser parser = null;
try {
- inputSource = this.resolver.resolve(this.source);
+ inputSource = this.resolver.resolveURI(this.source);
String systemId = inputSource.getSystemId();
if (!systemId.startsWith("file:/"))
throw new IOException("protocol not supported: " + systemId);
@@ -199,7 +199,7 @@
getLogger().debug("PhpGenerator.generate()", e);
throw new IOException(e.toString());
} finally {
- if (inputSource != null) inputSource.recycle();
+ this.resolver.release( inputSource );
this.manager.release(parser);
}
}
1.6 +11 -6 xml-cocoon2/src/java/org/apache/cocoon/reading/JSPReader.java
Index: JSPReader.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/reading/JSPReader.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JSPReader.java 22 Apr 2002 09:48:12 -0000 1.5
+++ JSPReader.java 7 Jun 2002 13:15:09 -0000 1.6
@@ -64,17 +64,17 @@
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.jsp.JSPEngine;
-import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.Context;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.http.HttpEnvironment;
+import org.apache.excalibur.source.Source;
/**
* The <code>JSPReader</code> component is used to serve JSP page output data
* in a sitemap pipeline.
*
* @author <a href="mailto:kpiroumian@flagship.ru">Konstantin Piroumian</a>
- * @version CVS $Id: JSPReader.java,v 1.5 2002/04/22 09:48:12 kpiroumian Exp $
+ * @version CVS $Id: JSPReader.java,v 1.6 2002/06/07 13:15:09 cziegeler Exp $
*/
public class JSPReader extends AbstractReader implements Composable, Poolable {
@@ -111,10 +111,15 @@
String url = this.source;
// -- debug info --
- Source src = resolver.resolve(url);
- System.out.println("Resolved to: " + src);
- java.net.URL resURL = httpContext.getResource(".");
- System.out.println(". resource is: " + resURL);
+ Source src = null;
+ try {
+ src = resolver.resolveURI(url);
+ System.out.println("Resolved to: " + src);
+ java.net.URL resURL = httpContext.getResource(".");
+ System.out.println(". resource is: " + resURL);
+ } finally {
+ resolver.release( src );
+ }
// -- end debug --
1.2 +64 -62 xml-cocoon2/src/java/org/apache/cocoon/samples/xmlform/WizardAction.java
Index: WizardAction.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/samples/xmlform/WizardAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WizardAction.java 20 May 2002 07:19:26 -0000 1.1
+++ WizardAction.java 7 Jun 2002 13:15:09 -0000 1.2
@@ -1,12 +1,12 @@
/*
- * $Header: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/samples/xmlform/WizardAction.java,v 1.1 2002/05/20 07:19:26 ivelin Exp $
- * $Revision: 1.1 $
- * $Date: 2002/05/20 07:19:26 $
+ * $Header: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/samples/xmlform/WizardAction.java,v 1.2 2002/06/07 13:15:09 cziegeler Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/06/07 13:15:09 $
*
* ====================================================================
* The Apache Software License, Version 1.1
*
- *
+ *
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
@@ -83,6 +83,7 @@
// Framework classes
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.excalibur.pool.Poolable;
+import org.apache.excalibur.source.Source;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -108,19 +109,19 @@
/**
- * This action demonstrates
+ * This action demonstrates
* a relatively complex form handling scenario.
*
* @author Ivelin Ivanov <iv...@apache.org>
*/
-public class WizardAction
+public class WizardAction
extends AbstractXMLFormAction
implements FormListener
-
-{
+
+{
- // different form views
+ // different form views
// participating in the wizard
final String VIEW_START = "start";
final String VIEW_USERID = "userIdentity";
@@ -133,8 +134,8 @@
final String CMD_START = "start";
final String CMD_NEXT = "next";
final String CMD_PREV = "prev";
-
-
+
+
/**
* The first callback method which is called
* when an action is invoked.
@@ -146,20 +147,20 @@
* an objectModel map which will be immediately returned by the action.
*
* This method is a good place to handle buttons with Cancel
- * kind of semantics. For example
+ * kind of semantics. For example
* <pre>if getCommand().equals("Cancel") return page("input");</pre>
*
*/
- protected Map prepare()
+ protected Map prepare()
{
-
+
if ( getCommand() == null )
- {
+ {
// initial link
return page( VIEW_START );
}
else if ( Form.lookup ( getObjectModel(), getFormId() ) == null)
- {
+ {
// session expired
return page( VIEW_START );
}
@@ -173,13 +174,13 @@
return page( VIEW_USERID );
}
-
+
// get ready for action
// if not ready return page("whereNext");
return null;
}
-
+
/**
* Invoked after form population
*
@@ -196,23 +197,23 @@
UserBean jBean = (UserBean) getForm().getModel();
jBean.incrementCount();
- // set the page control flow parameter
+ // set the page control flow parameter
// according to the validation result
- if ( getCommand().equals( CMD_NEXT ) &&
+ if ( getCommand().equals( CMD_NEXT ) &&
getForm().getViolations () != null )
{
// errors, back to the same page
return page( getFormView() );
}
- else
+ else
{
// validation passed
// continue with control flow
-
- // clear validation left overs in case the user
+
+ // clear validation left overs in case the user
// did not press the Next button
getForm().clearViolations();
-
+
// get the user submitted command (through a submit button)
String command = getCommand();
// get the form view which was submitted
@@ -256,17 +257,17 @@
}
// should never reach this statement
- return page( VIEW_START );
-
- }
+ return page( VIEW_START );
+
+ }
+
+
+
-
-
-
- /**
+ /**
*
- * FormListener callback
+ * FormListener callback
* called in the beginning Form.populate()
* before population starts.
*
@@ -290,30 +291,30 @@
ub.initRoles ();
}
}
-
-
- /**
- * FormListener callback
- *
+
+
+ /**
+ * FormListener callback
+ *
* Invoked during Form.populate();
*
* It is invoked before a request parameter is mapped to
* an attribute of the form model.
*
- * It is appropriate to use this method for filtering
+ * It is appropriate to use this method for filtering
* custom request parameters which do not reference
* the model.
*
* Another appropriate use of this method is for graceful filtering of invalid
- * values, in case that knowledge of the system state or
- * other circumstainces make the standard validation
+ * values, in case that knowledge of the system state or
+ * other circumstainces make the standard validation
* insufficient. For example if a registering user choses a username which
- * is already taken - the check requires database transaction, which is
- * beyond the scope of document validating schemas.
- * Of course customized Validators can be implemented to do
+ * is already taken - the check requires database transaction, which is
+ * beyond the scope of document validating schemas.
+ * Of course customized Validators can be implemented to do
* this kind of domain specific validation
* instead of using this method.
- *
+ *
*
* @return false if the request parameter should not be filtered.
* true otherwise.
@@ -323,26 +324,27 @@
// TBD
return false;
}
-
-
- public String getFile( String FileName ) {
- try
- {
- final String FILE_PREFIX = "file:";
- String path = getSourceResolver().resolve(FileName).getSystemId();
- if(path.startsWith(FILE_PREFIX))
- path = path.substring(FILE_PREFIX.length());
- return path;
- }
- catch(Exception e)
- {
- getLogger().error("could not read mapping file",e);
- return null;
- }
+
+
+ public String getFile( String FileName ) {
+ Source source = null;
+ try {
+ source = getSourceResolver().resolveURI(FileName);
+ final String FILE_PREFIX = "file:";
+ String path = source.getSystemId();
+ if(path.startsWith(FILE_PREFIX))
+ path = path.substring(FILE_PREFIX.length());
+ return path;
+ } catch(Exception e) {
+ getLogger().error("could not read mapping file",e);
+ return null;
+ } finally {
+ this.getSourceResolver().release( source );
+ }
}
-
+
private Validator validator_ = null;
private boolean initialized_ = false;
-
+
}
1.7 +9 -5 xml-cocoon2/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java
Index: CIncludeTransformer.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/CIncludeTransformer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CIncludeTransformer.java 22 Feb 2002 07:03:56 -0000 1.6
+++ CIncludeTransformer.java 7 Jun 2002 13:15:10 -0000 1.7
@@ -54,9 +54,10 @@
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.xml.IncludeXMLConsumer;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -74,7 +75,7 @@
* which surrounds the included content.
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: CIncludeTransformer.java,v 1.6 2002/02/22 07:03:56 cziegeler Exp $
+ * @version CVS $Id: CIncludeTransformer.java,v 1.7 2002/06/07 13:15:10 cziegeler Exp $
*/
public class CIncludeTransformer extends AbstractTransformer
implements Composable {
@@ -168,16 +169,19 @@
Source source = null;
try {
- source = this.sourceResolver.resolve(src);
- source.toSAX(consumer);
+ source = this.sourceResolver.resolveURI(src);
+ this.sourceResolver.toSAX(source, consumer);
} catch (IOException e) {
getLogger().error("CIncludeTransformer", e);
throw new SAXException("CIncludeTransformer could not read resource", e);
+ } catch (SourceException se) {
+ getLogger().error("Could not stream input", se);
+ throw new SAXException("Exception in CIncludeTransformer",se);
} catch (ProcessingException e){
getLogger().error("Could not stream input", e);
throw new SAXException("Exception in CIncludeTransformer",e);
} finally {
- source.recycle();
+ this.sourceResolver.release(source);
}
if (!"".equals(element)) {
1.19 +5 -4 xml-cocoon2/src/java/org/apache/cocoon/transformation/I18nTransformer.java
Index: I18nTransformer.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/I18nTransformer.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- I18nTransformer.java 21 May 2002 12:24:57 -0000 1.18
+++ I18nTransformer.java 7 Jun 2002 13:15:10 -0000 1.19
@@ -83,7 +83,7 @@
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.ResourceNotFoundException;
-import org.apache.cocoon.environment.Source;
+import org.apache.excalibur.source.Source;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.i18n.I18nUtils;
import org.apache.cocoon.i18n.XMLResourceBundle;
@@ -224,7 +224,7 @@
* @author <a href="mailto:Marcus.Crafter@managesoft.com">Marcus Crafter</a>
* @author <a href="mailto:Michael.Enke@wincor-nixdorf.com">Michael Enke</a>
* @author <a href="mailto:lassi.immonen@valkeus.com">Lassi Immonen</a>
- * @version CVS $Id: I18nTransformer.java,v 1.18 2002/05/21 12:24:57 cziegeler Exp $
+ * @version CVS $Id: I18nTransformer.java,v 1.19 2002/06/07 13:15:10 cziegeler Exp $
*
* @todo Move all formatting/parsing routines to I18nUtils
*/
@@ -829,8 +829,9 @@
);
debug("catalog location:" + location);
- Source source = resolver.resolve(location);
+ Source source = null;
try {
+ source = resolver.resolveURI(location);
String systemId = source.getSystemId();
if (!systemId.startsWith(FILE)) {
throw new ResourceNotFoundException(
@@ -841,7 +842,7 @@
dirConf.setValue(systemId);
configuration.addChild(dirConf);
} finally {
- source.recycle();
+ resolver.release(source);
}
// Pass created configuration object to the factory
1.8 +8 -4 xml-cocoon2/src/java/org/apache/cocoon/transformation/LogTransformer.java
Index: LogTransformer.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/LogTransformer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LogTransformer.java 22 Feb 2002 07:03:56 -0000 1.7
+++ LogTransformer.java 7 Jun 2002 13:15:10 -0000 1.8
@@ -52,7 +52,9 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.Source;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.SourceResolver;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
@@ -88,7 +90,7 @@
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @author <a href="mailto:giacomo.pati@pwr.ch">Giacomo Pati</a>
* (PWR Organisation & Entwicklung)
- * @version CVS $Id: LogTransformer.java,v 1.7 2002/02/22 07:03:56 cziegeler Exp $
+ * @version CVS $Id: LogTransformer.java,v 1.8 2002/06/07 13:15:10 cziegeler Exp $
*
*/
public class LogTransformer
@@ -113,15 +115,17 @@
if ( null != logfilename ) {
Source source = null;
try {
- source = resolver.resolve( logfilename );
+ source = resolver.resolveURI( logfilename );
final String systemId = source.getSystemId();
if ( systemId.startsWith("file:") ) {
this.logfile = new FileWriter(systemId.substring(5), append );
} else {
throw new ProcessingException("The logfile parameter must point to a file: " + logfilename);
}
+ } catch (SourceException se) {
+ throw SourceUtil.handle(se);
} finally {
- if (source != null) source.recycle();
+ resolver.release( source );
}
}
----------------------------------------------------------------------
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