cziegeler 01/06/28 02:56:51
Modified: . changes.xml todo.xml
src/org/apache/cocoon Cocoon.java
src/org/apache/cocoon/components/language/markup/xsp
XSPFormValidatorHelper.java
src/org/apache/cocoon/environment AbstractEnvironment.java
FactoryURLResolver.java Source.java
SourceResolver.java URLResolver.java
src/org/apache/cocoon/generation FileGenerator.java
src/org/apache/cocoon/sitemap AbstractSitemap.java
ContentAggregator.java Handler.java Sitemap.java
src/org/apache/cocoon/transformation I18nTransformer.java
TraxTransformer.java
Added: src/org/apache/cocoon/environment URLSource.java
src/org/apache/cocoon/sitemap SitemapSource.java
SitemapURLResolver.java
Log:
Added the cocoon: protocol
Revision Changes Path
1.15 +4 -1 xml-cocoon2/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/changes.xml,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- changes.xml 2001/06/20 13:18:56 1.14
+++ changes.xml 2001/06/28 09:56:27 1.15
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.14 2001/06/20 13:18:56 cziegeler Exp $
+ $Id: changes.xml,v 1.15 2001/06/28 09:56:27 cziegeler Exp $
-->
<changes title="History of Changes">
@@ -24,6 +24,9 @@
</devs>
<release version="2.1-dev" date="@date@">
+ <action dev="CZ" type="add">
+ Added the cocoon: protocol to access pipelines.
+ </action>
<action dev="CZ" type="add">
Removed XInclude/CIncludeSAXConnectors and added LoggingSAXConnector.
</action>
1.2 +3 -12 xml-cocoon2/todo.xml
Index: todo.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/todo.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- todo.xml 2001/05/09 20:49:26 1.1
+++ todo.xml 2001/06/28 09:56:28 1.2
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: todo.xml,v 1.1 2001/05/09 20:49:26 giacomo Exp $
+ $Id: todo.xml,v 1.2 2001/06/28 09:56:28 cziegeler Exp $
-->
@@ -36,9 +36,8 @@
is created then) the classpath is rebuild and used.
</action>
- <action context="code" assigned-to="DM">
- Make the evaluation/application of logicsheets in the XSP system reliable
- and usable without hassle to the logicsheet programmer
+ <action context="code" assigned-to="open">
+ Finish the cocoon: protocol.
</action>
<action context="code" assigned-to="open">
@@ -50,14 +49,6 @@
Complete (means put everything we know of into even if it has to be
commented)
the web.xml file and put descriptions into it (similar to the
httpd.conf file of the web server or the server.xml of Catalina)
- </action>
-
- <action context="code" assigned-to="GP">
- Implement content aggregation at the sitemap level.
- </action>
-
- <action context="code" assigned-to="PR">
- Implement transparent content aggregation at the pipeline level.
</action>
</actions>
1.13 +7 -4 xml-cocoon2/src/org/apache/cocoon/Cocoon.java
Index: Cocoon.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Cocoon.java 2001/06/22 18:19:37 1.12
+++ Cocoon.java 2001/06/28 09:56:30 1.13
@@ -39,7 +39,9 @@
import org.apache.cocoon.components.store.FilesystemStore;
import org.apache.cocoon.components.url.URLFactory;
import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.FactoryURLResolver;
import org.apache.cocoon.environment.Source;
+import org.apache.cocoon.environment.URLSource;
import org.apache.cocoon.serialization.Serializer;
import org.apache.cocoon.sitemap.Manager;
import org.apache.cocoon.sitemap.AbstractSitemap;
@@ -55,7 +57,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
(Apache Software Foundation, Exoffice Technologies)
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.12 $ $Date: 2001/06/22 18:19:37 $
+ * @version CVS $Revision: 1.13 $ $Date: 2001/06/28 09:56:30 $
*/
public class Cocoon extends AbstractLoggable implements ThreadSafe,
Component, Initializable, Disposable, Modifiable, Processor, Contextualizable {
/** The application context */
@@ -103,7 +105,8 @@
this.classpath =
(String)context.get(Constants.CONTEXT_CLASSPATH);
this.workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
try {
- this.configurationFile = new
Source((URL)context.get(Constants.CONTEXT_CONFIG_URL));
+ this.configurationFile = new
URLSource((URL)context.get(Constants.CONTEXT_CONFIG_URL),
+
this.componentManager);
} catch (IOException ioe) {
getLogger().error("Could not open configuration file.", ioe);
throw new ContextException("Could not open configuration
file.", ioe);
@@ -370,7 +373,7 @@
try {
programGenerator = (ProgramGenerator)
this.componentManager.lookup(Roles.PROGRAM_GENERATOR);
urlFactory = (URLFactory)
this.componentManager.lookup(Roles.URL_FACTORY);
- environment.setURLResolver(new
org.apache.cocoon.environment.FactoryURLResolver(urlFactory));
+ environment.setURLResolver(new
FactoryURLResolver(this.componentManager, urlFactory));
String markupLanguage = "sitemap";
String programmingLanguage = "java";
@@ -405,7 +408,7 @@
programGenerator = (ProgramGenerator)
this.componentManager.lookup(Roles.PROGRAM_GENERATOR);
urlFactory = (URLFactory)
this.componentManager.lookup(Roles.URL_FACTORY);
- environment.setURLResolver(new
org.apache.cocoon.environment.FactoryURLResolver(urlFactory));
+ environment.setURLResolver(new
FactoryURLResolver(this.componentManager, urlFactory));
String markupLanguage = "xsp";
String programmingLanguage = "java";
1.3 +3 -2
xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPFormValidatorHelper.java
Index: XSPFormValidatorHelper.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/XSPFormValidatorHelper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XSPFormValidatorHelper.java 2001/06/15 11:49:22 1.2
+++ XSPFormValidatorHelper.java 2001/06/28 09:56:32 1.3
@@ -20,6 +20,7 @@
import org.apache.cocoon.components.language.markup.xsp.XSPObjectHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Source;
+import org.apache.cocoon.environment.URLSource;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
@@ -38,7 +39,7 @@
* The <code>ValidatorActionResult</code> object helper
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
- * @version CVS $Revision: 1.2 $ $Date: 2001/06/15 11:49:22 $
+ * @version CVS $Revision: 1.3 $ $Date: 2001/06/28 09:56:32 $
*/
public class XSPFormValidatorHelper {
/**
@@ -470,7 +471,7 @@
try {
urlFactory = (URLFactory) manager.lookup(Roles.URL_FACTORY);
URL resource = urlFactory.getURL(descriptor);
- source = new Source(resource);
+ source = new URLSource(resource, manager);
if (conf == null || ( reloadable && conf.lastModified <
source.getLastModified())) {
logger.debug("XSPFormValidatorHelper.getConfiguration:
(Re)Loading " + descriptor);
1.7 +9 -5
xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java
Index: AbstractEnvironment.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/AbstractEnvironment.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractEnvironment.java 2001/05/31 20:37:05 1.6
+++ AbstractEnvironment.java 2001/06/28 09:56:34 1.7
@@ -15,6 +15,7 @@
import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.framework.logger.AbstractLoggable;
+import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.Environment;
import org.apache.log.LogKit;
import org.xml.sax.InputSource;
@@ -194,22 +195,23 @@
* Resolve an entity.
*/
public Source resolve(String systemId)
- throws SAXException, IOException {
+ throws ProcessingException, SAXException, IOException {
if (systemId == null) throw new SAXException("Invalid System ID");
if (systemId.length() == 0)
- return new Source(this.context);
+ return this.urlResolver.getSource(this,
this.context.toExternalForm());
if (systemId.indexOf(":") > 1)
- return new Source(this.urlResolver.getURL(systemId));
+ return this.urlResolver.getSource(this, systemId);
if (systemId.charAt(0) == '/')
- return new
Source(this.urlResolver.getURL(this.context.getProtocol() + ":" + systemId));
- return new Source(this.urlResolver.getURL(this.context, systemId));
+ return this.urlResolver.getSource(this,
this.context.getProtocol() + ":" + systemId);
+ return this.urlResolver.getSource(this, this.context, systemId);
}
/**
* Push a new URI for processing
*/
public void pushURI(String uri) {
+ this.uris.add(this.urlResolver);
this.uris.add(uri);
}
@@ -218,6 +220,8 @@
*/
public String popURI() {
String uri = (String)this.uris.get(this.uris.size()-1);
+ this.uris.remove(this.uris.size()-1);
+ this.urlResolver = (URLResolver)this.uris.get(this.uris.size()-1);
this.uris.remove(this.uris.size()-1);
return uri;
}
1.2 +18 -8
xml-cocoon2/src/org/apache/cocoon/environment/FactoryURLResolver.java
Index: FactoryURLResolver.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/FactoryURLResolver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FactoryURLResolver.java 2001/05/22 14:38:51 1.1
+++ FactoryURLResolver.java 2001/06/28 09:56:35 1.2
@@ -8,10 +8,14 @@
package org.apache.cocoon.environment;
+import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
-
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.url.URLFactory;
+import org.apache.cocoon.environment.Source;
+import org.apache.cocoon.environment.URLSource;
/**
* This interface describes the URLResolver which is used by the
@@ -22,31 +26,37 @@
* This class used only the <code>URLFactory</code>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/05/22 14:38:51 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/06/28 09:56:35 $
*/
public final class FactoryURLResolver
implements URLResolver {
private URLFactory factory;
+
+ private ComponentManager manager;
- public FactoryURLResolver(URLFactory factory) {
+ public FactoryURLResolver(ComponentManager manager,
+ URLFactory factory) {
+ this.manager = manager;
this.factory = factory;
}
/**
* Resolve the source
*/
- public URL getURL(String location) throws MalformedURLException {
- return this.factory.getURL(location);
+ public Source getSource(Environment environment, String location)
+ throws ProcessingException, IOException, MalformedURLException {
+ return new URLSource(this.factory.getURL(location), manager);
}
/**
* Resolve the source
*/
- public URL getURL(URL base, String location) throws
MalformedURLException {
- return this.factory.getURL(base, location);
+ public Source getSource(Environment environment, URL base, String
location)
+ throws ProcessingException, IOException, MalformedURLException {
+ return new URLSource(this.factory.getURL(base, location), manager);
}
-}
\ No newline at end of file
+}
1.7 +20 -104 xml-cocoon2/src/org/apache/cocoon/environment/Source.java
Index: Source.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/Source.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Source.java 2001/05/31 13:17:41 1.6
+++ Source.java 2001/06/28 09:56:36 1.7
@@ -17,155 +17,71 @@
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.xml.XMLConsumer;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* Description of a source. This interface provides a simple interface
* for accessing any resource (URL, local file etc).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.6 $ $Date: 2001/05/31 13:17:41 $
+ * @version CVS $Revision: 1.7 $ $Date: 2001/06/28 09:56:36 $
*/
-public final class Source {
-
- /** Identifier for file urls */
- private final String FILE = "file:";
-
- /** The last modification date or 0 */
- private long lastModificationDate;
-
- /** The content length */
- private long contentLength;
-
- /** The system id */
- private String systemId;
-
- /** The URL of the source */
- private URL url;
-
- /** The connection for a real URL */
- private URLConnection connection;
-
- /** Is this a file or a "real" URL */
- private boolean isFile;
-
- /** Are we initialized? */
- private boolean gotInfos;
-
- /**
- * Construct a new object
- */
- public Source(URL url)
- throws IOException {
- this.systemId = url.toExternalForm();
- this.isFile = systemId.startsWith(FILE);
- this.url = url;
- this.gotInfos = false;
- }
-
- /**
- * Get the last modification date and content length of the source.
- * Any exceptions are ignored.
- */
- private void getInfos() {
- if (this.gotInfos == false) {
- if (this.isFile == true) {
- File file = new File(systemId.substring(FILE.length()));
- this.lastModificationDate = file.lastModified();
- this.contentLength = file.length();
- } else {
- try {
- if (this.connection == null)
- this.connection = this.url.openConnection();
- this.lastModificationDate =
this.connection.getLastModified();
- this.contentLength = this.connection.getContentLength();
- } catch (IOException ignore) {
- this.lastModificationDate = 0;
- this.contentLength = -1;
- }
- }
- this.gotInfos = true;
- }
- }
-
+public interface Source {
/**
* Get the last modification date of the source or 0 if it
* is not possible to determine the date.
*/
- public long getLastModified() {
- this.getInfos();
- return this.lastModificationDate;
- }
+ long getLastModified();
/**
* Get the content length of the source or -1 if it
* is not possible to determine the length.
*/
- public long getContentLength() {
- this.getInfos();
- return this.contentLength;
- }
+ long getContentLength();
/**
* Return an <code>InputStream</code> object to read from the source.
*/
- public InputStream getInputStream()
- throws IOException {
- if (this.isFile == true) {
- return new
FileInputStream(this.systemId.substring(FILE.length()));
- } else {
- if (this.connection == null)
- this.connection = this.url.openConnection();
- return this.connection.getInputStream();
- }
- }
+ InputStream getInputStream()
+ throws ProcessingException, IOException;
/**
* Return the unique identifer for this source
*/
- public String getSystemId() {
- return this.systemId;
- }
+ String getSystemId();
/**
* Is this a file, then the <code>getFile</code> method can
* return a <code>File</code> object for this source.
*/
- public boolean isFile() {
- return this.isFile;
- }
+ boolean isFile();
/**
* Return a <code>File</code> object if this is a local file
* (if the <code>isFile</code> method returns true).
*/
- public File getFile() {
- if (this.isFile == true) {
- return new File(this.systemId.substring(FILE.length()));
- }
- return null;
- }
+ File getFile();
/**
* Refresh this object and update the last modified date
* and content length.
*/
- public void refresh() {
- // reset connection
- this.connection = null;
- this.gotInfos = false;
- }
+ void refresh();
/**
* Return a new <code>InputSource</code> object
*/
- public InputSource getInputSource()
- throws IOException {
- InputSource newObject = new InputSource(this.getInputStream());
- newObject.setSystemId(this.systemId);
- return newObject;
- }
+ InputSource getInputSource()
+ throws ProcessingException, IOException;
+ /**
+ * Stream content to the consumer
+ */
+ void stream(XMLConsumer consumer)
+ throws ProcessingException, SAXException, IOException;
}
1.3 +3 -3
xml-cocoon2/src/org/apache/cocoon/environment/SourceResolver.java
Index: SourceResolver.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/SourceResolver.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SourceResolver.java 2001/05/23 08:57:26 1.2
+++ SourceResolver.java 2001/06/28 09:56:36 1.3
@@ -9,13 +9,14 @@
package org.apache.cocoon.environment;
import java.io.IOException;
+import org.apache.cocoon.ProcessingException;
import org.xml.sax.SAXException;
/**
* Base interface for resolving a source by system identifiers.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.2 $ $Date: 2001/05/23 08:57:26 $
+ * @version CVS $Revision: 1.3 $ $Date: 2001/06/28 09:56:36 $
*/
public interface SourceResolver {
@@ -26,7 +27,6 @@
* (<code>java.net.URL</code> or a local file.
*/
Source resolve(String systemID)
- throws SAXException, IOException;
-
+ throws ProcessingException, SAXException, IOException;
}
1.2 +15 -6
xml-cocoon2/src/org/apache/cocoon/environment/URLResolver.java
Index: URLResolver.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/URLResolver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- URLResolver.java 2001/05/22 14:38:53 1.1
+++ URLResolver.java 2001/06/28 09:56:36 1.2
@@ -8,29 +8,38 @@
package org.apache.cocoon.environment;
+import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.Source;
/**
* This interface describes the URLResolver which is used by the
* <code>SourceResolver</code>.
* The <code>URLResolver</code> separates the <code>SourceResolver</code>
- * from the <code>URLFactory</code>.
+ * from the <code>URLFactory</code>. The context for the factory is
+ * calculated by this object.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/05/22 14:38:53 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/06/28 09:56:36 $
*/
public interface URLResolver {
/**
- * Resolve the source
+ * Resolve the source according to the environment.
+ * @param environment The current environment or <code>null</code>.
*/
- URL getURL(String location) throws MalformedURLException;
+ Source getSource(Environment environment, String location)
+ throws ProcessingException, IOException, MalformedURLException;
/**
- * Resolve the source
+ * Resolve the source according to the environment.
+ * @param environment The current environment or <code>null</code>.
*/
- URL getURL(URL base, String location) throws MalformedURLException;
+ Source getSource(Environment environment, URL base, String location)
+ throws ProcessingException, IOException, MalformedURLException;
}
1.1
xml-cocoon2/src/org/apache/cocoon/environment/URLSource.java
Index: URLSource.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.cocoon.environment;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.Roles;
import org.apache.cocoon.components.parser.Parser;
import org.apache.cocoon.xml.XMLConsumer;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Description of a source which is described by an URL.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/06/28 09:56:37 $
*/
public final class URLSource
implements Source {
/** Identifier for file urls */
private final String FILE = "file:";
/** The last modification date or 0 */
private long lastModificationDate;
/** The content length */
private long contentLength;
/** The system id */
private String systemId;
/** The URL of the source */
private URL url;
/** The connection for a real URL */
private URLConnection connection;
/** Is this a file or a "real" URL */
private boolean isFile;
/** Are we initialized? */
private boolean gotInfos;
/** The ComponentManager needed for streaming */
private ComponentManager manager;
/**
* Construct a new object
*/
public URLSource(URL url, ComponentManager manager)
throws IOException {
this.manager = manager;
this.systemId = url.toExternalForm();
this.isFile = systemId.startsWith(FILE);
this.url = url;
this.gotInfos = false;
}
/**
* Get the last modification date and content length of the source.
* Any exceptions are ignored.
*/
private void getInfos() {
if (this.gotInfos == false) {
if (this.isFile == true) {
File file = new File(systemId.substring(FILE.length()));
this.lastModificationDate = file.lastModified();
this.contentLength = file.length();
} else {
try {
if (this.connection == null) {
this.connection = this.url.openConnection();
}
this.lastModificationDate =
this.connection.getLastModified();
this.contentLength = this.connection.getContentLength();
} catch (IOException ignore) {
this.lastModificationDate = 0;
this.contentLength = -1;
}
}
this.gotInfos = true;
}
}
/**
* Get the last modification date of the source or 0 if it
* is not possible to determine the date.
*/
public long getLastModified() {
this.getInfos();
return this.lastModificationDate;
}
/**
* Get the content length of the source or -1 if it
* is not possible to determine the length.
*/
public long getContentLength() {
this.getInfos();
return this.contentLength;
}
/**
* Return an <code>InputStream</code> object to read from the source.
*/
public InputStream getInputStream()
throws IOException {
if (this.isFile == true) {
return new
FileInputStream(this.systemId.substring(FILE.length()));
} else {
if (this.connection == null) {
this.connection = this.url.openConnection();
}
return this.connection.getInputStream();
}
}
/**
* Return the unique identifer for this source
*/
public String getSystemId() {
return this.systemId;
}
/**
* Is this a file, then the <code>getFile</code> method can
* return a <code>File</code> object for this source.
*/
public boolean isFile() {
return this.isFile;
}
/**
* Return a <code>File</code> object if this is a local file
* (if the <code>isFile</code> method returns true).
*/
public File getFile() {
if (this.isFile == true) {
return new File(this.systemId.substring(FILE.length()));
}
return null;
}
/**
* Refresh this object and update the last modified date
* and content length.
*/
public void refresh() {
// reset connection
this.connection = null;
this.gotInfos = false;
}
/**
* Return a new <code>InputSource</code> object
*/
public InputSource getInputSource()
throws IOException {
InputSource newObject = new InputSource(this.getInputStream());
newObject.setSystemId(this.systemId);
return newObject;
}
/**
* Stream content to the consumer
*/
public void stream(XMLConsumer consumer)
throws ProcessingException, SAXException, IOException {
Parser parser = null;
try {
parser = (Parser)this.manager.lookup(Roles.PARSER);
parser.setConsumer(consumer);
parser.parse(this.getInputSource());
} catch (ComponentException e){
throw new ProcessingException("Exception in URLSource.stream()",
e);
} finally {
if (parser != null) this.manager.release(parser);
}
}
}
1.14 +2 -10
xml-cocoon2/src/org/apache/cocoon/generation/FileGenerator.java
Index: FileGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/generation/FileGenerator.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FileGenerator.java 2001/06/19 07:41:53 1.13
+++ FileGenerator.java 2001/06/28 09:56:42 1.14
@@ -39,7 +39,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
* (Apache Software Foundation, Exoffice Technologies)
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.13 $ $Date: 2001/06/19 07:41:53 $
+ * @version CVS $Revision: 1.14 $ $Date: 2001/06/28 09:56:42 $
*/
public class FileGenerator extends ComposerGenerator
implements Cacheable, Recyclable {
@@ -105,15 +105,12 @@
*/
public void generate()
throws IOException, SAXException, ProcessingException {
- Parser parser = null;
try {
getLogger().debug("processing file " + super.source);
getLogger().debug("file resolved to " +
this.inputSource.getSystemId());
- parser = (Parser)this.manager.lookup(Roles.PARSER);
+ this.inputSource.stream(super.xmlConsumer);
- parser.setConsumer(super.xmlConsumer);
- parser.parse(this.inputSource.getInputSource());
} catch (FileNotFoundException e) {
getLogger().warn("FileGenerator could not find resource " +
this.inputSource.getSystemId(), e);
throw new ResourceNotFoundException("FileGenerator could not
find resource "
@@ -124,11 +121,6 @@
} catch (SAXException e) {
getLogger().error("FileGenerator.generate()", e);
throw(e);
- } catch (Exception e){
- getLogger().error("Could not get parser", e);
- throw new ProcessingException("Exception in
FileGenerator.generate()",e);
- } finally {
- if (parser != null) this.manager.release(parser);
}
}
}
1.11 +8 -1
xml-cocoon2/src/org/apache/cocoon/sitemap/AbstractSitemap.java
Index: AbstractSitemap.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/AbstractSitemap.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AbstractSitemap.java 2001/06/22 14:45:58 1.10
+++ AbstractSitemap.java 2001/06/28 09:56:44 1.11
@@ -43,7 +43,7 @@
* Base class for generated <code>Sitemap</code> classes
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.10 $ $Date: 2001/06/22 14:45:58 $
+ * @version CVS $Revision: 1.11 $ $Date: 2001/06/28 09:56:44 $
*/
public abstract class AbstractSitemap extends AbstractLoggable implements
Sitemap, Disposable, ThreadSafe {
private Context context;
@@ -155,6 +155,13 @@
public void contextualize(Context context) throws ContextException {
this.context = context;
+ }
+
+ /**
+ * Return the component manager for this sitemap
+ */
+ public ComponentManager getComponentManager() {
+ return this.manager;
}
/**
1.9 +28 -99
xml-cocoon2/src/org/apache/cocoon/sitemap/ContentAggregator.java
Index: ContentAggregator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/ContentAggregator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ContentAggregator.java 2001/06/22 02:24:30 1.8
+++ ContentAggregator.java 2001/06/28 09:56:45 1.9
@@ -23,10 +23,9 @@
import org.apache.cocoon.caching.AggregatedCacheValidity;
import org.apache.cocoon.caching.Cacheable;
import org.apache.cocoon.caching.PipelineCacheKey;
-import org.apache.cocoon.components.pipeline.EventPipeline;
-import org.apache.cocoon.components.pipeline.CacheableEventPipeline;
-import org.apache.cocoon.components.pipeline.StreamPipeline;
+import org.apache.cocoon.caching.TimeStampCacheValidity;
import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.generation.Generator;
import org.apache.cocoon.sitemap.Sitemap;
@@ -42,11 +41,10 @@
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Id: ContentAggregator.java,v 1.8 2001/06/22 02:24:30
vgritsenko Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
+ * @version CVS $Id: ContentAggregator.java,v 1.9 2001/06/28 09:56:45
cziegeler Exp $
*/
public class ContentAggregator extends ContentHandlerWrapper implements
Generator, Cacheable, Composable {
- /** the current sitemap */
- protected Sitemap sitemap;
/** the root element of the aggregated content */
protected String rootElement;
@@ -60,9 +58,6 @@
/** the parts */
protected ArrayList parts = new ArrayList();
- /** The current <code>Environment</code>. */
- protected Environment environment;
-
/** The current <code>SourceResolver</code>. */
protected SourceResolver resolver;
@@ -87,9 +82,6 @@
/** The <code>ComponentManager</code> */
protected ComponentManager manager;
- /** Holds all collected <code>EventPipeline</code>s */
- private ArrayList partEventPipelines = new ArrayList();
-
/** Stacks namespaces during processing */
private ArrayList currentNS = new ArrayList();
@@ -117,10 +109,11 @@
public String element;
public String namespace;
public String prefix;
+ public Source source;
boolean stripRootElement;
public Part(String uri, String element, String namespace, String
stripRoot, String prefix) {
- this.uri = uri;
+ this.uri = "cocoon://" + uri;
this.element = element;
this.namespace = namespace;
this.prefix = prefix;
@@ -137,11 +130,10 @@
*/
public void generate() throws IOException, SAXException,
ProcessingException {
getLogger().debug("ContentAggregator: generating aggregated
content");
- collectParts();
this.documentHandler.startDocument();
this.startElem(this.rootElementNS, this.rootElementNSPrefix,
this.rootElement);
try {
- for (int i = 0; i < this.partEventPipelines.size(); i++) {
+ for (int i = 0; i < this.parts.size(); i++) {
Part part = (Part)this.parts.get(i);
this.rootElementIndex = (part.stripRootElement ? 0 : -1);
String ns = part.namespace;
@@ -153,19 +145,10 @@
if (!part.element.equals("")) {
this.startElem(ns, prefix, part.element);
}
- EventPipeline ep =
(EventPipeline)this.partEventPipelines.get(i);
- ((XMLProducer)ep).setConsumer(this);
+
try {
- this.environment.pushURI(part.uri);
- ep.process(this.environment);
- } catch (ProcessingException e) {
- // Already reported to log, rethrowing.
- throw e;
- } catch (Exception e) {
- getLogger().error("ContentAggregator: cannot process
event pipeline for URI " + part.uri, e);
- throw new ProcessingException("ContentAggregator: cannot
process event pipeline for URI " + part.uri, e);
+ this.resolver.resolve(part.uri).stream(this);
} finally {
- this.environment.popURI();
if (!part.element.equals("")) {
this.endElem(prefix, part.element);
}
@@ -178,41 +161,6 @@
getLogger().debug("ContentAggregator: finished aggregating content");
}
- private void collectParts() throws ProcessingException {
- if (this.partEventPipelines.size() == 0) {
- EventPipeline eventPipeline = null;
- StreamPipeline pipeline = null;
- for (int i = 0; i < this.parts.size(); i++) {
- Part part = (Part)this.parts.get(i);
- getLogger().debug("ContentAggregator: collecting internal
resource " + part.uri);
- try {
- eventPipeline =
(EventPipeline)this.manager.lookup(Roles.EVENT_PIPELINE);
- this.partEventPipelines.add(eventPipeline);
- pipeline =
(StreamPipeline)this.manager.lookup(Roles.STREAM_PIPELINE);
- } catch (ComponentException cme) {
- getLogger().error("ContentAggregator: could not lookup
pipeline components", cme);
- throw new ProcessingException("could not lookup pipeline
components", cme);
- }
- try {
- pipeline.setEventPipeline(eventPipeline);
- } catch (Exception cme) {
- getLogger().error("ContentAggregator: could not set
event pipeline on stream pipeline", cme);
- throw new ProcessingException("could not set event
pipeline on stream pipeline", cme);
- }
- try {
- this.environment.pushURI(part.uri);
- this.sitemap.process(this.environment, pipeline,
eventPipeline);
- } catch (Exception cme) {
- getLogger().error("ContentAggregator: could not process
pipeline", cme);
- throw new ProcessingException("could not process
pipeline", cme);
- } finally {
- this.manager.release(pipeline);
- this.environment.popURI();
- }
- }
- }
- }
-
/**
* Generate the unique key.
* This key must be unique inside the space of this component.
@@ -221,22 +169,16 @@
*/
public long generateKey() {
try {
- collectParts();
long key = 0;
- for (int i = 0; i < this.partEventPipelines.size(); i++) {
- EventPipeline ep =
(EventPipeline)this.partEventPipelines.get(i);
- if (ep instanceof CacheableEventPipeline) {
- ((XMLProducer)ep).setConsumer(this);
- PipelineCacheKey pck =
((CacheableEventPipeline)ep).generateKey(environment);
- if (pck == null) {
+ Source current;
+ for (int i = 0; i < this.parts.size(); i++) {
+ current = ((Part)this.parts.get(i)).source;
+ if (current.getLastModified() == 0) {
return 0;
} else {
- key += HashUtil.hash(pck.toString());
+ key += HashUtil.hash(current.getSystemId());
}
- } else {
- return 0;
}
- }
return key;
} catch (Exception e) {
getLogger().error("ContentAggregator: could not generateKey", e);
@@ -252,37 +194,27 @@
*/
public CacheValidity generateValidity() {
try {
- collectParts();
- final AggregatedCacheValidity v = new AggregatedCacheValidity();
+ AggregatedCacheValidity v = new AggregatedCacheValidity();
+ Source current;
for (int i = 0; i < this.parts.size(); i++) {
- EventPipeline ep =
(EventPipeline)this.partEventPipelines.get(i);
- if (ep instanceof CacheableEventPipeline) {
- Map map =
((CacheableEventPipeline)ep).generateValidity(environment);
- if (map == null) {
+ current = ((Part)this.parts.get(i)).source;
+ if (current.getLastModified() == 0) {
return null;
- }
- Iterator j = map.values().iterator();
- while (j.hasNext()) {
- CacheValidity epv = (CacheValidity)j.next();
- v.add(epv);
- }
} else {
- return null;
+ v.add(new
TimeStampCacheValidity(current.getLastModified()));
}
}
return v;
} catch (Exception e) {
- getLogger().error("ContentAggregator: could not
generateValidity", e);
+ getLogger().error("ContentAggregator: could not generateKey", e);
return null;
}
}
public void setEnvironment(Environment environment) {
- this.environment = environment;
}
public void setSitemap(Sitemap sitemap) {
- this.sitemap = sitemap;
}
public void setRootElement(String element, String namespace, String
prefix) {
@@ -330,7 +262,6 @@
*/
public void recycle() {
super.recycle();
- this.sitemap = null;
this.resolver = null;
this.objectModel = null;
this.source = null;
@@ -339,14 +270,6 @@
this.rootElementNS = null;
this.rootElementNSPrefix = null;
this.parts.clear();
- this.environment = null;
-
- for (int i = 0; i < this.partEventPipelines.size(); i++) {
- Component component = (Component)this.partEventPipelines.get(i);
- this.manager.release(component);
- }
-
- this.partEventPipelines.clear();
this.currentNS.clear();
this.xmlConsumer = null;
this.contentHandler = null;
@@ -357,12 +280,18 @@
* Set the <code>SourceResolver</code>, object model <code>Map</code>,
* the source and sitemap <code>Parameters</code> used to process the
request.
*/
- public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par) throws ProcessingException,
- SAXException, IOException {
+ public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par)
+ throws ProcessingException, SAXException, IOException {
this.resolver = resolver;
this.objectModel = objectModel;
this.source = src;
this.parameters = par;
+
+ Part current;
+ for(int i=0; i<this.parts.size();i++) {
+ current = (Part)this.parts.get(i);
+ current.source = this.resolver.resolve(current.uri);
+ }
}
private String pushNS(String ns) {
1.11 +12 -9 xml-cocoon2/src/org/apache/cocoon/sitemap/Handler.java
Index: Handler.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/Handler.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Handler.java 2001/06/08 20:28:25 1.10
+++ Handler.java 2001/06/28 09:56:45 1.11
@@ -28,10 +28,10 @@
import org.apache.cocoon.components.pipeline.EventPipeline;
import org.apache.cocoon.components.pipeline.StreamPipeline;
import org.apache.cocoon.components.url.URLFactory;
-import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.FactoryURLResolver;
-import org.apache.cocoon.environment.URLResolver;
+import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.Source;
+import org.apache.cocoon.environment.URLResolver;
/**
* Handles the manageing and stating of one <code>Sitemap</code>
@@ -39,7 +39,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.10 $ $Date: 2001/06/08 20:28:25 $
+ * @version CVS $Revision: 1.11 $ $Date: 2001/06/28 09:56:45 $
*/
public class Handler extends AbstractLoggable implements Runnable,
Configurable, Composable,
Contextualizable, Processor, Disposable {
@@ -58,9 +58,6 @@
/** the URLFactory */
private URLFactory urlFactory;
- /** The URLResolver for the sitemap components */
- private URLResolver urlResolver;
-
/** the last error */
private Exception exception;
@@ -76,11 +73,13 @@
/** the sitemaps base path */
private String basePath;
+ /** The URLResolver for the sitemap components */
+ private URLResolver urlResolver;
+
public void compose(ComponentManager manager) {
this.manager = manager;
try {
urlFactory = (URLFactory)manager.lookup(Roles.URL_FACTORY);
- this.urlResolver = new FactoryURLResolver(urlFactory);
} catch (Exception e) {
getLogger().error("cannot obtain URLFactory", e);
}
@@ -123,7 +122,7 @@
this.sourceFileName = this.sourceFileName + "sitemap.xmap";
}
try {
- environment.setURLResolver(this.urlResolver);
+ environment.setURLResolver(new
FactoryURLResolver(this.manager, this.urlFactory));
this.source = environment.resolve(this.sourceFileName);
} finally {
environment.setURLResolver(null);
@@ -210,7 +209,7 @@
XSLTFactoryLoader.setLogger(getLogger());
programGenerator =
(ProgramGenerator)this.manager.lookup(Roles.PROGRAM_GENERATOR);
try {
- environment.setURLResolver(this.urlResolver);
+ environment.setURLResolver(new
FactoryURLResolver(this.manager, this.urlFactory));
smap = (Sitemap)programGenerator.load(this.manager,
this.sourceFileName, markupLanguage,
programmingLanguage, environment);
} finally {
@@ -220,6 +219,10 @@
programGenerator.release((CompiledComponent)this.sitemap);
}
this.sitemap = smap;
+ // create the urlResolver
+ this.urlResolver = new
SitemapURLResolver(this.sitemap.getComponentManager(),
+ this.urlFactory,
+ this.sitemap);
getLogger().debug("Sitemap regeneration complete");
if (this.sitemap != null) {
getLogger().debug("The sitemap has been successfully
compiled!");
1.3 +6 -1 xml-cocoon2/src/org/apache/cocoon/sitemap/Sitemap.java
Index: Sitemap.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/Sitemap.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Sitemap.java 2001/06/08 20:28:26 1.2
+++ Sitemap.java 2001/06/28 09:56:46 1.3
@@ -21,7 +21,7 @@
* Base interface for generated <code>Sitemap</code> classes
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.2 $ $Date: 2001/06/08 20:28:26 $
+ * @version CVS $Revision: 1.3 $ $Date: 2001/06/28 09:56:46 $
*/
public interface Sitemap extends CompiledComponent, Configurable,
Contextualizable, Processor {
int GENERATOR = 1;
@@ -31,6 +31,11 @@
int ACTION = READER << 1;
int MATCHER = ACTION << 1;
int SELECTOR = MATCHER << 1;
+
+ /**
+ * Return the component manager for this sitemap
+ */
+ ComponentManager getComponentManager();
/**
* Process the given <code>Environment</code>
1.1
xml-cocoon2/src/org/apache/cocoon/sitemap/SitemapSource.java
Index: SitemapSource.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.cocoon.sitemap;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.Roles;
import org.apache.cocoon.components.parser.Parser;
import org.apache.cocoon.components.pipeline.EventPipeline;
import org.apache.cocoon.components.pipeline.StreamPipeline;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.serialization.Serializer;
import org.apache.cocoon.xml.XMLConsumer;
import org.apache.cocoon.xml.XMLProducer;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* Description of a source which is described by a pipeline.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/06/28 09:56:46 $
*/
public final class SitemapSource
implements Source {
/** The cocoon protocol */
private String COCOON_PROTOCOL = "cocoon://";
/** The last modification date or 0 */
private long lastModificationDate;
/** The content length */
private long contentLength;
/** The system id */
private String systemId;
/** The current ComponentManager */
private ComponentManager manager;
/** The sitemap */
private Sitemap sitemap;
/** The environment */
private Environment environment;
/**
* Construct a new object
*/
public SitemapSource(Environment env,
ComponentManager manager,
Sitemap sitemap,
String url)
throws IOException, ProcessingException {
// FIXME (CZ) We should change the systemId from cocoon:
// to http://server/context/...
this.systemId = url;
this.contentLength = -1;
this.lastModificationDate = 0;
this.manager = manager;
this.sitemap = sitemap;
this.environment = env;
}
/**
* Get the last modification date of the source or 0 if it
* is not possible to determine the date.
*/
public long getLastModified() {
return this.lastModificationDate;
}
/**
* Get the content length of the source or -1 if it
* is not possible to determine the length.
*/
public long getContentLength() {
return this.contentLength;
}
/**
* Return an <code>InputStream</code> object to read from the source.
*/
public InputStream getInputStream()
throws ProcessingException, IOException {
EventPipeline eventPipeline = null;
StreamPipeline pipeline = null;
SitemapComponentSelector serializerSelector = null;
Serializer serializer = null;
try {
eventPipeline =
(EventPipeline)this.manager.lookup(Roles.EVENT_PIPELINE);
pipeline =
(StreamPipeline)this.manager.lookup(Roles.STREAM_PIPELINE);
serializerSelector = (SitemapComponentSelector)
this.manager.lookup(Roles.SERIALIZERS);
serializer = (Serializer)serializerSelector.select("xml");
ByteArrayOutputStream os = new ByteArrayOutputStream();
serializer.setOutputStream(os);
pipeline.setEventPipeline(eventPipeline);
try {
this.environment.pushURI(this.systemId.substring(COCOON_PROTOCOL.length()));
this.sitemap.process(this.environment, pipeline,
eventPipeline);
((XMLProducer)eventPipeline).setConsumer(serializer);
eventPipeline.process(this.environment);
} finally {
this.environment.popURI();
}
return new ByteArrayInputStream(os.toByteArray());
} catch (ComponentException cme) {
throw new ProcessingException("could not lookup pipeline
components", cme);
} catch (Exception e) {
throw new ProcessingException("Exception during processing of
"+this.systemId, e);
} finally {
if (serializer != null) {
serializerSelector.release(serializer);
}
if (serializerSelector != null)
this.manager.release(serializerSelector);
if (eventPipeline != null) this.manager.release(eventPipeline);
if (pipeline != null) this.manager.release(pipeline);
}
}
/**
* Return the unique identifer for this source
*/
public String getSystemId() {
return this.systemId;
}
/**
* Is this a file, then the <code>getFile</code> method can
* return a <code>File</code> object for this source.
*/
public boolean isFile() {
return false;
}
/**
* Return a <code>File</code> object if this is a local file
* (if the <code>isFile</code> method returns true).
*/
public File getFile() {
return null;
}
/**
* Refresh this object and update the last modified date
* and content length.
*/
public void refresh() {
// nothing to do here
}
/**
* Return a new <code>InputSource</code> object
*/
public InputSource getInputSource()
throws ProcessingException, IOException {
InputSource newObject = new InputSource(this.getInputStream());
newObject.setSystemId(this.systemId);
return newObject;
}
/**
* Stream content to the consumer
*/
public void stream(XMLConsumer consumer)
throws ProcessingException, SAXException, IOException {
EventPipeline eventPipeline = null;
StreamPipeline pipeline = null;
try {
eventPipeline =
(EventPipeline)this.manager.lookup(Roles.EVENT_PIPELINE);
pipeline =
(StreamPipeline)this.manager.lookup(Roles.STREAM_PIPELINE);
pipeline.setEventPipeline(eventPipeline);
try {
this.environment.pushURI(this.systemId.substring(COCOON_PROTOCOL.length()));
this.sitemap.process(this.environment, pipeline,
eventPipeline);
((XMLProducer)eventPipeline).setConsumer(consumer);
eventPipeline.process(this.environment);
} finally {
this.environment.popURI();
}
} catch (ComponentException cme) {
throw new ProcessingException("could not lookup pipeline
components", cme);
} catch (Exception e) {
throw new ProcessingException("Exception during processing of
"+this.systemId, e);
} finally {
if (eventPipeline != null) this.manager.release(eventPipeline);
if (pipeline != null) this.manager.release(pipeline);
}
}
}
1.1
xml-cocoon2/src/org/apache/cocoon/sitemap/SitemapURLResolver.java
Index: SitemapURLResolver.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.cocoon.sitemap;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.url.URLFactory;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.URLResolver;
import org.apache.cocoon.environment.URLSource;
/**
* This interface describes the URLResolver which is used by the
* <code>SourceResolver</code>.
* The <code>URLResolver</code> separates the <code>SourceResolver</code>
* from the <code>URLFactory</code>.
*
* This class used only the <code>URLFactory</code>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/06/28 09:56:47 $
*/
public final class SitemapURLResolver
implements URLResolver {
private URLFactory factory;
private Sitemap sitemap;
private ComponentManager manager;
public SitemapURLResolver(ComponentManager manager,
URLFactory factory,
Sitemap sitemap) {
this.factory = factory;
this.sitemap = sitemap;
this.manager = manager;
}
/**
* Resolve the source
*/
public Source getSource(Environment environment, String location)
throws ProcessingException, IOException, MalformedURLException {
if (location.startsWith("cocoon://") == true) {
return new SitemapSource(environment,
this.manager,
this.sitemap,
location);
} else {
return new URLSource(this.factory.getURL(location), this.manager);
}
}
/**
* Resolve the source
*/
public Source getSource(Environment environment, URL base, String
location)
throws ProcessingException, IOException, MalformedURLException {
return this.getSource(environment, base.toExternalForm() + location);
}
}
1.11 +1 -1
xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer.java
Index: I18nTransformer.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- I18nTransformer.java 2001/06/19 07:41:56 1.10
+++ I18nTransformer.java 2001/06/28 09:56:49 1.11
@@ -855,7 +855,7 @@
*Loads translations from given URL
*/
private void initialiseDictionary(Source inputSource)
- throws SAXException, MalformedURLException, IOException {
+ throws ProcessingException, SAXException, MalformedURLException,
IOException {
Parser parser = null;
1.19 +3 -1
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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- TraxTransformer.java 2001/06/22 02:13:31 1.18
+++ TraxTransformer.java 2001/06/28 09:56:50 1.19
@@ -100,7 +100,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Id: TraxTransformer.java,v 1.18 2001/06/22 02:13:31
vgritsenko Exp $
+ * @version CVS $Id: TraxTransformer.java,v 1.19 2001/06/28 09:56:50
cziegeler Exp $
*/
public class TraxTransformer extends ContentHandlerWrapper
implements Transformer, Composable, Recyclable, Configurable, Cacheable,
Disposable, URIResolver {
@@ -279,6 +279,8 @@
throw new javax.xml.transform.TransformerException(e);
} catch (SAXException e) {
throw new javax.xml.transform.TransformerException(e);
+ } catch (ProcessingException e) {
+ throw new javax.xml.transform.TransformerException(e);
}
}
/**
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]