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 2003/10/24 14:49:40 UTC
cvs commit: cocoon-2.2/src/java/org/apache/cocoon/components/source CocoonSourceResolver.java
cziegeler 2003/10/24 05:49:40
Modified: src/java/org/apache/cocoon/bean OldCocoonBean.java
src/java/org/apache/cocoon/bean/helpers
BeanConfigurator.java
src/java/org/apache/cocoon/environment
EnvironmentHelper.java EnvironmentStack.java
src/java/org/apache/cocoon/components/source
CocoonSourceResolver.java
Log:
Moving away from ugly Object[] arrays
Removing verbose from the Bean
Revision Changes Path
1.4 +1 -6 cocoon-2.2/src/java/org/apache/cocoon/bean/OldCocoonBean.java
Index: OldCocoonBean.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/OldCocoonBean.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- OldCocoonBean.java 24 Oct 2003 12:31:53 -0000 1.3
+++ OldCocoonBean.java 24 Oct 2003 12:49:40 -0000 1.4
@@ -102,7 +102,6 @@
private boolean followLinks = true;
private boolean precompileOnly = false;
private boolean confirmExtension = true;
- private boolean verbose = false;
private String defaultFilename = Constants.INDEX_URI;
private boolean brokenLinkGenerate = false;
private String brokenLinkExtension = "";
@@ -174,10 +173,6 @@
this.brokenLinkGenerate = brokenLinkGenerate;
}
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
public void setBrokenLinkExtension(String brokenLinkExtension) {
this.brokenLinkExtension = brokenLinkExtension;
}
1.4 +1 -5 cocoon-2.2/src/java/org/apache/cocoon/bean/helpers/BeanConfigurator.java
Index: BeanConfigurator.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/helpers/BeanConfigurator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BeanConfigurator.java 17 Oct 2003 17:49:23 -0000 1.3
+++ BeanConfigurator.java 24 Oct 2003 12:49:40 -0000 1.4
@@ -72,7 +72,6 @@
public class BeanConfigurator {
private static final String NODE_ROOT = "cocoon";
- private static final String ATTR_VERBOSE = "verbose";
private static final String NODE_LOGGING = "logging";
private static final String ATTR_LOG_KIT = "log-kit";
@@ -133,9 +132,6 @@
throw new IllegalArgumentException("Expected root node of "+ NODE_ROOT);
}
- if (hasAttribute(root, ATTR_VERBOSE)) {
- cocoon.setVerbose(getBooleanAttributeValue(root, ATTR_VERBOSE));
- }
if (hasAttribute(root, ATTR_FOLLOW_LINKS)) {
cocoon.setFollowLinks(getBooleanAttributeValue(root, ATTR_FOLLOW_LINKS));
}
1.4 +20 -7 cocoon-2.2/src/java/org/apache/cocoon/environment/EnvironmentHelper.java
Index: EnvironmentHelper.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/EnvironmentHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EnvironmentHelper.java 20 Oct 2003 08:15:27 -0000 1.3
+++ EnvironmentHelper.java 24 Oct 2003 12:49:40 -0000 1.4
@@ -118,8 +118,9 @@
source = this.resolver.resolveURI(this.context);
this.context = source.getURI();
- if (this.rootContext == null) // hack for EnvironmentWrapper
+ if (this.rootContext == null) {// hack for EnvironmentWrapper
this.rootContext = this.context;
+ }
} catch (IOException ioe) {
throw new ServiceException("Unable to resolve environment context. ", ioe);
} finally {
@@ -273,7 +274,7 @@
stack = new EnvironmentStack();
environmentStack.set(stack);
}
- stack.push(new Object[] {processor, new Integer(stack.getOffset())});
+ stack.push(new EnvironmentInfo(processor, stack.getOffset()));
stack.setOffset(stack.size()-1);
}
@@ -283,18 +284,30 @@
*/
public static void leaveProcessor() {
final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
- final Object[] objs = (Object[])stack.pop();
- stack.setOffset(((Integer)objs[1]).intValue());
+ final EnvironmentInfo info = (EnvironmentInfo)stack.pop();
+ stack.setOffset(info.oldStackCount);
}
/**
+ * Return the current processor
+ */
+ public static Processor getCurrentProcessor() {
+ final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
+ if ( stack != null && !stack.isEmpty()) {
+ final EnvironmentInfo info = stack.getCurrent();
+ return info.processor;
+ }
+ return null;
+ }
+
+ /**
* Create an environment aware xml consumer for the cocoon
* protocol
*/
public static XMLConsumer createEnvironmentAwareConsumer(XMLConsumer consumer) {
final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
- final Object[] objs = (Object[])stack.getCurrent();
- return stack.getEnvironmentAwareConsumerWrapper(consumer, ((Integer)objs[1]).intValue());
+ final EnvironmentInfo info = stack.getCurrent();
+ return stack.getEnvironmentAwareConsumerWrapper(consumer, info.oldStackCount);
}
}
1.2 +15 -4 cocoon-2.2/src/java/org/apache/cocoon/environment/EnvironmentStack.java
Index: EnvironmentStack.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/EnvironmentStack.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EnvironmentStack.java 20 Oct 2003 08:15:27 -0000 1.1
+++ EnvironmentStack.java 24 Oct 2003 12:49:40 -0000 1.2
@@ -50,6 +50,7 @@
*/
package org.apache.cocoon.environment;
+import org.apache.cocoon.Processor;
import org.apache.cocoon.xml.XMLConsumer;
import org.apache.commons.collections.ArrayStack;
import org.xml.sax.Attributes;
@@ -70,9 +71,8 @@
int offset;
- Object getCurrent() {
- return this.get(offset);
- //return this.peek(this.offset);
+ EnvironmentInfo getCurrent() {
+ return (EnvironmentInfo)this.get(offset);
}
int getOffset() {
@@ -92,6 +92,17 @@
XMLConsumer getEnvironmentAwareConsumerWrapper(XMLConsumer consumer,
int oldOffset) {
return new EnvironmentChanger(consumer, this, oldOffset, this.offset);
+ }
+}
+
+final class EnvironmentInfo {
+
+ public final Processor processor;
+ public final int oldStackCount;
+
+ public EnvironmentInfo(Processor processor, int oldStackCount) {
+ this.processor = processor;
+ this.oldStackCount = oldStackCount;
}
}
1.2 +6 -8 cocoon-2.2/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java
Index: CocoonSourceResolver.java
===================================================================
RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CocoonSourceResolver.java 19 Oct 2003 15:58:15 -0000 1.1
+++ CocoonSourceResolver.java 24 Oct 2003 12:49:40 -0000 1.2
@@ -57,14 +57,13 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.components.CocoonComponentManager;
-import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.environment.EnvironmentHelper;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.impl.SourceResolverImpl;
-
/**
* This is the default implementation of the {@link SourceResolver} for
* Cocoon.
@@ -85,10 +84,9 @@
public Source resolveURI(String location, String baseURI, Map parameters)
throws MalformedURLException, IOException, SourceException {
if ( baseURI == null ) {
- // TODO (CZ) Change this!
- final Environment env = CocoonComponentManager.getCurrentEnvironment();
- if ( env != null ) {
- baseURI = env.getContext();
+ final Processor processor = EnvironmentHelper.getCurrentProcessor();
+ if ( processor != null ) {
+ return processor.getSourceResolver().resolveURI(location, null, parameters);
}
}
if ( this.customResolver != null ) {