sylvain 01/10/22 03:17:47
Modified: . changes.xml
src/org/apache/cocoon/components/language/markup/sitemap/java
sitemap.xsl
src/org/apache/cocoon/matching AbstractRegexpMatcher.java
AbstractWildcardMatcher.java
BrowserMatcherFactory.java Matcher.java
RegexpTargetHostMatcherFactory.java
RegexpURIMatcherFactory.java
WildcardHeaderMatcherFactory.java
WildcardParameterValueMatcherFactory.java
WildcardSessionAttributeMatcher.java
WildcardSessionAttributeMatcherFactory.java
WildcardURIMatcherFactory.java
src/org/apache/cocoon/selection BrowserSelectorFactory.java
CodedSelectorFactory.java
HeaderSelectorFactory.java HostSelectorFactory.java
ParameterSelectorFactory.java
RequestSelectorFactory.java
SessionAttributeSelectorFactory.java
src/org/apache/cocoon/sitemap XSLTFactoryLoader.java
webapp sitemap.xmap
webapp/i18n sitemap.xmap
webapp/protected sitemap.xmap
webapp/sitebuilder sitemap.skel.xmap
webapp/sub sitemap.xmap
webapp.tutorial sitemap.xmap
Added: src/org/apache/cocoon/matching
AbstractPreparableMatcher.java
PreparableMatcher.java
src/org/apache/cocoon/selection BrowserSelector.java
HeaderSelector.java HostSelector.java
NamedPatternsSelector.java ParameterSelector.java
RequestSelector.java SessionAttributeSelector.java
Removed: src/org/apache/cocoon/matching PreparedMatcher.java
Log:
- PreparableMatchers are now fully inherited in subsitemaps
- Rewrote all factory-based selectors as implementations of Selector.
Revision Changes Path
1.43 +4 -4 xml-cocoon2/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/changes.xml,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- changes.xml 2001/10/19 15:28:44 1.42
+++ changes.xml 2001/10/22 10:17:45 1.43
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.42 2001/10/19 15:28:44 sylvain Exp $
+ $Id: changes.xml,v 1.43 2001/10/22 10:17:45 sylvain Exp $
-->
<changes title="History of Changes">
@@ -27,9 +27,9 @@
<release version="2.1-dev" date="@date@">
<action dev="SW" type="add">
- New PreparedMatcher interface as a replacement for CodeFactory. All
factory-based matchers have
- been rewritten using this new interface. CodeFactory shouldn't be used
anymore in preparation of
- the tree traversal implementation of the sitemap.
+ Deprecation of CodeFactory in preparation of the tree traversal
implementation of the sitemap.
+ All factory-based matchers have been rewritten using the new
PreparableMatcher interface, and
+ all factory-based selectors have been rewritten as regular
implementations of Selector.
</action>
<action dev="SW" type="fix">
Reduce exception nesting in case of sitemap setup errors, and display
all nested exceptions
1.45 +74 -84
xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl
Index: sitemap.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- sitemap.xsl 2001/10/19 15:28:45 1.44
+++ sitemap.xsl 2001/10/22 10:17:45 1.45
@@ -107,7 +107,7 @@
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.matching.Matcher;
- import org.apache.cocoon.matching.PreparedMatcher;
+ import org.apache.cocoon.matching.PreparableMatcher;
import org.apache.cocoon.selection.Selector;
import org.apache.cocoon.sitemap.AbstractSitemap;
import org.apache.cocoon.components.pipeline.StreamPipeline;
@@ -125,7 +125,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo
Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin
Loritsch</a>
- * @version CVS $Id: sitemap.xsl,v 1.44 2001/10/19 15:28:45 sylvain Exp $
+ * @version CVS $Id: sitemap.xsl,v 1.45 2001/10/22 10:17:45 sylvain Exp $
*/
public class <xsl:value-of select="@file-name"/> extends AbstractSitemap
{
static final String LOCATION = "<xsl:value-of
select="translate(@file-path, '/', '.')"/>.<xsl:value-of select="@file-name"/>";
@@ -138,13 +138,14 @@
private Parameters emptyParam = new Parameters();
- <!-- Generate matchers which implements CodeFactory or PreparedMatcher
-->
+ <!-- Generate matchers which implements CodeFactory -->
<xsl:for-each
select="/map:sitemap/map:components/map:matchers/map:matcher">
<xsl:call-template name="line-number"/>
<xsl:variable name="src">
<xsl:value-of select="@src"/>
</xsl:variable>
- <xsl:if test="XSLTFactoryLoader:isFactory($factory-loader,
string($src))">
+ <xsl:choose>
+ <xsl:when test="XSLTFactoryLoader:isFactory($factory-loader,
string($src))">
<xsl:variable name="name" select="@name"/>
<xsl:variable name="type" select="translate(@name, '- ', '__')"/>
<xsl:variable name="default" select="@name = ../@default"/>
@@ -164,28 +165,33 @@
// The generated matcher for a pattern of "<xsl:value-of
select="@pattern"/>"
<xsl:value-of
select="XSLTFactoryLoader:getClassSource($factory-loader,string($src),string($matcher-name),string(@pattern),$config)"/>
</xsl:for-each>
- </xsl:if>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:for-each>
- <xsl:if test="XSLTFactoryLoader:isPreparedMatcher($factory-loader,
string($src))">
- <xsl:variable name="name" select="@name"/>
- <!--xsl:variable name="type" select="translate(@name, '- ',
'__')"/-->
- <xsl:variable name="default" select="@name = ../@default"/>
+ <!-- Generate variables for non-factory patterns -->
+ <xsl:for-each select="/map:sitemap/map:pipelines//map:match">
- <!-- process all map:match elements with a type attribute refering
to the current matcher factory iteration -->
- <xsl:for-each
select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:[EMAIL
PROTECTED] or (not(@type) and $default)]">
- <xsl:call-template name="line-number"/>
- <xsl:variable name="matcher-name">
- <xsl:call-template name="generate-name">
- <xsl:with-param name="prefix">matcher_</xsl:with-param>
- <xsl:with-param name="suffix"><xsl:value-of
select="$name"/>_<xsl:value-of select="generate-id(.)"/></xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
- // The prepared pattern for "<xsl:value-of select="@pattern"/>"
- private Object <xsl:value-of select="$matcher-name"/>_expr;
- </xsl:for-each>
- </xsl:if>
- </xsl:for-each>
+ <!-- get the type of matcher used -->
+ <xsl:variable name="matcher-type">
+ <xsl:call-template name="get-parameter">
+ <xsl:with-param name="parname">type</xsl:with-param>
+ <xsl:with-param name="default"><xsl:value-of
select="/map:sitemap/map:components/map:matchers/@default"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="src"
select="/map:sitemap/map:components/map:matchers/map:[EMAIL
PROTECTED]($matcher-type)]/@src"/>
+ <xsl:if test="not(XSLTFactoryLoader:isFactory($factory-loader,
string($src)))">
+ <xsl:variable name="matcher-name">
+ <xsl:call-template name="generate-name">
+ <xsl:with-param name="prefix">matcher_</xsl:with-param>
+ <xsl:with-param name="suffix"><xsl:value-of
select="$matcher-type"/>_<xsl:value-of
select="generate-id(.)"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ // Pattern for "<xsl:value-of select="@pattern"/>" (either String
or prepared pattern)
+ private Object <xsl:value-of select="$matcher-name"/>_expr;
+ </xsl:if>
+ </xsl:for-each>
<!-- Generate selectors which implements CodeFactory -->
<xsl:for-each
select="/map:sitemap/map:components/map:selectors/map:selector">
@@ -230,24 +236,16 @@
}
/**
- * Method that handles prepared matchers.
- */
- private Map preparedMatches(String hint, Object preparedPattern, List
listOfMaps, Parameters params, Map objectModel) throws Exception {
- PreparedMatcher matcher =
(PreparedMatcher)this.matchers.select(hint);
- try {
- return matcher.match(preparedPattern, objectModel, params);
- } finally {
- this.matchers.release(matcher);
- }
- }
-
- /**
* Method that handles non-factory matchers.
*/
- private Map matches(String hint, String patternValue, List listOfMaps,
Parameters params, Map objectModel) throws Exception {
- Matcher matcher = (Matcher)this.matchers.select(hint);
+ private Map matches(String hint, Object patternValue, List listOfMaps,
Parameters params, Map objectModel) throws Exception {
+ Component matcher = (Component)this.matchers.select(hint);
try {
- return matcher.match(substitute(listOfMaps, patternValue),
objectModel, params);
+ if (matcher instanceof PreparableMatcher) {
+ return ((PreparableMatcher)matcher).preparedMatch(patternValue,
objectModel, params);
+ } else {
+ return ((Matcher)matcher).match(substitute(listOfMaps,
(String)patternValue), objectModel, params);
+ }
} finally {
this.matchers.release(matcher);
}
@@ -371,40 +369,48 @@
}
}
- /** Prepare patterns of PreparedMatchers. */
+ public Object preparePattern(String type, String pattern) throws
Exception {
+ Component matcher = this.matchers.select(type);
+ try {
+ if (matcher instanceof PreparableMatcher) {
+ // Prepare pattern
+ return ((PreparableMatcher)matcher).preparePattern(pattern);
+ } else {
+ // Return pattern unchanged
+ return pattern;
+ }
+ } finally {
+ this.matchers.release(matcher);
+ }
+ }
+ /** Prepare patterns of PreparableMatchers. */
public void prepareMatchers() throws Exception {
- <!-- Prepare patterns for PreparedMatchers -->
- PreparedMatcher matcher = null;
- <xsl:for-each
select="/map:sitemap/map:components/map:matchers/map:matcher">
- <xsl:call-template name="line-number"/>
- <xsl:variable name="src">
- <xsl:value-of select="@src"/>
- </xsl:variable>
+ <!-- Generate variables for non-factory patterns -->
+ <xsl:for-each select="/map:sitemap/map:pipelines//map:match">
- <xsl:if test="XSLTFactoryLoader:isPreparedMatcher($factory-loader,
string($src))">
- <xsl:variable name="name" select="@name"/>
- <!--xsl:variable name="type" select="translate(@name, '- ',
'__')"/-->
- <xsl:variable name="default" select="@name = ../@default"/>
+ <!-- get the type of matcher used -->
+ <xsl:variable name="matcher-type">
+ <xsl:call-template name="get-parameter">
+ <xsl:with-param name="parname">type</xsl:with-param>
+ <xsl:with-param name="default"><xsl:value-of
select="/map:sitemap/map:components/map:matchers/@default"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
- // Prepare patterns for matcher '<xsl:value-of select="@name"/>'
- matcher = (PreparedMatcher)this.matchers.select("<xsl:value-of
select="@name"/>");
+ <xsl:variable name="src"
select="/map:sitemap/map:components/map:matchers/map:[EMAIL
PROTECTED]($matcher-type)]/@src"/>
- <!-- process all map:match elements with a type attribute refering
to the current matcher factory iteration -->
- <xsl:for-each
select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:[EMAIL
PROTECTED] or (not(@type) and $default)]">
- <xsl:call-template name="line-number"/>
- <xsl:variable name="matcher-name">
- <xsl:call-template name="generate-name">
- <xsl:with-param name="prefix">matcher_</xsl:with-param>
- <xsl:with-param name="suffix"><xsl:value-of
select="$name"/>_<xsl:value-of select="generate-id(.)"/></xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
+ <xsl:if test="not(XSLTFactoryLoader:isFactory($factory-loader,
string($src)))">
+ <xsl:variable name="matcher-name">
+ <xsl:call-template name="generate-name">
+ <xsl:with-param name="prefix">matcher_</xsl:with-param>
+ <xsl:with-param name="suffix"><xsl:value-of
select="$matcher-type"/>_<xsl:value-of
select="generate-id(.)"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
// Prepare the pattern for "<xsl:value-of select="@pattern"/>"
- this.<xsl:value-of select="$matcher-name"/>_expr =
matcher.preparePattern("<xsl:value-of
select="XSLTFactoryLoader:escape($factory-loader, @pattern)"/>");
- </xsl:for-each>
- this.matchers.release(matcher);
- </xsl:if>
- </xsl:for-each>
+ this.<xsl:value-of select="$matcher-name"/>_expr =
this.preparePattern("<xsl:value-of select="$matcher-type"/>", "<xsl:value-of
select="XSLTFactoryLoader:escape($factory-loader, @pattern)"/>");
+ </xsl:if>
+ </xsl:for-each>
+
}
<!-- generate methods for every map:resource element -->
@@ -711,11 +717,6 @@
<xsl:value-of select="XSLTFactoryLoader:isFactory($factory-loader,
string(/map:sitemap/map:components/map:matchers/map:[EMAIL PROTECTED]/@src))"/>
</xsl:variable>
- <!-- check if this matcher is a prepared matcher ? -->
- <xsl:variable name="is-prepared">
- <xsl:value-of
select="XSLTFactoryLoader:isPreparedMatcher($factory-loader,
string(/map:sitemap/map:components/map:matchers/map:[EMAIL PROTECTED]/@src))"/>
- </xsl:variable>
-
<!-- break on error when old parameter syntax exists -->
<xsl:if test="parameter">
<xsl:call-template name="error">
@@ -752,11 +753,8 @@
<xsl:when test="string($is-factory)='true'">
<xsl:value-of select="translate($matcher-type, '- ',
'__')"/>Match(<xsl:value-of select="$matcher-name2"/>_expr, objectModel,
<xsl:value-of select="$component-param"/>)
</xsl:when>
- <xsl:when test="string($is-prepared)='true'">
- preparedMatches("<xsl:value-of select="$matcher-type"/>",
<xsl:value-of select="$matcher-name2"/>_expr, listOfMaps, <xsl:value-of
select="$component-param"/>, objectModel)
- </xsl:when>
<xsl:otherwise>
- matches("<xsl:value-of select="$matcher-type"/>", "<xsl:value-of
select="XSLTFactoryLoader:escape($factory-loader, $pattern-value)"/>",
listOfMaps, <xsl:value-of select="$component-param"/>, objectModel)
+ matches("<xsl:value-of select="$matcher-type"/>", <xsl:value-of
select="$matcher-name2"/>_expr, listOfMaps, <xsl:value-of
select="$component-param"/>, objectModel)
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
@@ -805,10 +803,6 @@
<xsl:value-of select="XSLTFactoryLoader:isFactory($factory-loader,
string(/map:sitemap/map:components/map:matchers/map:[EMAIL PROTECTED]/@src))"/>
</xsl:variable>
- <xsl:variable name="is-prepared">
- <xsl:value-of
select="XSLTFactoryLoader:isPreparedMatcher($factory-loader,
string(/map:sitemap/map:components/map:matchers/map:[EMAIL PROTECTED]/@src))"/>
- </xsl:variable>
-
<!-- break on error when old parameter syntax exists -->
<xsl:if test="parameter">
<xsl:call-template name="error">
@@ -846,12 +840,8 @@
<xsl:value-of select="translate($matcher-type, '- ',
'__')"/>Match(<xsl:value-of select="$matcher-name2"/>_expr, objectModel,
<xsl:value-of select="$component-param"/>)
</xsl:when>
- <xsl:when test="string($is-prepared)='true'">
- <xsl:text>preparedMatches("</xsl:text><xsl:value-of
select="$matcher-type"/>", <xsl:value-of select="$matcher-name2"/>_expr,
listOfMaps, <xsl:value-of select="$component-param"/><xsl:text>,
objectModel)</xsl:text>
- </xsl:when>
-
<xsl:otherwise>
- <xsl:text>matches("</xsl:text><xsl:value-of
select="$matcher-type"/>", "<xsl:value-of
select="XSLTFactoryLoader:escape($factory-loader, $pattern-value)"/>",
listOfMaps, <xsl:value-of select="$component-param"/><xsl:text>,
objectModel)</xsl:text>
+ <xsl:text>matches("</xsl:text><xsl:value-of
select="$matcher-type"/>", <xsl:value-of select="$matcher-name2"/>_expr,
listOfMaps, <xsl:value-of select="$component-param"/><xsl:text>,
objectModel)</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
1.2 +4 -5
xml-cocoon2/src/org/apache/cocoon/matching/AbstractRegexpMatcher.java
Index: AbstractRegexpMatcher.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/AbstractRegexpMatcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractRegexpMatcher.java 2001/10/19 15:28:45 1.1
+++ AbstractRegexpMatcher.java 2001/10/22 10:17:45 1.2
@@ -7,7 +7,6 @@
*****************************************************************************/
package org.apache.cocoon.matching;
-import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
@@ -28,10 +27,10 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @authos <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/10/19 15:28:45 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/10/22 10:17:45 $
*/
-public abstract class AbstractRegexpMatcher extends AbstractLoggable
implements PreparedMatcher, ThreadSafe {
+public abstract class AbstractRegexpMatcher extends
AbstractPreparableMatcher implements ThreadSafe {
/**
* Compile the pattern in a <code>org.apache.regexp.REProgram</code>.
@@ -49,9 +48,9 @@
}
/**
- * Match the prepared pattern against the value returned by [EMAIL
PROTECTED] #getMatchString()}.
+ * Match the prepared pattern against the value returned by [EMAIL
PROTECTED] #getMatchString(Map, Parameters)}.
*/
- public Map match(Object preparedPattern, Map objectModel, Parameters
parameters) {
+ public Map preparedMatch(Object preparedPattern, Map objectModel,
Parameters parameters) {
RE re = new RE((REProgram)preparedPattern);
String match = getMatchString(objectModel, parameters);
1.2 +4 -4
xml-cocoon2/src/org/apache/cocoon/matching/AbstractWildcardMatcher.java
Index: AbstractWildcardMatcher.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/AbstractWildcardMatcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractWildcardMatcher.java 2001/10/19 15:28:45 1.1
+++ AbstractWildcardMatcher.java 2001/10/22 10:17:45 1.2
@@ -23,10 +23,10 @@
* Base class for wildcard matchers
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/10/19 15:28:45 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/10/22 10:17:45 $
*/
-public abstract class AbstractWildcardMatcher extends AbstractLoggable
implements PreparedMatcher, ThreadSafe {
+public abstract class AbstractWildcardMatcher extends
AbstractPreparableMatcher implements ThreadSafe {
/**
* Compile the pattern in an <code>int[]</code>.
@@ -36,9 +36,9 @@
}
/**
- * Match the prepared pattern against the result of [EMAIL PROTECTED]
#getMatchString()}.
+ * Match the prepared pattern against the result of [EMAIL PROTECTED]
#getMatchString(Map, Parameters)}.
*/
- public Map match(Object preparedPattern, Map objectModel, Parameters
parameters) {
+ public Map preparedMatch(Object preparedPattern, Map objectModel,
Parameters parameters) {
String match = getMatchString(objectModel, parameters);
1.8 +2 -2
xml-cocoon2/src/org/apache/cocoon/matching/BrowserMatcherFactory.java
Index: BrowserMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/BrowserMatcherFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BrowserMatcherFactory.java 2001/10/19 15:28:45 1.7
+++ BrowserMatcherFactory.java 2001/10/22 10:17:45 1.8
@@ -19,8 +19,8 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.7 $ $Date: 2001/10/19 15:28:45 $
- * @deprecated code factories are replaced by PreparedMatcher
+ * @version CVS $Revision: 1.8 $ $Date: 2001/10/22 10:17:45 $
+ * @deprecated not replaced, because it does nothing !!
*/
public class BrowserMatcherFactory implements CodeFactory {
1.7 +3 -2 xml-cocoon2/src/org/apache/cocoon/matching/Matcher.java
Index: Matcher.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/Matcher.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Matcher.java 2001/10/11 07:28:22 1.6
+++ Matcher.java 2001/10/22 10:17:45 1.7
@@ -9,13 +9,14 @@
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.sitemap.PatternException;
import java.util.Map;
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.6 $ $Date: 2001/10/11 07:28:22 $
+ * @version CVS $Revision: 1.7 $ $Date: 2001/10/22 10:17:45 $
*/
public interface Matcher extends Component {
@@ -36,7 +37,7 @@
* contained in the pattern.
* If the return value is null there was no match.
*/
- Map match (String pattern, Map objectModel, Parameters parameters);
+ Map match (String pattern, Map objectModel, Parameters parameters)
throws PatternException;
}
1.6 +2 -2
xml-cocoon2/src/org/apache/cocoon/matching/RegexpTargetHostMatcherFactory.java
Index: RegexpTargetHostMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/RegexpTargetHostMatcherFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RegexpTargetHostMatcherFactory.java 2001/10/19 15:28:45 1.5
+++ RegexpTargetHostMatcherFactory.java 2001/10/22 10:17:45 1.6
@@ -23,8 +23,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
- * @version CVS $Revision: 1.5 $ $Date: 2001/10/19 15:28:45 $
- * @deprecated code factories are replaced by PreparedMatcher
+ * @version CVS $Revision: 1.6 $ $Date: 2001/10/22 10:17:45 $
+ * @deprecated replaced by RegexpTargetHostMatcher - code factories should
no longer be used
*/
public class RegexpTargetHostMatcherFactory extends AbstractLoggable
implements CodeFactory {
1.6 +2 -2
xml-cocoon2/src/org/apache/cocoon/matching/RegexpURIMatcherFactory.java
Index: RegexpURIMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/RegexpURIMatcherFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RegexpURIMatcherFactory.java 2001/10/19 15:28:45 1.5
+++ RegexpURIMatcherFactory.java 2001/10/22 10:17:45 1.6
@@ -21,8 +21,8 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.5 $ $Date: 2001/10/19 15:28:45 $
- * @deprecated code factories are replaced by PreparedMatcher
+ * @version CVS $Revision: 1.6 $ $Date: 2001/10/22 10:17:45 $
+ * @deprecated replaced by RegexpURIMatcher - code factories should no
longer be used
*/
public class RegexpURIMatcherFactory extends AbstractLoggable implements
CodeFactory {
1.9 +2 -2
xml-cocoon2/src/org/apache/cocoon/matching/WildcardHeaderMatcherFactory.java
Index: WildcardHeaderMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/WildcardHeaderMatcherFactory.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WildcardHeaderMatcherFactory.java 2001/10/19 15:28:45 1.8
+++ WildcardHeaderMatcherFactory.java 2001/10/22 10:17:45 1.9
@@ -22,8 +22,8 @@
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
- * @version CVS $Revision: 1.8 $ $Date: 2001/10/19 15:28:45 $
- * @deprecated code factories are replaced by PreparedMatcher
+ * @version CVS $Revision: 1.9 $ $Date: 2001/10/22 10:17:45 $
+ * @deprecated replaced by WildcardHeaderMatcher - code factories should no
longer be used
*/
public class WildcardHeaderMatcherFactory extends WildcardURIMatcherFactory {
1.9 +2 -2
xml-cocoon2/src/org/apache/cocoon/matching/WildcardParameterValueMatcherFactory.java
Index: WildcardParameterValueMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/WildcardParameterValueMatcherFactory.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- WildcardParameterValueMatcherFactory.java 2001/10/19 15:28:45 1.8
+++ WildcardParameterValueMatcherFactory.java 2001/10/22 10:17:45 1.9
@@ -26,8 +26,8 @@
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
- * @deprecated code factories are replaced by PreparedMatcher
- * @version CVS $Revision: 1.8 $ $Date: 2001/10/19 15:28:45 $ */
+ * @deprecated replaced by WildcardParameterValueMatcher - code factories
should no longer be used
+ * @version CVS $Revision: 1.9 $ $Date: 2001/10/22 10:17:45 $ */
public class WildcardParameterValueMatcherFactory extends
WildcardURIMatcherFactory {
1.2 +2 -2
xml-cocoon2/src/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java
Index: WildcardSessionAttributeMatcher.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WildcardSessionAttributeMatcher.java 2001/10/19 15:28:45 1.1
+++ WildcardSessionAttributeMatcher.java 2001/10/22 10:17:46 1.2
@@ -26,10 +26,10 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/10/19 15:28:45 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/10/22 10:17:46 $
*/
-public class WildcardSessionAttributeMatcher extends
WildcardURIMatcherFactory {
+public class WildcardSessionAttributeMatcher extends WildcardURIMatcher {
private String defaultParam;
1.6 +2 -2
xml-cocoon2/src/org/apache/cocoon/matching/WildcardSessionAttributeMatcherFactory.java
Index: WildcardSessionAttributeMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/WildcardSessionAttributeMatcherFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WildcardSessionAttributeMatcherFactory.java 2001/10/19 15:28:45
1.5
+++ WildcardSessionAttributeMatcherFactory.java 2001/10/22 10:17:46
1.6
@@ -21,8 +21,8 @@
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
- * @version CVS $Revision: 1.5 $ $Date: 2001/10/19 15:28:45 $
- * @deprecated code factories are replaced by PreparedMatcher
+ * @version CVS $Revision: 1.6 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated replaced by WildcardSessionAttributeMatcher - code factories
should no longer be used
*/
public class WildcardSessionAttributeMatcherFactory extends
WildcardURIMatcherFactory {
1.6 +2 -2
xml-cocoon2/src/org/apache/cocoon/matching/WildcardURIMatcherFactory.java
Index: WildcardURIMatcherFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/matching/WildcardURIMatcherFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WildcardURIMatcherFactory.java 2001/10/19 15:28:45 1.5
+++ WildcardURIMatcherFactory.java 2001/10/22 10:17:46 1.6
@@ -19,8 +19,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.5 $ $Date: 2001/10/19 15:28:45 $
- * @deprecated code factories are replaced by PreparedMatcher
+ * @version CVS $Revision: 1.6 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated replaced by WildcardURIMatcher - code factories should no
longer be used
*/
public class WildcardURIMatcherFactory extends AbstractLoggable implements
CodeFactory {
1.1
xml-cocoon2/src/org/apache/cocoon/matching/AbstractPreparableMatcher.java
Index: AbstractPreparableMatcher.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.matching;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.sitemap.PatternException;
import java.util.Map;
/**
* A matcher that can prepare patterns during sitemap setup for faster match
at request time.
* This is also a regular matcher, meaning the sitemap can decide either to
prepare the pattern
* or to match with a request-time evaluated pattern (for {..} substitution).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:45 $
*/
public abstract class AbstractPreparableMatcher extends AbstractLoggable
implements PreparableMatcher {
/**
* Match the pattern by preparing it and matching the prepared pattern.
*/
public Map match (String pattern, Map objectModel, Parameters parameters)
throws PatternException {
return preparedMatch(preparePattern(pattern), objectModel,
parameters);
}
}
1.1
xml-cocoon2/src/org/apache/cocoon/matching/PreparableMatcher.java
Index: PreparableMatcher.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.matching;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.sitemap.PatternException;
import java.util.Map;
/**
* A matcher that can prepare patterns during sitemap setup for faster match
at request time.
* This is also a regular matcher, meaning the sitemap can decide either to
prepare the pattern
* or to match with a request-time evaluated pattern (for {..} substitution).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:45 $
*/
public interface PreparableMatcher extends Matcher {
/**
* Prepares a pattern in a form that allows faster match. For example, a
regular
* expression matcher can precompile the expression and return the
corresponding
* object. This method is called once for each pattern used with a
particular matcher
* class. The returned value is then passed back as the
<code>preparedPattern</code>
* parameter of [EMAIL PROTECTED] #match(Object, Map, Parameters)}.
*
* @param pattern The pattern to prepare. Depending on the implementation
the pattern
* can contain wildcards or regular expressions.
* @return an optimized representation of the pattern.
* @throws a <code>PatternException</code> if the pattern couldn't be
prepared.
*/
Object preparePattern(String pattern) throws PatternException;
/**
* Matches the prepared pattern against some values in the object model
(most often the
* <code>Request</code) and returns a <code>Map</code> object with
replacements
* for wildcards contained in the pattern.
*
* @param preparedPattern The preparedPattern to match against, as
returned by [EMAIL PROTECTED] #preparePattern(String)}.
* @param objectModel The <code>Map</code> with objects of the
calling environment
* which can be used to select values this
matchers matches against.
* @return a <code>Map</code> object with replacements for
wildcards/regular-expressions
* contained in the pattern. If the return value
is null there was no match.
*/
Map preparedMatch(Object preparedPattern, Map objectModel, Parameters
parameters);
}
1.7 +3 -2
xml-cocoon2/src/org/apache/cocoon/selection/BrowserSelectorFactory.java
Index: BrowserSelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/selection/BrowserSelectorFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BrowserSelectorFactory.java 2001/10/11 07:28:22 1.6
+++ BrowserSelectorFactory.java 2001/10/22 10:17:46 1.7
@@ -20,8 +20,9 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.6 $ $Date: 2001/10/11 07:28:22 $
-*/
+ * @version CVS $Revision: 1.7 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated replaced by BrowserSelector - code factories should no longer
be used
+ */
public class BrowserSelectorFactory implements CodeFactory {
1.4 +2 -1
xml-cocoon2/src/org/apache/cocoon/selection/CodedSelectorFactory.java
Index: CodedSelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/selection/CodedSelectorFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CodedSelectorFactory.java 2001/10/11 07:28:22 1.3
+++ CodedSelectorFactory.java 2001/10/22 10:17:46 1.4
@@ -16,7 +16,8 @@
* embedded java code within the 'test' clause of the select.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
- * @version CVS $Revision: 1.3 $ $Date: 2001/10/11 07:28:22 $
+ * @version CVS $Revision: 1.4 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated no replacement - code factories should no longer be used
*/
public class CodedSelectorFactory extends java.lang.Object
implements CodeFactory {
1.8 +2 -1
xml-cocoon2/src/org/apache/cocoon/selection/HeaderSelectorFactory.java
Index: HeaderSelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/selection/HeaderSelectorFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HeaderSelectorFactory.java 2001/10/11 07:28:23 1.7
+++ HeaderSelectorFactory.java 2001/10/22 10:17:46 1.8
@@ -22,7 +22,8 @@
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
- * @version CVS $Revision: 1.7 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.8 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated replaced by HeaderSelector - code factories should no longer
be used
*/
public class HeaderSelectorFactory extends ParameterSelectorFactory {
1.7 +3 -2
xml-cocoon2/src/org/apache/cocoon/selection/HostSelectorFactory.java
Index: HostSelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/selection/HostSelectorFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HostSelectorFactory.java 2001/10/11 07:28:23 1.6
+++ HostSelectorFactory.java 2001/10/22 10:17:46 1.7
@@ -32,8 +32,9 @@
* </map:select>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Colin Britton</a>
- * @version CVS $Revision: 1.6 $ $Date: 2001/10/11 07:28:23 $
-*/
+ * @version CVS $Revision: 1.7 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated replaced by HostSelector - code factories should no longer be
used
+ */
public class HostSelectorFactory implements CodeFactory {
1.6 +2 -1
xml-cocoon2/src/org/apache/cocoon/selection/ParameterSelectorFactory.java
Index: ParameterSelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/selection/ParameterSelectorFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ParameterSelectorFactory.java 2001/10/11 07:28:23 1.5
+++ ParameterSelectorFactory.java 2001/10/22 10:17:46 1.6
@@ -35,7 +35,8 @@
* depending on those parameters.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Leo Sutic</a>
- * @version CVS $Revision: 1.5 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.6 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated replaced by ParameterSelector - code factories should no
longer be used
*/
public class ParameterSelectorFactory implements CodeFactory {
1.8 +2 -1
xml-cocoon2/src/org/apache/cocoon/selection/RequestSelectorFactory.java
Index: RequestSelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/selection/RequestSelectorFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RequestSelectorFactory.java 2001/10/11 07:28:23 1.7
+++ RequestSelectorFactory.java 2001/10/22 10:17:46 1.8
@@ -22,7 +22,8 @@
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
- * @version CVS $Revision: 1.7 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.8 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated replaced by RequestSelector - code factories should no longer
be used
*/
public class RequestSelectorFactory extends ParameterSelectorFactory {
1.5 +2 -1
xml-cocoon2/src/org/apache/cocoon/selection/SessionAttributeSelectorFactory.java
Index: SessionAttributeSelectorFactory.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/selection/SessionAttributeSelectorFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SessionAttributeSelectorFactory.java 2001/10/11 07:28:23 1.4
+++ SessionAttributeSelectorFactory.java 2001/10/22 10:17:46 1.5
@@ -21,7 +21,8 @@
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
- * @version CVS $Revision: 1.4 $ $Date: 2001/10/11 07:28:23 $
+ * @version CVS $Revision: 1.5 $ $Date: 2001/10/22 10:17:46 $
+ * @deprecated replaced by SessionAttributeSelector - code factories should
no longer be used
*/
public class SessionAttributeSelectorFactory extends
ParameterSelectorFactory {
1.1
xml-cocoon2/src/org/apache/cocoon/selection/BrowserSelector.java
Index: BrowserSelector.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.selection;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import java.util.Map;
/**
* Tests a specific browser pattern against the requesting user-agent.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:46 $
*/
public class BrowserSelector extends NamedPatternsSelector {
public void configure(Configuration conf) throws ConfigurationException {
configure(conf, "browser", "name", "useragent");
}
public boolean select(String expression, Map objectModel, Parameters
parameters) {
// Inform proxies that response varies with the user-agent header
ObjectModelHelper.getResponse(objectModel).addHeader("Vary",
"User-Agent");
// Get the user-agent request header
String userAgent =
ObjectModelHelper.getRequest(objectModel).getHeader("User-Agent");
if (userAgent == null) {
getLogger().debug("No User-Agent header -- failing.");
return false;
}
return checkPatterns(expression, userAgent);
}
}
1.1
xml-cocoon2/src/org/apache/cocoon/selection/HeaderSelector.java
Index: HeaderSelector.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.selection;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.environment.ObjectModelHelper;
import java.util.Map;
/**
* A <code>Selector</code> that matches a string against a configurable
* request header, e.g. "referer".
*
* <p><b>Global and local configuration</b></p>
* <table border="1">
* <tr><td><code>header-name</code></td><td>Name of the request header to
* match against</td></tr>
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:46 $
*/
public class HeaderSelector extends AbstractLoggable
implements Configurable, ThreadSafe, Selector {
protected String defaultName;
public void configure(Configuration config) throws ConfigurationException
{
// Check old name
this.defaultName = config.getChild("parameter-name").getValue(null);
if (defaultName != null) {
getLogger().warn("'parameter-name' is deprecated. Please use
'header-name'");
}
// Load with new one
this.defaultName =
config.getChild("header-name").getValue(this.defaultName);
}
public boolean select(String expression, Map objectModel, Parameters
parameters) {
// Check old name
String name = parameters.getParameter("parameter-name", null);
if (name != null) {
getLogger().warn("'parameter-name' is deprecated. Please use
'header-name'");
} else {
name = this.defaultName;
}
// Load with new one.
name = parameters.getParameter("header-name", name);
if (name == null) {
getLogger().warn("No header name given -- failing.");
return false;
}
String value =
ObjectModelHelper.getRequest(objectModel).getHeader(name);
if (value == null) {
getLogger().debug("Header '" + name + "' not set -- failing.");
return false;
}
return value.equals(expression);
}
}
1.1
xml-cocoon2/src/org/apache/cocoon/selection/HostSelector.java
Index: HostSelector.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.selection;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import java.util.Map;
/**
* A <code>Selector</code> that matches a string from within the host
parameter
* of the HTTP request.
*
* <map:selector name="host"
src="org.apache.cocoon.selection.HostSelectorFactory">
* <host name="uk-site" value="www.foo.co.uk"/>
* </map:selector>
*
*
* <map:select type="host">
* <map:when test="uk-site">
* <map:transform src="stylesheets/page/uk.xsl"/>
* </map:when>
* <map:otherwise>
* <map:transform src="stylesheets/page/us.xsl"/>
* </map:otherwise>
* </map:select>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Colin Britton</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:46 $
*/
public class HostSelector extends NamedPatternsSelector {
public void configure(Configuration conf) throws ConfigurationException {
configure(conf, "host", "name", "value");
}
public boolean select(String expression, Map objectModel, Parameters
parameters) {
// Inform proxies that response varies with the Host header
ObjectModelHelper.getResponse(objectModel).addHeader("Vary", "Host");
// Get the host request header
String host =
ObjectModelHelper.getRequest(objectModel).getHeader("Host");
if (host == null) {
getLogger().debug("No Host header -- failing.");
return false;
}
return checkPatterns(expression, host);
}
}
1.1
xml-cocoon2/src/org/apache/cocoon/selection/NamedPatternsSelector.java
Index: NamedPatternsSelector.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.selection;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import java.util.*;
/**
* Abstract class for selectors that select a value when it matches
* some patterns associated to the select expression.
*
* @see BrowserSelector
* @see HostSelector
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:46 $
*/
public abstract class NamedPatternsSelector extends AbstractLoggable
implements Configurable, ThreadSafe, Selector {
/**
* Association of names to String[] of values.
*/
private Map strings;
/**
* Setup the association from expressions to a list of patterns. The
configuration
* should look like :
* <pre>
* <map:selector name="foo" src="...">
* <confName nameAttr="expression" valueAttr="pattern"/>
* ... others (expression, pattern) associations ...
* </map:selector>
* </pre>
*
* @param conf the configuration
* @param confName the name of children of <code>conf</code> that will be
used to
* build associations
* @param nameAttr the name of the attribute that holds the expression
* @param valueAttr the name of the attribute that holds the pattern
*/
protected void configure(Configuration conf, String confName, String
nameAttr, String valueAttr)
throws ConfigurationException {
Configuration confs[] = conf.getChildren(confName);
Map configMap = new HashMap();
// Build a list of strings for each name
for (int i = 0; i < confs.length; i++) {
String name = confs[i].getAttribute(nameAttr);
String value = confs[i].getAttribute(valueAttr);
// Get value list for this name
List nameList = (List)configMap.get(name);
if (nameList == null) {
nameList = new ArrayList();
configMap.put(name, nameList);
}
// Add the current value
nameList.add(value);
}
// Convert lists to arrays for faster lookup
Iterator entries = configMap.entrySet().iterator();
while(entries.hasNext()) {
Map.Entry entry = (Map.Entry)entries.next();
List nameList = (List)entry.getValue();
entry.setValue(nameList.toArray(new String[nameList.size()]));
}
this.strings = configMap;
}
/**
* Checks if <code>value</code> is a substring of one of the patterns
associated
* to <code>expression</code>
*
* @param expression the expression that is selected
* @param value the value to check
* @return true if <code>value</code> matches one of the patterns
*/
protected boolean checkPatterns(String expression, String value) {
if (value == null) {
getLogger().debug("No value given -- failing.");
return false;
}
// Get patterns for 'expression'
String[] patterns = (String[])this.strings.get(expression);
if (patterns == null) {
getLogger().warn("No configuration for expression '" + expression
+ "' -- failing.");
return false;
}
// Does a pattern match 'value' ?
for (int i = 0; i < patterns.length; i++) {
if (value.indexOf(patterns[i]) != -1) {
getLogger().debug(expression + " selected value " + value);
return true;
}
}
// No match
return false;
}
}
1.1
xml-cocoon2/src/org/apache/cocoon/selection/ParameterSelector.java
Index: ParameterSelector.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.selection;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import java.util.Map;
/**
* A <code>Selector</code> that matches a string in the parameters object
passed to it.
*
* <pre>
* <map:selector name="parameter"
factory="org.apache.cocoon.selection.ParameterSelector"/>
*
* <map:select type="parameter">
* <parameter name="parameter-selector-test"
value="{$mySitemapParameter}"/>
* <map:when test="myParameterValue">
* <!-- executes iff {$mySitemapParameter} == "myParameterValue"
-->
* <map:transform src="stylesheets/page/uk.xsl"/>
* </map:when>
* <map:otherwise>
* <map:transform src="stylesheets/page/us.xsl"/>
* </map:otherwise>
* </map:select>
* </pre>
*
* The purpose of this selector is to allow an action to set parameters
* and to be able to select between different pipeline configurations
* depending on those parameters.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Leo Sutic</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:46 $
*/
public class ParameterSelector implements ThreadSafe, Selector {
public boolean select(String expression, Map objectModel, Parameters
parameters) {
String compareToString =
parameters.getParameter("parameter-selector-test", null);
return compareToString != null && compareToString.equals(expression);
}
}
1.1
xml-cocoon2/src/org/apache/cocoon/selection/RequestSelector.java
Index: RequestSelector.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.selection;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import java.util.Map;
/**
* A <code>Selector</code> that matches a string against a configurable
request parameter's value.
*
* <p><b>Global and local configuration</b></p>
* <table border="1">
* <tr><td><code>parameter-name</code></td><td>Name of the request
* parameter whose value to match against</td></tr>
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:46 $
*/
public class RequestSelector extends AbstractLoggable
implements Configurable, ThreadSafe, Selector {
protected String defaultName;
public void configure(Configuration config) throws ConfigurationException
{
this.defaultName = config.getChild("parameter-name").getValue(null);
}
public boolean select(String expression, Map objectModel, Parameters
parameters) {
String name = parameters.getParameter("parameter-name",
this.defaultName);
if (name == null) {
getLogger().warn("No parameter name given -- failing.");
return false;
}
String value =
ObjectModelHelper.getRequest(objectModel).getParameter(name);
if (value == null) {
getLogger().debug("Request parameter '" + name + "' not set --
failing.");
return false;
}
return value.equals(expression);
}
}
1.1
xml-cocoon2/src/org/apache/cocoon/selection/SessionAttributeSelector.java
Index: SessionAttributeSelector.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.selection;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import java.util.Map;
/**
* This class generates source code to implement a selector that
* matches a string against an arbitrary session attribute.
*
* <p><b>Global and local configuration</b></p>
* <table border="1">
* <tr><td><code>attribute-name</code></td><td>String identifying the session
attribute.</td></tr>
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Christian Haul</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/10/22 10:17:46 $
*/
public class SessionAttributeSelector extends AbstractLoggable
implements Configurable, ThreadSafe, Selector {
protected String defaultName;
public void configure(Configuration config) throws ConfigurationException
{
this.defaultName = config.getChild("attribute-name").getValue(null);
}
public boolean select(String expression, Map objectModel, Parameters
parameters) {
String name = parameters.getParameter("attribute-name",
this.defaultName);
if (name == null) {
getLogger().warn("No attribute name given -- failing.");
return false;
}
String value =
(String)ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(name);
if (value == null) {
getLogger().debug("Request parameter '" + name + "' not set --
failing.");
return false;
}
return value.equals(expression);
}
}
1.9 +5 -14
xml-cocoon2/src/org/apache/cocoon/sitemap/XSLTFactoryLoader.java
Index: XSLTFactoryLoader.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/XSLTFactoryLoader.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSLTFactoryLoader.java 2001/10/19 15:28:45 1.8
+++ XSLTFactoryLoader.java 2001/10/22 10:17:47 1.9
@@ -10,7 +10,6 @@
import org.apache.avalon.framework.logger.Loggable;
import org.apache.cocoon.CodeFactory;
-import org.apache.cocoon.matching.PreparedMatcher;
import org.apache.cocoon.util.ClassUtils;
import org.apache.log.Logger;
import org.w3c.dom.NodeList;
@@ -27,7 +26,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.8 $ $Date: 2001/10/19 15:28:45 $
+ * @version CVS $Revision: 1.9 $ $Date: 2001/10/22 10:17:47 $
*/
public class XSLTFactoryLoader {
protected static Logger log;
@@ -107,24 +106,16 @@
public boolean isFactory(String className) {
boolean result = false;
+
+ if (className == null)
+ return false;
+
try {
result = ClassUtils.implementsInterface(className,
CodeFactory.class.getName());
} catch (ClassNotFoundException e) {
log.debug("ClassNotFoundException in XSLTFactoryLoader.isFactory
checking for " + className, e);
} catch (Exception e) {
log.debug("Exception in XSLTFactoryLoader.isFactory checking for
" + className, e);
- }
- return result;
- }
-
- public boolean isPreparedMatcher(String className) {
- boolean result = false;
- try {
- result = ClassUtils.implementsInterface(className,
PreparedMatcher.class.getName());
- } catch (ClassNotFoundException e) {
- log.debug("ClassNotFoundException in
XSLTFactoryLoader.isPreparedMatcher checking for " + className, e);
- } catch (Exception e) {
- log.debug("Exception in XSLTFactoryLoader.isPreparedMatcher
checking for " + className, e);
}
return result;
}
1.58 +2 -3 xml-cocoon2/webapp/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/sitemap.xmap,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- sitemap.xmap 2001/10/19 15:28:46 1.57
+++ sitemap.xmap 2001/10/22 10:17:47 1.58
@@ -72,7 +72,7 @@
</map:serializers>
<map:selectors default="browser">
- <map:selector name="browser"
src="org.apache.cocoon.selection.BrowserSelectorFactory">
+ <map:selector name="browser"
src="org.apache.cocoon.selection.BrowserSelector">
<!-- # NOTE: The appearance indicates the search order. This is very
important since
# some words may be found in more than one browser
description. (MSIE is
# presented as "Mozilla/4.0 (Compatible; MSIE 4.01; ...")
@@ -92,8 +92,7 @@
<browser name="mozilla5" useragent="Netscape6/"/>
<browser name="netscape" useragent="Mozilla"/>
</map:selector>
- <map:selector name="coded"
src="org.apache.cocoon.selection.CodedSelectorFactory"/>
- <map:selector name="parameter"
src="org.apache.cocoon.selection.ParameterSelectorFactory"/>
+ <map:selector name="parameter"
src="org.apache.cocoon.selection.ParameterSelector"/>
</map:selectors>
<map:matchers default="wildcard">
1.9 +1 -3 xml-cocoon2/webapp/i18n/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/i18n/sitemap.xmap,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- sitemap.xmap 2001/10/19 15:28:46 1.8
+++ sitemap.xmap 2001/10/22 10:17:47 1.9
@@ -7,9 +7,7 @@
<map:readers default="resource"/>
<map:serializers default="html"/>
<map:selectors default="browser"/>
- <map:matchers default="wildcard">
- <map:matcher name="wildcard"
src="org.apache.cocoon.matching.WildcardURIMatcher"/>
- </map:matchers>
+ <map:matchers default="wildcard"/>
</map:components>
<!-- =========================== Pipelines
================================= -->
1.7 +1 -3 xml-cocoon2/webapp/protected/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/protected/sitemap.xmap,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- sitemap.xmap 2001/10/19 15:28:46 1.6
+++ sitemap.xmap 2001/10/22 10:17:47 1.7
@@ -16,9 +16,7 @@
<map:selectors default="browser"/>
- <map:matchers default="wildcard">
- <map:matcher name="wildcard"
src="org.apache.cocoon.matching.WildcardURIMatcher"/>
- </map:matchers>
+ <map:matchers default="wildcard"/>
<map:actions>
<map:action name="session-validator"
1.2 +1 -1 xml-cocoon2/webapp/sitebuilder/sitemap.skel.xmap
Index: sitemap.skel.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/sitebuilder/sitemap.skel.xmap,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sitemap.skel.xmap 2001/08/21 12:43:37 1.1
+++ sitemap.skel.xmap 2001/10/22 10:17:47 1.2
@@ -17,7 +17,7 @@
<map:selectors id="7" default="browser"/>
<map:matchers id="8" default="wildcard">
- <map:matcher id="9" name="wildcard"
src="org.apache.cocoon.matching.WildcardURIMatcherFactory"/>
+ <map:matcher id="9" name="wildcard"
src="org.apache.cocoon.matching.WildcardURIMatcher"/>
</map:matchers>
</map:components>
1.6 +1 -3 xml-cocoon2/webapp/sub/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/sub/sitemap.xmap,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- sitemap.xmap 2001/10/19 15:28:46 1.5
+++ sitemap.xmap 2001/10/22 10:17:47 1.6
@@ -16,9 +16,7 @@
<map:selectors default="browser"/>
- <map:matchers default="wildcard">
- <map:matcher name="wildcard"
src="org.apache.cocoon.matching.WildcardURIMatcher"/>
- </map:matchers>
+ <map:matchers default="wildcard"/>
</map:components>
1.4 +2 -3 xml-cocoon2/webapp.tutorial/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp.tutorial/sitemap.xmap,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- sitemap.xmap 2001/10/19 15:28:46 1.3
+++ sitemap.xmap 2001/10/22 10:17:47 1.4
@@ -35,7 +35,7 @@
</map:serializers>
<map:selectors default="browser">
- <map:selector name="browser"
src="org.apache.cocoon.selection.BrowserSelectorFactory">
+ <map:selector name="browser"
src="org.apache.cocoon.selection.BrowserSelector">
<!-- # NOTE: The appearance indicates the search order. This is very
important since
# some words may be found in more than one browser
description. (MSIE is
# presented as "Mozilla/4.0 (Compatible; MSIE 4.01; ...")
@@ -55,8 +55,7 @@
<browser name="mozilla5" useragent="Netscape6/"/>
<browser name="netscape" useragent="Mozilla"/>
</map:selector>
- <map:selector name="coded"
src="org.apache.cocoon.selection.CodedSelectorFactory"/>
- <map:selector name="parameter"
src="org.apache.cocoon.selection.ParameterSelectorFactory"/>
+ <map:selector name="parameter"
src="org.apache.cocoon.selection.ParameterSelector"/>
</map:selectors>
<map:matchers default="wildcard">
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]