cziegeler 01/07/10 01:17:09
Modified: . Tag: cocoon_20_branch changes.xml todo.xml
src/org/apache/cocoon/components/source Tag:
cocoon_20_branch SitemapSource.java
src/org/apache/cocoon/environment Tag: cocoon_20_branch
AbstractEnvironment.java Environment.java
Log:
Finished the cocoon:// protocol
Revision Changes Path
No revision
No revision
1.2.2.17 +3 -2 xml-cocoon2/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/changes.xml,v
retrieving revision 1.2.2.16
retrieving revision 1.2.2.17
diff -u -r1.2.2.16 -r1.2.2.17
--- changes.xml 2001/07/09 08:55:10 1.2.2.16
+++ changes.xml 2001/07/10 08:16:43 1.2.2.17
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.2.2.16 2001/07/09 08:55:10 cziegeler Exp $
+ $Id: changes.xml,v 1.2.2.17 2001/07/10 08:16:43 cziegeler Exp $
-->
<changes title="History of Changes">
@@ -38,7 +38,8 @@
and source factory components.
</action>
<action dev="CZ" type="add">
- Added the cocoon: protocol to access pipelines.
+ Added the cocoon: protocol to access pipelines. cocoon:/ resolves
+ to the current sitemap and cocoon:// to the root sitemap.
</action>
<action dev="VG" type="fix">
Offline site generation now allows recursive links and
1.1.1.1.2.4 +1 -5 xml-cocoon2/todo.xml
Index: todo.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/todo.xml,v
retrieving revision 1.1.1.1.2.3
retrieving revision 1.1.1.1.2.4
diff -u -r1.1.1.1.2.3 -r1.1.1.1.2.4
--- todo.xml 2001/07/09 08:55:12 1.1.1.1.2.3
+++ todo.xml 2001/07/10 08:16:46 1.1.1.1.2.4
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: todo.xml,v 1.1.1.1.2.3 2001/07/09 08:55:12 cziegeler Exp $
+ $Id: todo.xml,v 1.1.1.1.2.4 2001/07/10 08:16:46 cziegeler Exp $
-->
@@ -34,10 +34,6 @@
the servlet. A reloading of the Cocoon is not sufficient. This is not
very convenient. Suggestion: When Cocoon is reloaded (a new cocoon instance
is created then) the classpath is rebuild and used.
- </action>
-
- <action context="code" assigned-to="open">
- Make the cocoon:/ protocol work which should resolve to the root sitemap.
</action>
<action context="code" assigned-to="open">
No revision
No revision
1.1.2.7 +10 -7
xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java
Index: SitemapSource.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/source/SitemapSource.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- SitemapSource.java 2001/07/09 13:22:26 1.1.2.6
+++ SitemapSource.java 2001/07/10 08:16:55 1.1.2.7
@@ -43,7 +43,7 @@
* Description of a source which is defined by a pipeline.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/07/09 13:22:26 $
+ * @version CVS $Revision: 1.1.2.7 $ $Date: 2001/07/10 08:16:55 $
*/
public final class SitemapSource
@@ -70,6 +70,9 @@
/** The environment */
private Environment environment;
+ /** The prefix for the processing */
+ private String prefix;
+
/**
* Construct a new object
*/
@@ -91,16 +94,16 @@
// does the uri point to this sitemap or to the root sitemap?
if (uri.startsWith("//") == true) {
uri = uri.substring(2);
- // FIXME (CZ) The root sitemap is not available
- // so resolve it to the current sitemap
Processor processor = null;
try {
processor = (Processor)this.manager.lookup(Processor.ROLE);
} catch (ComponentException e) {
throw new ProcessingException("Cannot get Processor instance", e);
}
+ this.prefix = ""; // start at the root
this.processor = processor;
} else if (uri.startsWith("/") == true) {
+ this.prefix = null;
uri = uri.substring(1);
this.processor = sitemap;
}
@@ -152,13 +155,13 @@
pipeline.setEventPipeline(eventPipeline);
try {
- this.environment.pushURI(this.uri);
+ this.environment.pushURI(this.prefix, this.uri);
this.processor.process(this.environment, pipeline, eventPipeline);
} finally {
this.environment.popURI();
}
try {
- this.environment.pushURI(this.uri);
+ this.environment.pushURI(this.prefix, this.uri);
((XMLProducer)eventPipeline).setConsumer(serializer);
eventPipeline.process(this.environment);
} finally {
@@ -236,13 +239,13 @@
pipeline.setEventPipeline(eventPipeline);
try {
- this.environment.pushURI(this.uri);
+ this.environment.pushURI(this.prefix, this.uri);
this.processor.process(this.environment, pipeline, eventPipeline);
} finally {
this.environment.popURI();
}
try {
- this.environment.pushURI(this.uri);
+ this.environment.pushURI(this.prefix, this.uri);
((XMLProducer)eventPipeline).setConsumer(consumer);
eventPipeline.process(this.environment);
} finally {
No revision
No revision
1.6.2.4 +42 -10
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.2.3
retrieving revision 1.6.2.4
diff -u -r1.6.2.3 -r1.6.2.4
--- AbstractEnvironment.java 2001/07/04 13:59:36 1.6.2.3
+++ AbstractEnvironment.java 2001/07/10 08:17:02 1.6.2.4
@@ -20,6 +20,13 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+/**
+ * Base class for any environment
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
+ * @version CVS $Revision: 1.6.2.4 $ $Date: 2001/07/10 08:17:02 $
+ */
public abstract class AbstractEnvironment extends AbstractLoggable implements
Environment {
/** The current uri in progress */
@@ -37,6 +44,9 @@
/** The Context path */
protected URL context = null;
+ /** The root context path */
+ protected URL rootContext = null;
+
/** The servlet object model */
protected HashMap objectModel = null;
@@ -80,11 +90,12 @@
*/
public AbstractEnvironment(String uri, String view, URL context, String action)
throws MalformedURLException {
- this.pushURI(uri);
+ this.pushURI(null, uri);
this.view = view;
this.context = context;
this.action = action;
this.objectModel = new HashMap();
+ this.rootContext = context;
}
/**
@@ -208,23 +219,39 @@
*/
public Source resolve(String systemId)
throws ProcessingException, SAXException, IOException {
+ this.getLogger().debug("Resolving '"+systemId+"'");
if (systemId == null) throw new SAXException("Invalid System ID");
- if (systemId.length() == 0)
- return this.sourceHandler.getSource(this,
this.context.toExternalForm());
- if (systemId.indexOf(":") > 1)
- return this.sourceHandler.getSource(this, systemId);
- if (systemId.charAt(0) == '/')
- return this.sourceHandler.getSource(this, this.context.getProtocol() +
":" + systemId);
- return this.sourceHandler.getSource(this, this.context, systemId);
+ Source source;
+ if (systemId.length() == 0) {
+ source = this.sourceHandler.getSource(this,
this.context.toExternalForm());
+ } else if (systemId.indexOf(":") > 1) {
+ source = this.sourceHandler.getSource(this, systemId);
+ } else if (systemId.charAt(0) == '/') {
+ source = this.sourceHandler.getSource(this, this.context.getProtocol()
+ ":" + systemId);
+ } else {
+ source = this.sourceHandler.getSource(this, this.context, systemId);
+ }
+ this.getLogger().debug("Resolved to '"+source.getSystemId()+"'");
+ return source;
}
/**
- * Push a new URI for processing
+ * Push a new URI for processing. If the prefix is null the
+ * new URI is inside the current context.
+ * If the prefix is not null the context is changed to the root
+ * context and the prefix is set.
*/
- public void pushURI(String uri) {
+ public void pushURI(String prefix, String uri) {
+ this.getLogger().debug("Push uri '"+uri+"' with prefix '"+prefix+"'");
this.uris.add(this.sourceHandler);
+ this.uris.add(this.prefix);
+ this.uris.add(this.context);
this.uris.add(uri);
+ if (prefix != null) {
+ this.context = this.rootContext;
+ this.prefix = new StringBuffer(prefix);
+ }
}
/**
@@ -232,6 +259,11 @@
*/
public String popURI() {
String uri = (String)this.uris.get(this.uris.size()-1);
+ this.getLogger().debug("Pop uri '"+uri+"'");
+ this.uris.remove(this.uris.size()-1);
+ this.context = (URL)this.uris.get(this.uris.size()-1);
+ this.uris.remove(this.uris.size()-1);
+ this.prefix = (StringBuffer)this.uris.get(this.uris.size()-1);
this.uris.remove(this.uris.size()-1);
this.sourceHandler = (SourceHandler)this.uris.get(this.uris.size()-1);
this.uris.remove(this.uris.size()-1);
1.2.2.3 +7 -3 xml-cocoon2/src/org/apache/cocoon/environment/Environment.java
Index: Environment.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/Environment.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- Environment.java 2001/07/04 13:59:37 1.2.2.2
+++ Environment.java 2001/07/10 08:17:04 1.2.2.3
@@ -19,7 +19,8 @@
* Base interface for an environment abstraction
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.2.2.2 $ $Date: 2001/07/04 13:59:37 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
+ * @version CVS $Revision: 1.2.2.3 $ $Date: 2001/07/10 08:17:04 $
*/
public interface Environment extends SourceResolver {
@@ -85,9 +86,12 @@
Map getObjectModel();
/**
- * Push a new URI for processing
+ * Push a new URI for processing. If the prefix is null the
+ * new URI is inside the current context.
+ * If the prefix is not null the context is changed to the root
+ * context and the prefix is set.
*/
- void pushURI(String uri);
+ void pushURI(String prefix, String uri);
/**
* Pop last pushed URI
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]