You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2001/11/05 14:18:35 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/xml AbstractXMLProducer.java

sylvain     01/11/05 05:18:35

  Modified:    src/org/apache/cocoon/matching
                        RegexpTargetHostMatcherFactory.java
                        RegexpURIMatcherFactory.java
                        WildcardHeaderMatcherFactory.java
                        WildcardParameterValueMatcherFactory.java
                        WildcardSessionAttributeMatcherFactory.java
                        WildcardURIMatcherFactory.java
               src/org/apache/cocoon/selection BrowserSelectorFactory.java
                        HeaderSelectorFactory.java HostSelectorFactory.java
                        ParameterSelectorFactory.java
                        RequestSelectorFactory.java
                        SessionAttributeSelectorFactory.java
               src/org/apache/cocoon/sitemap XSLTFactoryLoader.java
               src/org/apache/cocoon/xml AbstractXMLProducer.java
  Log:
  Removed CodeFactory, rewrote all 'xxxFactory' as subclasses of 'xxx' for backwards compatibility.
  
  Revision  Changes    Path
  1.7       +6 -94     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RegexpTargetHostMatcherFactory.java	2001/10/22 10:17:45	1.6
  +++ RegexpTargetHostMatcherFactory.java	2001/11/05 13:18:34	1.7
  @@ -7,105 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.matching;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
  -import org.apache.cocoon.CodeFactory;
  -import org.apache.regexp.RECompiler;
  -import org.apache.regexp.REProgram;
  -import org.apache.regexp.RESyntaxException;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
  -
   /**
  - * This class generates source code which represents a specific pattern matcher
  - * for request URIs
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2001/10/22 10:17:45 $
  + * @version CVS $Revision: 1.7 $ $Date: 2001/11/05 13:18:34 $
    * @deprecated replaced by RegexpTargetHostMatcher - code factories should no longer be used
    */
  -
  -public class RegexpTargetHostMatcherFactory extends AbstractLoggable implements CodeFactory {
  -
  -    public String generateParameterSource (NodeList conf)
  -    throws ConfigurationException {
  -        return "org.apache.regexp.RE";
  -    }
   
  -    public String generateClassSource (String prefix, String pattern,
  -                                       NodeList conf)
  -    throws ConfigurationException {
  -        StringBuffer sb = new StringBuffer ();
  -        String pat = correctPattern(pattern);
  -        try {
  -            RECompiler r = new RECompiler();
  -            String name         = prefix;
  -            String instructions = name + "PatternInstructions";
  -            sb.append("\n    // Pre-compiled regular expression '")
  -              .append(pat).append("'\n")
  -              .append("    static char[] ");
  -            sb.append(instructions).append(" = \n    {");
  -            REProgram program = r.compile(pat);
  -            int numColumns = 7;
  -            char[] p = program.getInstructions();
  -            for (int j = 0; j < p.length; j++) {
  -                if ((j % numColumns) == 0) {
  -                    sb.append("\n        ");
  -                }
  -                String hex = Integer.toHexString(p[j]);
  -                while (hex.length() < 4) {
  -                    hex = "0" + hex;
  -                }
  -                sb.append("0x").append(hex).append(", ");
  -            }
  -            sb.append("\n    };")
  -              .append("\n    static org.apache.regexp.RE ")
  -              .append(name)
  -              .append("_expr = new org.apache.regexp.RE(new org.apache.regexp.REProgram(")
  -              .append(instructions)
  -              .append("));");
  -            return sb.toString();
  -        } catch (RESyntaxException rse) {
  -            getLogger().warn("Syntax exception while compiling regexp '" + pat + "'.", rse);
  -            throw new ConfigurationException (rse.getMessage(), rse);
  -        }
  +public class RegexpTargetHostMatcherFactory extends RegexpTargetHostMatcher implements Initializable {
  +    
  +    public void initialize() {
  +        getLogger().warn("RegexpTargetHostMatcherFactory is deprecated. Please use RegexpTargetHostMatcher");
       }
   
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -        StringBuffer sb = new StringBuffer ();
  -        sb.append("HashMap map = new HashMap ();")
  -          .append("String host = XSPRequestHelper.getHeader(objectModel,\"Host\");")
  -          .append("getLogger().debug(\"Matching against host: \" + host + \".\");")
  -          .append("if(pattern.match(host)) {");
  -        /* Handle parenthesised subexpressions. XXX: could be faster if we count
  -         * parens *outside* the generated code.
  -         * Note: *ONE* based, not zero.
  -         */
  -        sb.append("int parenCount = pattern.getParenCount();")
  -          .append("for (int paren = 1; paren <= parenCount; paren++) {")
  -          .append("map.put(Integer.toString(paren), pattern.getParen(paren));")
  -          .append("}");
  -        sb.append("return map; } else { return null; }");
  -        return sb.toString();
  -    }
  -
  -    private String correctPattern (String pattern) {
  -        char[] pat = new char[pattern.length()];
  -        pattern.getChars (0, pattern.length(), pat, 0);
  -        int j = 0;
  -        int i = 0;
  -        while (i < pat.length-1) {
  -            if (pat[i] == '\\') {
  -                if (pat[i+1] == '\\') {
  -                    i++;
  -                }
  -            }
  -            pat[j++]=pat[i++];
  -        }
  -        pat[j]=pat[i];
  -        return new String(pat,0,j+1);
  -    }
   }
  
  
  
  1.7       +6 -109    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RegexpURIMatcherFactory.java	2001/10/22 10:17:45	1.6
  +++ RegexpURIMatcherFactory.java	2001/11/05 13:18:34	1.7
  @@ -7,120 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.matching;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
  -import org.apache.cocoon.CodeFactory;
  -import org.apache.regexp.RECompiler;
  -import org.apache.regexp.REProgram;
  -import org.apache.regexp.RESyntaxException;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code which represents a specific pattern matcher
  - * for request URIs
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2001/10/22 10:17:45 $
  + * @version CVS $Revision: 1.7 $ $Date: 2001/11/05 13:18:34 $
    * @deprecated replaced by RegexpURIMatcher - code factories should no longer be used
    */
   
  -public class RegexpURIMatcherFactory extends AbstractLoggable implements CodeFactory {
  -
  -    public String generateParameterSource (NodeList conf)
  -    throws ConfigurationException {
  -        return "org.apache.regexp.RE";
  -    }
  -
  -    public String generateClassSource (String prefix, String pattern,
  -                                       NodeList conf)
  -    throws ConfigurationException {
  -        StringBuffer sb = new StringBuffer ();
  -        try {
  -            RECompiler r = new RECompiler();
  -            String name         = prefix;
  -            String instructions = name + "PatternInstructions";
  -            String pat = correctPattern (pattern);
  -            sb.append("// Pre-compiled regular expression '")
  -              .append(pat).append("'\n")
  -              .append("    static char[] ");
  -            sb.append(instructions).append(" = {");
  -            REProgram program = r.compile(pat);
  -            int numColumns = 7;
  -            char[] p = program.getInstructions();
  -            for (int j = 0; j < p.length; j++) {
  -                if ((j % numColumns) == 0) {
  -                    sb.append("\n");
  -                }
  -                String hex = Integer.toHexString(p[j]);
  -                while (hex.length() < 4) {
  -                    hex = "0" + hex;
  -                }
  -                sb.append("0x").append(hex).append(", ");
  -            }
  -            sb.append("\n};\nstatic org.apache.regexp.RE ")
  -              .append(name)
  -              .append("_expr = new org.apache.regexp.RE(new org.apache.regexp.REProgram(")
  -              .append(instructions)
  -              .append("));\n")
  -              .append("static ArrayList ")
  -              .append(name)
  -              .append("_list = new ArrayList();\n")
  -              .append("static {");
  -            // Count number of parens
  -            int i = 0;
  -            int j = -1;
  -            while ((j = pat.indexOf('(', j+1)) != -1) {
  -                if (j == 0 || pat.charAt(j-1) != '\\') {
  -                    sb.append(name)
  -                      .append("_list.add (")
  -                      .append(name)
  -                      .append("_expr.getParen(")
  -                      .append(++i).append("));");
  -                }
  -            }
  -            sb.append("}");
  -            return sb.toString();
  -        } catch (RESyntaxException rse) {
  -            getLogger().debug("RegexpURIMatcherFactory", rse);
  -            throw new ConfigurationException (rse.getMessage(), rse);
  -        }
  +public class RegexpURIMatcherFactory extends RegexpURIMatcher implements Initializable {
  +    
  +    public void initialize() {
  +        getLogger().warn("RegexpURIMatcherFactory is deprecated. Please use RegexpURIMatcher");
       }
   
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -        StringBuffer sb = new StringBuffer ();
  -        sb.append("HashMap map = new HashMap ();")
  -          .append("String uri = XSPRequestHelper.getSitemapURI(objectModel);")
  -          .append("if(uri.startsWith(\"/\")) uri = uri.substring(1);")
  -          .append("if(pattern.match(uri)) {");
  -          /* Handle parenthesised subexpressions. XXX: could be faster if we count
  -           * parens *outside* the generated code.
  -           * Note: *ONE* based, not zero.
  -           */
  -          sb.append("int parenCount = pattern.getParenCount();")
  -            .append("for (int paren = 1; paren <= parenCount; paren++) {")
  -            .append("map.put(Integer.toString(paren), pattern.getParen(paren));")
  -            .append("}");
  -
  -        sb.append("return map; } else { return null; }");
  -        return sb.toString();
  -    }
  -
  -    private String correctPattern (String pattern) {
  -        char[] pat = new char[pattern.length()];
  -        pattern.getChars (0, pattern.length(), pat, 0);
  -        int j = 0;
  -        int i = 0;
  -        while (i < pat.length-1) {
  -            if (pat[i] == '\\') {
  -                if (pat[i+1] == '\\') {
  -                    i++;
  -                }
  -            }
  -            pat[j++]=pat[i++];
  -        }
  -        pat[j]=pat[i];
  -        return new String(pat,0,j+1);
  -    }
   }
  
  
  
  1.11      +5 -101    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- WildcardHeaderMatcherFactory.java	2001/10/25 20:36:39	1.10
  +++ WildcardHeaderMatcherFactory.java	2001/11/05 13:18:34	1.11
  @@ -7,113 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.matching;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code which represents a specific pattern matcher
  - * for values of request headers, e.g. "referer"
  - *
  - * <p><b>Global and local configuration</b></p>
  - * <table border="1">
  - * <tr><td><code>parameter-name</code></td><td>Name of the request header to
  - * match against</td></tr>
  - * </table>
  - *
  - * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Revision: 1.10 $ $Date: 2001/10/25 20:36:39 $
  + * @version CVS $Revision: 1.11 $ $Date: 2001/11/05 13:18:34 $
    * @deprecated replaced by WildcardHeaderMatcher - code factories should no longer be used
    */
   
  -public class WildcardHeaderMatcherFactory extends WildcardURIMatcherFactory {
  -
  -    public void dumpConfig(NodeList conf) 
  -    { // dump config
  -	if (conf != null) {
  -	    for (int i=0; i<conf.getLength(); i++) {
  -		Node node = conf.item(i);
  -		if (node!=null) {
  -		    if (node.hasChildNodes()){
  -		    	getLogger().debug("<"+node.getNodeName()+">");
  -			try {
  -			    this.dumpConfig(node.getChildNodes());
  -			} catch (Exception e) {
  -			    getLogger().debug(e.toString()+e.getMessage());
  -			}
  -		        getLogger().debug("</>");
  -                    } else {
  -		    	getLogger().debug("<"+node.getNodeName()+"/>");
  -                    }
  -		}
  -	    }
  -	}
  -    }
  +public class WildcardHeaderMatcherFactory extends WildcardHeaderMatcher implements Initializable {
       
  -    /**
  -     * Generates the matcher method level source code
  -     */
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -	
  -        String parameterName = null;
  -
  -	this.dumpConfig(conf);
  -
  -        int count = conf.getLength();
  -        for(int k = 0; k < count;k++) {
  -            Node node = conf.item(k);
  -            if (node != null &&
  -                node.getNodeName() != null && 
  -                node.getNodeName().equals("parameter-name")) 
  -            {
  -                Node textNode = node.getFirstChild();
  -                if (textNode != null) {
  -                    parameterName = textNode.getNodeValue().trim();
  -                }
  -            }
  -        }
  -
  -        StringBuffer sb = new StringBuffer();
  -	sb
  -	    .append("HashMap map = new HashMap(1);")
  -	    .append("String parameterName = null;")
  -	    .append("String parameterValue = null;")
  -	    .append("if (parameters.getNames().length == 0) {");
  -	if ( parameterName == null ) {
  -	    sb
  -		.append("   getLogger().warn(\"No request header name and no default name given. FAILING\");")
  -		.append("} else { ")
  -		.append("  parameterName = parameters.getParameter(\"parameter-name\", null);")
  -		.append("  if ( parameterName == null ) {")
  -		.append("     getLogger().warn(\"No request header name and no default name given. FAILING\");")
  -		.append("  } else {")
  -		.append("     parameterValue = XSPRequestHelper.getHeader(objectModel, parameterName); ")
  -		.append("  }");
  -	} else {
  -	    sb
  -		.append("  parameterName = \"").append(parameterName).append("\";")
  -		.append("  parameterValue = XSPRequestHelper.getHeader(objectModel, parameterName);")
  -		.append("} else { ")
  -		.append("  parameterName = parameters.getParameter(\"parameter-name\", null);")
  -		.append("  if ( parameterName == null ) {")
  -		.append("     getLogger().warn(\"No request header name given, will use default\");")
  -		.append("     parameterName = \"").append(parameterName).append("\";")
  -		.append("  }")
  -		.append("  parameterValue = XSPRequestHelper.getHeader(objectModel, parameterName); ");
  -	}
  -	sb
  -	    .append("}")
  -	    .append("if ( parameterValue == null ) {")
  -	    .append("   getLogger().debug(\"Request header not set\");")
  -	    .append("} else {")
  -	    .append("   if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (map, parameterValue, pattern)) {")
  -	    .append("      map.put(parameterName, parameterValue ); ")   
  -	    .append("      return map;")
  -	    .append("   }")
  -	    .append("}")
  -	    .append("return null;");
  -        return sb.toString();
  +    public void initialize() {
  +        getLogger().warn("WildcardHeaderMatcherFactory is deprecated. Please use WildcardHeaderMatcher");
       }
   
   }
  
  
  
  1.11      +7 -82     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- WildcardParameterValueMatcherFactory.java	2001/10/25 20:36:39	1.10
  +++ WildcardParameterValueMatcherFactory.java	2001/11/05 13:18:34	1.11
  @@ -7,92 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.matching;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code which represents a specific pattern matcher
  - * for request parameters.
  - *
  - * <p> In contrast to the {@link RequestParamMatcher} this matcher
  - * factory generates matchers that match the <b>value</b> of a request
  - * parameter.</p>
  - *
  - * <p><b>Global and local configuration</b></p>
  - * <table border="1">
  - * <tr><td><code>parameter-name</code></td><td>Name of the request parameter to
  - * match against</td></tr>
  - * </table>
  - *
  - * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  + * @version CVS $Revision: 1.11 $ $Date: 2001/11/05 13:18:34 $
    * @deprecated replaced by WildcardParameterValueMatcher - code factories should no longer be used
  - * @version CVS $Revision: 1.10 $ $Date: 2001/10/25 20:36:39 $ */
  + */
   
  -public class WildcardParameterValueMatcherFactory extends WildcardURIMatcherFactory {
  -
  -    /**
  -     * Generates the matcher method level source code
  -     */
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -
  -        String parameterName = null;
  -
  -        int count = conf.getLength();
  -        for(int k = 0; k < count;k++) {
  -            Node node = conf.item(k);
  -            if (node != null &&
  -                node.getNodeName() != null && 
  -                node.getNodeName().equals("parameter-name")) 
  -            {
  -                Node textNode = node.getFirstChild();
  -                if (textNode != null) {
  -                    parameterName = textNode.getNodeValue().trim();
  -                }
  -            }
  -        }
  -
  -        StringBuffer sb = new StringBuffer();
  -	sb
  -	    .append("HashMap map = new HashMap(1);")
  -	    .append("String parameterName = null;")
  -	    .append("String parameterValue = null;")
  -	    .append("if (parameters.getNames().length == 0) {");
  -	if ( parameterName == null ) {
  -	    sb
  -		.append("   getLogger().warn(\"No request parameter name and no default name given. FAILING\");")
  -		.append("} else { ")
  -		.append("  parameterName = parameters.getParameter(\"parameter-name\", null);")
  -		.append("  if ( parameterName == null ) {")
  -		.append("     getLogger().warn(\"No request parameter name and no default name given. FAILING\");")
  -		.append("  } else {")
  -		.append("     parameterValue = XSPRequestHelper.getParameter(objectModel, parameterName, null); ")
  -		.append("  }");
  -	} else {
  -	    sb
  -		.append("  parameterName = \"").append(parameterName).append("\";")
  -		.append("  parameterValue = XSPRequestHelper.getParameter(objectModel, parameterName, null);")
  -		.append("} else { ")
  -		.append("  parameterName = parameters.getParameter(\"parameter-name\", null);")
  -		.append("  if ( parameterName == null ) {")
  -		.append("     getLogger().warn(\"No request parameter name given, will use default\");")
  -		.append("     parameterName = \"").append(parameterName).append("\";")
  -		.append("  }")
  -		.append("  parameterValue = XSPRequestHelper.getParameter(objectModel, parameterName, null); ");
  -	}
  -	sb
  -	    .append("}")
  -	    .append("if ( parameterValue == null ) {")
  -	    .append("   getLogger().debug(\"Request parameter not set\");")
  -	    .append("} else {")
  -	    .append("   if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (map, parameterValue, pattern)) {")
  -	    .append("      map.put(parameterName, parameterValue ); ")   
  -	    .append("      return map;")
  -	    .append("   }")
  -	    .append("}")
  -	    .append("return null;");
  -        return sb.toString();
  +public class WildcardParameterValueMatcherFactory extends WildcardParameterValueMatcher implements Initializable {
  +    
  +    public void initialize() {
  +        getLogger().warn("WildcardParameterValueMatcherFactory is deprecated. Please use WildcardParameterValueMatcher");
       }
   
   }
  
  
  
  1.8       +7 -77     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WildcardSessionAttributeMatcherFactory.java	2001/10/25 20:36:39	1.7
  +++ WildcardSessionAttributeMatcherFactory.java	2001/11/05 13:18:34	1.8
  @@ -7,87 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.matching;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code which represents a specific pattern matcher
  - * for a session attribute.
  - *
  - * <p><b>Global and local configuration</b></p>
  - * <tableborder="1">
  - * <tr><td><code>attribute-name</code></td><td>String identifying the session attribute</td></tr>
  - * </table>
  - *
  - * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/10/25 20:36:39 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/11/05 13:18:34 $
    * @deprecated replaced by WildcardSessionAttributeMatcher - code factories should no longer be used
    */
   
  -public class WildcardSessionAttributeMatcherFactory extends WildcardURIMatcherFactory {
  -
  -    /**
  -     * Generates the matcher method level source code
  -     */
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -
  -        String attributeName=null;
  -        
  -        int count = conf.getLength();
  -        for(int k = 0; k < count;k++) {
  -            Node node = conf.item(k);
  -            if (node != null &&
  -                node.getNodeName() != null && 
  -                node.getNodeName().equals("attribute-name")) 
  -            {
  -                Node textNode = node.getFirstChild();
  -                if (textNode != null) {
  -                    attributeName = textNode.getNodeValue().trim();
  -                }
  -            }
  -        }
  -
  -        StringBuffer sb = new StringBuffer();
  -	sb
  -	    .append("HashMap map = new HashMap(1);")
  -	    .append("String attributeName = null;")
  -	    .append("String attributeValue = null;")
  -	    .append("if (parameters.getNames().length == 0) {");
  -	if ( attributeName == null ) {
  -	    sb
  -		.append("   getLogger().warn(\"No session attribute and no default attribute given. FAILING\");")
  -		.append("} else { ")
  -		.append("  attributeName = parameters.getParameter(\"attribute-name\", null);")
  -		.append("  if ( attributeName == null ) {")
  -		.append("     getLogger().warn(\"No session attribute and no default attribute given. FAILING\");")
  -		.append("  } else {")
  -		.append("     attributeValue = (String) XSPRequestHelper.getSessionAttribute(objectModel, attributeName); ")
  -		.append("  }");
  -	} else {
  -	    sb
  -		.append("  attributeName = \"").append(attributeName).append("\";")
  -		.append("  attributeValue = (String) XSPRequestHelper.getSessionAttribute(objectModel, attributeName);")
  -		.append("} else { ")
  -		.append("  attributeName = parameters.getParameter(\"attribute-name\", null);")
  -		.append("  if ( attributeName == null ) {")
  -		.append("     getLogger().warn(\"No session attribute given, will use default\");")
  -		.append("     attributeName = \"").append(attributeName).append("\";")
  -		.append("  }")
  -		.append("  attributeValue = (String) XSPRequestHelper.getSessionAttribute(objectModel, attributeName); ");
  -	}
  -	sb
  -	    .append("}")
  -	    .append("if ( attributeValue == null ) {")
  -	    .append("   getLogger().debug(\"Session attribute not set\");")
  -	    .append("} else {")
  -	    .append("   if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (map, attributeValue, pattern)) {")
  -	    .append("      map.put(attributeName, attributeValue ); ")   
  -	    .append("      return map;")
  -	    .append("   }")
  -	    .append("}")
  -	    .append("return null;");
  -        return sb.toString();
  +public class WildcardSessionAttributeMatcherFactory extends WildcardSessionAttributeMatcher implements Initializable {
  +    
  +    public void initialize() {
  +        getLogger().warn("WildcardSessionAttributeMatcherFactory is deprecated. Please use WildcardSessionAttributeMatcher");
       }
  +
   }
  
  
  
  1.8       +5 -166    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WildcardURIMatcherFactory.java	2001/10/25 20:36:39	1.7
  +++ WildcardURIMatcherFactory.java	2001/11/05 13:18:34	1.8
  @@ -7,178 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.matching;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
  -import org.apache.cocoon.CodeFactory;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code which represents a specific pattern matcher
  - * for request URIs
  - *
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/10/25 20:36:39 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/11/05 13:18:34 $
    * @deprecated replaced by WildcardURIMatcher - code factories should no longer be used
    */
   
  -public class WildcardURIMatcherFactory extends AbstractLoggable implements CodeFactory {
  +public class WildcardURIMatcherFactory extends WildcardURIMatcher implements Initializable {
   
  -    /** The int representing '*' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_FILE        = -1;
  -    /** The int representing '**' in the pattern <code>int []</code>. */
  -    protected static final int MATCH_PATH        = -2;
  -    /** The int representing begin in the pattern <code>int []</code>. */
  -    protected static final int MATCH_BEGIN        = -4;
  -    /** The int representing end in pattern <code>int []</code>. */
  -    protected static final int MATCH_THEEND        = -5;
  -    /** The int value that terminates the pattern <code>int []</code>. */
  -    protected static final int MATCH_END        = -3;
  -
  -    /** The <code>int []</code> identifying the pattern to match. */
  -    protected int[] sourcePattern = null;
  -
  -    /**
  -     * Generates the matcher parameter level source code
  -     */
  -    public String generateParameterSource (NodeList conf)
  -    throws ConfigurationException {
  -        return "int []";
  +    public void initialize() {
  +        getLogger().warn("WildcardURIMatcherFactory is deprecated. Please use WildcardURIMatcher");
       }
   
  -    /**
  -     * Generates the matcher method level source code
  -     */
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -        return new StringBuffer("HashMap map = new HashMap();")
  -                .append("String uri = XSPRequestHelper.getSitemapURI(objectModel);")
  -                .append("if (uri.startsWith(\"/\")) uri = uri.substring(1);")
  -                .append("if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (map, uri, pattern)) {")
  -                .append("return map;").append("} else {")
  -                .append("return null;}").toString();
  -    }
  -
  -    /**
  -     * Generates the matcher class level source code
  -     */
  -    public String generateClassSource (String prefix, String pattern,
  -                                       NodeList conf)
  -    throws ConfigurationException {
  -        StringBuffer result = new StringBuffer();
  -        try {
  -            this.setPattern (pattern);
  -
  -            result.append ("\n// wildcard pattern = \"").append(pattern).append("\"\n\t")
  -                  .append ("static int[] ").append(prefix).append("_expr = {");
  -
  -            int j = sourcePattern.length - 1;
  -            for (int i = 0; i < j; i++) {
  -                result.append (sourcePattern[i])
  -                      .append (',');
  -            }
  -            return result.append (sourcePattern[j])
  -                         .append ("};\n").toString();
  -        } catch (NullPointerException pe) {
  -            getLogger().error("WildcardURIMatcherFactory:NULL", pe);
  -            throw new ConfigurationException (pe.getMessage(), pe);
  -        }
  -    }
  -
  -    /**
  -     * Set the pattern for matching.
  -     */
  -    public void setPattern(String pattern)
  -    throws NullPointerException {
  -        if (pattern == null) throw new NullPointerException("Pattern cannot be null");
  -        this.sourcePattern = this.convertPattern(pattern);
  -    }
  -
  -    /**
  -     * Translate the given <code>String</code> into a <code>int []</code>
  -     * representing the pattern matchable by this class.
  -     * <br>
  -     * This function translates a <code>String</code> into an int array
  -     * converting the special '*' and '\' characters.
  -     * <br>
  -     * Here is how the conversion algorithm works:
  -     * <ul>
  -     *   <li>The '*' character is converted to MATCH_FILE, meaning that zero
  -     *        or more characters (excluding the path separator '/') are to
  -     *        be matched.</li>
  -     *   <li>The '**' sequence is converted to MATCH_PATH, meaning that zero
  -     *       or more characters (including the path separator '/') are to
  -     *        be matched.</li>
  -     *   <li>The '\' character is used as an escape sequence ('\*' is
  -     *       translated in '*', not in MATCH_FILE). If an exact '\' character
  -     *       is to be matched the source string must contain a '\\'.
  -     *       sequence.</li>
  -     * </ul>
  -     * When more than two '*' characters, not separated by another character,
  -     * are found their value is considered as '**' (MATCH_PATH).
  -     * <br>
  -     * The array is always terminated by a special value (MATCH_END).
  -     * <br>
  -     * All MATCH* values are less than zero, while normal characters are equal
  -     * or greater.
  -     *
  -     * @parameter data The string to translate.
  -     * @return The encoded string as an int array, terminated by the MATCH_END
  -     *         value (don't consider the array length).
  -     * @exception NullPointerException If data is null.
  -     */
  -    protected int[] convertPattern(String data)
  -    throws NullPointerException {
  -
  -        // Prepare the arrays
  -        int expr[] = new int[data.length() + 2];
  -        char buff[] = data.toCharArray();
  -
  -        // Prepare variables for the translation loop
  -        int y = 0;
  -        boolean slash = false;
  -
  -        // Must start from beginning
  -        expr[y++] = MATCH_BEGIN;
  -
  -        if (buff.length > 0) {
  -            if (buff[0]=='\\') {
  -                slash = true;
  -            } else if (buff[0] == '*') {
  -                expr[y++] = MATCH_FILE;
  -            }  else {
  -                expr[y++] = buff[0];
  -            }
  -
  -            // Main translation loop
  -            for (int x = 1; x < buff.length; x++) {
  -                // If the previous char was '\' simply copy this char.
  -                if (slash) {
  -                    expr[y++] = buff[x];
  -                    slash = false;
  -                // If the previous char was not '\' we have to do a bunch of checks
  -                } else {
  -                    // If this char is '\' declare that and continue
  -                    if (buff[x] == '\\') {
  -                        slash = true;
  -                    // If this char is '*' check the previous one
  -                    } else if (buff[x] == '*') {
  -                        // If the previous character als was '*' match a path
  -                        if (expr[y-1] <= MATCH_FILE) {
  -                            expr[y-1] = MATCH_PATH;
  -                        } else {
  -                            expr[y++] = MATCH_FILE;
  -                        }
  -                    } else {
  -                        expr[y++]=buff[x];
  -                    }
  -                }
  -            }
  -        }
  -
  -        // Must match end at the end
  -        expr[y] = MATCH_THEEND;
  -        return expr;
  -    }
   }
  
  
  
  1.8       +5 -61     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BrowserSelectorFactory.java	2001/10/22 10:17:46	1.7
  +++ BrowserSelectorFactory.java	2001/11/05 13:18:35	1.8
  @@ -7,73 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.selection;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.cocoon.CodeFactory;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code which tests a specific browser pattern
  - * agains the requesting user-agent
  - *
  - * @author <a href="mailto:cziegeler@sundn.de">Carsten Ziegeler</a>
  - * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
  - * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/10/22 10:17:46 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/11/05 13:18:35 $
    * @deprecated replaced by BrowserSelector - code factories should no longer be used
    */
   
  +public class BrowserSelectorFactory extends BrowserSelector implements Initializable {
   
  -public class BrowserSelectorFactory implements CodeFactory {
  -
  -    public String generateParameterSource (NodeList conf)
  -    throws ConfigurationException {
  -        return "String []";
  -    }
  -
  -    public String generateClassSource (String prefix, String test, NodeList conf)
  -    throws ConfigurationException {
  -        Node node = null;
  -        Node nodeattrname  = null;
  -        Node nodeattruseragent = null;
  -        NamedNodeMap nm = null;
  -        int cnt = 0;
  -        StringBuffer sb = new StringBuffer();
  -        sb.append("static String [] ")
  -          .append(prefix)
  -          .append("_expr = {");
  -        int count = conf.getLength();
  -        for(int k = 0; k < count;k++) {
  -            node = conf.item(k);
  -            if (node != null &&
  -                node.getNodeName().equals("browser") &&
  -                node.getNodeType() == Node.ELEMENT_NODE) {
  -                nm = node.getAttributes();
  -                if (nm != null) {
  -                    nodeattrname = nm.getNamedItem("name");
  -                    nodeattruseragent = nm.getNamedItem("useragent");
  -                    if (nodeattrname != null && nodeattruseragent != null
  -                            && nodeattrname.getNodeValue().equals(test)) {
  -                        sb.append(cnt++==0 ? "\"" : ",\"")
  -                          .append(nodeattruseragent.getNodeValue())
  -                          .append("\"");
  -                    }
  -                }
  -            }
  -        }
  -        return sb.append("};").toString();
  +    public void initialize() {
  +        getLogger().warn("BrowserSelectorFactory is deprecated. Please use BrowserSelector");
       }
   
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -        StringBuffer sb = new StringBuffer();
  -         sb.append("if (pattern != null && objectModel.get(Constants.REQUEST_OBJECT) != null) {")
  -          .append("String userAgent = XSPRequestHelper.getHeader(objectModel,\"User-Agent\");")
  -          .append("if(null == userAgent)\nreturn false;")
  -          .append("XSPResponseHelper.addHeader(objectModel, \"Vary\", \"User-Agent\");")
  -          .append("for (int i = 0; i < pattern.length; i++) {")
  -          .append("if (userAgent.indexOf(pattern[i]) != -1) return true;}");
  -        return sb.append("} return false;").toString();
  -    }
   }
  
  
  
  1.10      +6 -65     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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HeaderSelectorFactory.java	2001/10/25 20:36:40	1.9
  +++ HeaderSelectorFactory.java	2001/11/05 13:18:35	1.10
  @@ -7,76 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.selection;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code to implement a selector 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>parameter-name</code></td><td>Name of the request header to
  - * match against</td></tr>
  - * </table>
  - *
  - * @author <a href="mailto:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Revision: 1.9 $ $Date: 2001/10/25 20:36:40 $
  + * @version CVS $Revision: 1.10 $ $Date: 2001/11/05 13:18:35 $
    * @deprecated replaced by HeaderSelector - code factories should no longer be used
    */
  -public class HeaderSelectorFactory extends ParameterSelectorFactory {
   
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  +public class HeaderSelectorFactory extends HeaderSelector implements Initializable {
   
  -        String parameterName = null;
  -
  -        int count = conf.getLength();
  -        for(int k = 0; k < count;k++) {
  -            Node node = conf.item(k);
  -            if (node != null &&
  -                node.getNodeName() != null && 
  -                node.getNodeName().equals("parameter-name")) 
  -            {
  -                Node textNode = node.getFirstChild();
  -                if (textNode != null) {
  -                    parameterName = textNode.getNodeValue().trim();
  -                }
  -            }
  -        }
  -
  -        StringBuffer sb = new StringBuffer();
  -	sb
  -	    .append("String compareToString = null;")
  -	    .append("if (param.getNames().length == 0) {");
  -	if ( parameterName == null ) {
  -	    sb
  -		.append("   getLogger().warn(\"No request header name and no default name given. FAILING\");")
  -		.append("} else { ")
  -		.append("  String parameterName = param.getParameter(\"parameter-name\", null);")
  -		.append("  if ( parameterName == null ) {")
  -		.append("     getLogger().warn(\"No request header name and no default name given. FAILING\");")
  -		.append("  } else {")
  -		.append("     compareToString = (String) XSPRequestHelper.getHeader(objectModel, parameterName);")
  -		.append("  }");
  -	} else {
  -	    sb
  -		.append("  compareToString = (String) XSPRequestHelper.getHeader(objectModel, \"").append(parameterName).append("\");")
  -		.append("} else { ")
  -		.append("  String parameterName = param.getParameter(\"parameter-name\", null);")
  -		.append("  if ( parameterName == null ) {")
  -		.append("     getLogger().warn(\"No request header name given, will use default\");")
  -		.append("     parameterName = \"").append(parameterName).append("\";")
  -		.append("  }")
  -		.append("  compareToString = (String) XSPRequestHelper.getHeader(objectModel, parameterName);");
  -	}
  -	sb
  -	    .append("}")
  -	    .append("if ( compareToString == null ) {")
  -	    .append("   getLogger().debug(\"request header not set\");")
  -	    .append("}")
  -	    .append("return compareToString != null && compareToString.equals (pattern);");
  -        return sb.toString();
  +    public void initialize() {
  +        getLogger().warn("HeaderSelectorFactory is deprecated. Please use HeaderSelector");
       }
  +
   }
  
  
  
  1.8       +5 -72     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- HostSelectorFactory.java	2001/10/22 10:17:46	1.7
  +++ HostSelectorFactory.java	2001/11/05 13:18:35	1.8
  @@ -7,84 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.selection;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.cocoon.CodeFactory;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code to implement a selector 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:cbritton@centervilletech.com">Colin Britton</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/10/22 10:17:46 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/11/05 13:18:35 $
    * @deprecated replaced by HostSelector - code factories should no longer be used
    */
   
  +public class HostSelectorFactory extends HostSelector implements Initializable {
   
  -public class HostSelectorFactory implements CodeFactory {
  -
  -    public String generateParameterSource (NodeList conf)
  -    throws ConfigurationException {
  -        return "String []";
  -    }
  -
  -    public String generateClassSource (String prefix, String test, NodeList conf)
  -    throws ConfigurationException {
  -        Node node = null;
  -        Node nodeattrname  = null;
  -        Node nodeattrhost = null;
  -        NamedNodeMap nm = null;
  -        int cnt = 0;
  -        StringBuffer sb = new StringBuffer();
  -        sb.append("static String [] ")
  -          .append(prefix)
  -          .append("_expr = {");
  -        int count = conf.getLength();
  -        for(int k = 0; k < count;k++) {
  -            node = conf.item(k);
  -            if (node != null &&
  -                node.getNodeName().equals("host") &&
  -                node.getNodeType() == Node.ELEMENT_NODE) {
  -                nm = node.getAttributes();
  -                if (nm != null) {
  -                    nodeattrname = nm.getNamedItem("name");
  -                    nodeattrhost = nm.getNamedItem("value");
  -                    if (nodeattrname != null && nodeattrhost != null
  -                            && nodeattrname.getNodeValue().equals(test)) {
  -                        sb.append(cnt++==0 ? "\"" : ",\"")
  -                          .append(nodeattrhost.getNodeValue())
  -                          .append("\"");
  -                    }
  -                }
  -            }
  -        }
  -        return sb.append("};").toString();
  +    public void initialize() {
  +        getLogger().warn("HostSelectorFactory is deprecated. Please use HostSelector");
       }
   
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -        StringBuffer sb = new StringBuffer();
  -         sb.append("if (pattern != null && objectModel.get(Constants.REQUEST_OBJECT) != null) {")
  -          .append("String hostServer = XSPRequestHelper.getHeader(objectModel, \"host\");")
  -          .append("XSPResponseHelper.addHeader(objectModel, \"Vary\", \"host\");")
  -          .append("for (int i = 0; i < pattern.length; i++) {")
  -          .append("if (hostServer.indexOf(pattern[i]) != -1) return true;}");
  -        return sb.append("} return false;").toString();
  -    }
   }
  
  
  
  1.7       +6 -50     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ParameterSelectorFactory.java	2001/10/22 10:17:46	1.6
  +++ ParameterSelectorFactory.java	2001/11/05 13:18:35	1.7
  @@ -7,62 +7,18 @@
    *****************************************************************************/
   package org.apache.cocoon.selection;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.cocoon.CodeFactory;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.logger.Loggable;
  +import org.apache.log.Logger;
   
   /**
  - * This class generates source code to implement a selector that
  - * matches a string in the parameters object passed to it.
  - *
  - * <pre>
  - *  &lt;map:selector name="parameter" factory="org.apache.cocoon.selection.ParameterSelectorFactory"/&gt;
  - *
  - *   &lt;map:select type="parameter"&gt;
  - *      &lt;parameter name="parameter-selector-test" value="{$mySitemapParameter}"/&gt;
  - *      &lt;map:when test="myParameterValue"&gt;
  - *         &lt;!-- executes iff {$mySitemapParameter} == "myParameterValue" --&gt;
  - *         &lt;map:transform src="stylesheets/page/uk.xsl"/&gt;
  - *      &lt;/map:when&gt;
  - *      &lt;map:otherwise&gt;
  - *         &lt;map:transform src="stylesheets/page/us.xsl"/&gt;
  - *      &lt;/map:otherwise&gt;
  - *   &lt;/map:select&gt;
  - * </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:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2001/10/22 10:17:46 $
  + * @version CVS $Revision: 1.7 $ $Date: 2001/11/05 13:18:35 $
    * @deprecated replaced by ParameterSelector - code factories should no longer be used
    */
  -public class ParameterSelectorFactory implements CodeFactory {
   
  -    public String generateParameterSource (NodeList conf)
  -    throws ConfigurationException {
  -        return "String ";
  -    }
  +public class ParameterSelectorFactory extends ParameterSelector implements Loggable {
   
  -    public String generateClassSource (String prefix, String test, NodeList conf)
  -    throws ConfigurationException {
  -		StringBuffer sb = new StringBuffer ();
  -        sb.append("static String ")
  -            .append(prefix)
  -            .append("_expr = \"")
  -			.append (test)
  -			.append ("\";");
  -        return sb.toString();
  +    public void setLogger(Logger logger) {
  +        logger.warn("ParameterSelectorFactory is deprecated. Please use ParameterSelector");
       }
   
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  -        StringBuffer sb = new StringBuffer();
  -         sb.append("if (param != null) {")
  -          .append("String compareToString = param.getParameter (\"parameter-selector-test\", null);")
  -          .append("return compareToString != null && compareToString.equals (pattern);")
  -          .append("} return false;");
  -        return sb.toString();
  -    }
   }
  
  
  
  1.10      +6 -65     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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RequestSelectorFactory.java	2001/10/25 20:36:40	1.9
  +++ RequestSelectorFactory.java	2001/11/05 13:18:35	1.10
  @@ -7,76 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.selection;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * This class generates source code to implement a selector 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:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Revision: 1.9 $ $Date: 2001/10/25 20:36:40 $
  + * @version CVS $Revision: 1.10 $ $Date: 2001/11/05 13:18:35 $
    * @deprecated replaced by RequestSelector - code factories should no longer be used
    */
  -public class RequestSelectorFactory extends ParameterSelectorFactory {
   
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  +public class RequestSelectorFactory extends RequestSelector implements Initializable {
   
  -        String parameterName = null;
  -
  -        int count = conf.getLength();
  -        for(int k = 0; k < count;k++) {
  -            Node node = conf.item(k);
  -            if (node != null &&
  -                node.getNodeName() != null && 
  -                node.getNodeName().equals("parameter-name")) 
  -            {
  -                Node textNode = node.getFirstChild();
  -                if (textNode != null) {
  -                    parameterName = textNode.getNodeValue().trim();
  -                }
  -            }
  -        }
  -
  -        StringBuffer sb = new StringBuffer();
  -	sb
  -	    .append("String compareToString = null;")
  -	    .append("if (param.getNames().length == 0) {");
  -	if ( parameterName == null ) {
  -	    sb
  -		.append("   getLogger().warn(\"No request parameter name and no default request parameter name given. FAILING\");")
  -		.append("} else { ")
  -		.append("  String parameterName = param.getParameter(\"parameter-name\", null);")
  -		.append("  if ( parameterName == null ) {")
  -		.append("     getLogger().warn(\"No request parameter name and no default request parameter name given. FAILING\");")
  -		.append("  } else {")
  -		.append("     compareToString = (String) XSPRequestHelper.getParameter(objectModel, parameterName, null);")
  -		.append("  }");
  -	} else {
  -	    sb
  -		.append("  compareToString = (String) XSPRequestHelper.getParameter(objectModel, \"").append(parameterName).append("\", null);")
  -		.append("} else { ")
  -		.append("  String parameterName = param.getParameter(\"parameter-name\", null);")
  -		.append("  if ( parameterName == null ) {")
  -		.append("     getLogger().warn(\"No request parameter name given, will use default\");")
  -		.append("     parameterName = \"").append(parameterName).append("\";")
  -		.append("  }")
  -		.append("  compareToString = (String) XSPRequestHelper.getParameter(objectModel, parameterName, null);");
  -	}
  -	sb
  -	    .append("}")
  -	    .append("if ( compareToString == null ) {")
  -	    .append("   getLogger().debug(\"request parameter not set\");")
  -	    .append("}")
  -	    .append("return compareToString != null && compareToString.equals (pattern);");
  -        return sb.toString();
  +    public void initialize() {
  +        getLogger().warn("RequestSelectorFactory is deprecated. Please use RequestSelector");
       }
  +
   }
  
  
  
  1.7       +6 -64     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SessionAttributeSelectorFactory.java	2001/10/25 20:36:40	1.6
  +++ SessionAttributeSelectorFactory.java	2001/11/05 13:18:35	1.7
  @@ -7,75 +7,17 @@
    *****************************************************************************/
   package org.apache.cocoon.selection;
   
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.w3c.dom.Node;
  -import org.w3c.dom.NodeList;
  +import org.apache.avalon.framework.activity.Initializable;
   
   /**
  - * 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:haul@informatik.tu-darmstadt.de">Christian Haul</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2001/10/25 20:36:40 $
  + * @version CVS $Revision: 1.7 $ $Date: 2001/11/05 13:18:35 $
    * @deprecated replaced by SessionAttributeSelector - code factories should no longer be used
    */
  -public class SessionAttributeSelectorFactory extends ParameterSelectorFactory {
   
  -    public String generateMethodSource (NodeList conf)
  -    throws ConfigurationException {
  +public class SessionAttributeSelectorFactory extends SessionAttributeSelector implements Initializable {
   
  -        String attributeName = null;
  -        
  -        int count = conf.getLength();
  -        for(int k = 0; k < count;k++) {
  -            Node node = conf.item(k);
  -            if (node != null &&
  -                node.getNodeName() != null && 
  -                node.getNodeName().equals("attribute-name")) 
  -            {
  -                Node textNode = node.getFirstChild();
  -                if (textNode != null) {
  -                    attributeName = textNode.getNodeValue().trim();
  -                }
  -            }
  -        }
  -
  -        StringBuffer sb = new StringBuffer();
  -	sb
  -	    .append("String compareToString = null;")
  -	    .append("if (param.getNames().length == 0) {");
  -	if ( attributeName == null ) {
  -	    sb
  -		.append("   getLogger().warn(\"No session attribute and no default attribute given. FAILING\");")
  -		.append("} else { ")
  -		.append("  String attributeName = param.getParameter(\"attribute-name\", null);")
  -		.append("  if ( attributeName == null ) {")
  -		.append("     getLogger().warn(\"No session attribute and no default attribute given. FAILING\");")
  -		.append("  } else {")
  -		.append("     compareToString = (String) XSPRequestHelper.getSessionAttribute(objectModel, attributeName); ")
  -		.append("  }");
  -	} else {
  -	    sb
  -		.append("  compareToString = (String) XSPRequestHelper.getSessionAttribute(objectModel, \"").append(attributeName).append("\");")
  -		.append("} else { ")
  -		.append("  String attributeName = param.getParameter(\"attribute-name\", null);")
  -		.append("  if ( attributeName == null ) {")
  -		.append("     getLogger().warn(\"No session attribute given, will use default\");")
  -		.append("     attributeName = \"").append(attributeName).append("\";")
  -		.append("  }")
  -		.append("  compareToString = (String) XSPRequestHelper.getSessionAttribute(objectModel, attributeName); ");
  -	}
  -	sb
  -	    .append("}")
  -	    .append("if ( compareToString == null ) {")
  -	    .append("   getLogger().debug(\"Session attribute not set\");")
  -	    .append("}")
  -	    .append("return compareToString != null && compareToString.equals (pattern);");
  -        return sb.toString();
  +    public void initialize() {
  +        getLogger().warn("SessionAttributeSelectorFactory is deprecated. Please use SessionAttributeSelector");
       }
  +
   }
  
  
  
  1.12      +84 -69    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XSLTFactoryLoader.java	2001/10/24 09:33:04	1.11
  +++ XSLTFactoryLoader.java	2001/11/05 13:18:35	1.12
  @@ -9,7 +9,7 @@
   package org.apache.cocoon.sitemap;
   
   import org.apache.avalon.framework.logger.Loggable;
  -import org.apache.cocoon.CodeFactory;
  +//import org.apache.cocoon.CodeFactory;
   import org.apache.cocoon.util.ClassUtils;
   import org.apache.log.Logger;
   import org.w3c.dom.NodeList;
  @@ -26,7 +26,7 @@
    *
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.11 $ $Date: 2001/10/24 09:33:04 $
  + * @version CVS $Revision: 1.12 $ $Date: 2001/11/05 13:18:35 $
    */
   public class XSLTFactoryLoader {
       protected static Logger log;
  @@ -34,24 +34,28 @@
   
       public String getClassSource(String className, String prefix, String pattern, NodeList conf) throws ClassNotFoundException,
           InstantiationException, IllegalAccessException, Exception {
  -        try {
  -            Object factory = obj.get(className);
  -            if (factory == null) {
  -                factory = ClassUtils.newInstance(className);
  -            }
  -            obj.put(className, factory);
  -            if (factory instanceof Loggable) {
  -                ((Loggable)factory).setLogger(XSLTFactoryLoader.log);
  -            }
  -            if (factory instanceof CodeFactory) {
  -                return ((CodeFactory)factory).generateClassSource(prefix, pattern, conf);
  -            }
  -            throw new Exception("Wrong class \"" + factory.getClass().getName() +
  -                "\". Should implement the CodeFactory interface");
  -        } catch (RuntimeException re){
  -            log.debug("Exception in XSLTFactoryLoader.getMethodSource calling className:" + className, re);
  -            throw re;
  -        }
  +            
  +        throw new UnsupportedOperationException("CodeFactory is no longer supported.");
  +        
  +// CodeFactory handling code - now removed.
  +//        try {
  +//            Object factory = obj.get(className);
  +//            if (factory == null) {
  +//                factory = ClassUtils.newInstance(className);
  +//            }
  +//            obj.put(className, factory);
  +//            if (factory instanceof Loggable) {
  +//                ((Loggable)factory).setLogger(XSLTFactoryLoader.log);
  +//            }
  +//            if (factory instanceof CodeFactory) {
  +//                return ((CodeFactory)factory).generateClassSource(prefix, pattern, conf);
  +//            }
  +//            throw new Exception("Wrong class \"" + factory.getClass().getName() +
  +//                "\". Should implement the CodeFactory interface");
  +//        } catch (RuntimeException re){
  +//            log.debug("Exception in XSLTFactoryLoader.getMethodSource calling className:" + className, re);
  +//            throw re;
  +//        }
       }
   
       public static void setLogger(Logger logger) {
  @@ -62,62 +66,73 @@
   
       public String getParameterSource(String className, NodeList conf) throws ClassNotFoundException, InstantiationException,
           IllegalAccessException, Exception {
  -        try {
  -            Object factory = obj.get(className);
  -            if (factory == null) {
  -                factory = ClassUtils.newInstance(className);
  -            }
  -            obj.put(className, factory);
  -            if (factory instanceof Loggable) {
  -                ((Loggable)factory).setLogger(XSLTFactoryLoader.log);
  -            }
  -            if (factory instanceof CodeFactory) {
  -                return ((CodeFactory)factory).generateParameterSource(conf);
  -            }
  -            throw new Exception("Wrong class \"" + factory.getClass().getName() +
  -                "\". Should implement the CodeFactory interface");
  -        } catch (RuntimeException re){
  -            log.debug("Exception in XSLTFactoryLoader.getMethodSource calling className:" + className, re);
  -            throw re;
  -        }
  +            
  +        throw new UnsupportedOperationException("CodeFactory is no longer supported.");
  +        
  +// CodeFactory handling code - now removed.
  +//        try {
  +//            Object factory = obj.get(className);
  +//            if (factory == null) {
  +//                factory = ClassUtils.newInstance(className);
  +//            }
  +//            obj.put(className, factory);
  +//            if (factory instanceof Loggable) {
  +//                ((Loggable)factory).setLogger(XSLTFactoryLoader.log);
  +//            }
  +//            if (factory instanceof CodeFactory) {
  +//                return ((CodeFactory)factory).generateParameterSource(conf);
  +//            }
  +//            throw new Exception("Wrong class \"" + factory.getClass().getName() +
  +//                "\". Should implement the CodeFactory interface");
  +//        } catch (RuntimeException re){
  +//            log.debug("Exception in XSLTFactoryLoader.getMethodSource calling className:" + className, re);
  +//            throw re;
  +//        }
       }
   
       public String getMethodSource(String className, NodeList conf) throws ClassNotFoundException, InstantiationException,
           IllegalAccessException, Exception {
  -        try {
  -            Object factory = obj.get(className);
  -            if (factory == null) {
  -                factory = ClassUtils.newInstance(className);
  -            }
  -            obj.put(className, factory);
  -            if (factory instanceof Loggable) {
  -                ((Loggable)factory).setLogger(XSLTFactoryLoader.log);
  -            }
  -            if (factory instanceof CodeFactory) {
  -                return ((CodeFactory)factory).generateMethodSource(conf);
  -            }
  -            throw new Exception("Wrong class \"" + factory.getClass().getName() +
  -                "\". Should implement the CodeFactory interface");
  -        } catch (RuntimeException re){
  -            log.debug("Exception in XSLTFactoryLoader.getMethodSource calling className:" + className, re);
  -            throw re;
  -        }
  +            
  +        throw new UnsupportedOperationException("CodeFactory is no longer supported.");
  +        
  +// CodeFactory handling code - now removed.
  +//        try {
  +//            Object factory = obj.get(className);
  +//            if (factory == null) {
  +//                factory = ClassUtils.newInstance(className);
  +//            }
  +//            obj.put(className, factory);
  +//            if (factory instanceof Loggable) {
  +//                ((Loggable)factory).setLogger(XSLTFactoryLoader.log);
  +//            }
  +//            if (factory instanceof CodeFactory) {
  +//                return ((CodeFactory)factory).generateMethodSource(conf);
  +//            }
  +//            throw new Exception("Wrong class \"" + factory.getClass().getName() +
  +//                "\". Should implement the CodeFactory interface");
  +//        } catch (RuntimeException re){
  +//            log.debug("Exception in XSLTFactoryLoader.getMethodSource calling className:" + className, re);
  +//            throw re;
  +//        }
       }
   
       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;
  +        return false;
  +        
  +// CodeFactory handling code - now removed.
  +//        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;
       }
   
       /**
  
  
  
  1.5       +3 -2      xml-cocoon2/src/org/apache/cocoon/xml/AbstractXMLProducer.java
  
  Index: AbstractXMLProducer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/xml/AbstractXMLProducer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractXMLProducer.java	2001/10/11 07:28:25	1.4
  +++ AbstractXMLProducer.java	2001/11/05 13:18:35	1.5
  @@ -7,6 +7,7 @@
    *****************************************************************************/
   package org.apache.cocoon.xml;
   
  +import org.apache.avalon.excalibur.pool.Recyclable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.ext.LexicalHandler;
  @@ -17,9 +18,9 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.4 $ $Date: 2001/10/11 07:28:25 $
  + * @version CVS $Revision: 1.5 $ $Date: 2001/11/05 13:18:35 $
    */
  -public abstract class AbstractXMLProducer extends AbstractLoggable implements XMLProducer {
  +public abstract class AbstractXMLProducer extends AbstractLoggable implements XMLProducer, Recyclable {
   
       /** The <code>XMLConsumer</code> receiving SAX events. */
       protected XMLConsumer xmlConsumer;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org