You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2001/02/15 22:10:09 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/selection BrowserSelectorFactory.java

bloritsch    01/02/15 13:10:06

  Modified:    src/org/apache/cocoon Tag: xml-cocoon2
                        CocoonComponentSelector.java
                        DefaultComponentManager.java
               src/org/apache/cocoon/matching Tag: xml-cocoon2
                        RegexpTargetHostMatcherFactory.java
                        RegexpURIMatcherFactory.java
                        WildcardURIMatcherFactory.java
               src/org/apache/cocoon/selection Tag: xml-cocoon2
                        BrowserSelectorFactory.java
  Log:
  Fixed problems with Contextualized Components not being contextualized if they
  were in CocoonComponentSelector
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.16  +18 -2     xml-cocoon/src/org/apache/cocoon/Attic/CocoonComponentSelector.java
  
  Index: CocoonComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/CocoonComponentSelector.java,v
  retrieving revision 1.1.2.15
  retrieving revision 1.1.2.16
  diff -u -r1.1.2.15 -r1.1.2.16
  --- CocoonComponentSelector.java	2001/02/12 13:30:42	1.1.2.15
  +++ CocoonComponentSelector.java	2001/02/15 21:09:28	1.1.2.16
  @@ -19,6 +19,8 @@
   import org.apache.avalon.ComponentManagerException;
   import org.apache.avalon.ComponentNotFoundException;
   import org.apache.avalon.ComponentNotAccessibleException;
  +import org.apache.avalon.Context;
  +import org.apache.avalon.Contextualizable;
   import org.apache.avalon.Configurable;
   import org.apache.avalon.Configuration;
   import org.apache.avalon.ConfigurationException;
  @@ -40,14 +42,17 @@
   /** Default component manager for Cocoon's non sitemap components.
    * @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.1.2.15 $ $Date: 2001/02/12 13:30:42 $
  + * @version CVS $Revision: 1.1.2.16 $ $Date: 2001/02/15 21:09:28 $
    */
  -public class CocoonComponentSelector implements ComponentSelector, Composer, Configurable, ThreadSafe, Loggable {
  +public class CocoonComponentSelector implements Contextualizable, ComponentSelector, Composer, Configurable, ThreadSafe, Loggable {
       protected Logger log;
       /** Hashmap of all components which this ComponentManager knows about.
        */
       private Map components;
   
  +    /** The app Context */
  +    private Context context;
  +
       /** Static component instances.
        */
       private Map instances;
  @@ -88,6 +93,12 @@
           }
       }
   
  +    public void contextualize(Context context) {
  +      if (this.context == null) {
  +          this.context = context;
  +      }
  +    }
  +
       /** Return an instance of a component.
        */
       public Component select( Object hint )
  @@ -250,6 +261,11 @@
        */
       private void setupComponent(Object hint, Component c)
       throws ComponentManagerException {
  +
  +        if ( c instanceof Contextualizable ) {
  +            ((Contextualizable)c).contextualize(this.context);
  +        }
  +
           if ( c instanceof Loggable ) {
               ((Loggable)c).setLogger(this.log);
           }
  
  
  
  1.1.2.16  +5 -4      xml-cocoon/src/org/apache/cocoon/Attic/DefaultComponentManager.java
  
  Index: DefaultComponentManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Attic/DefaultComponentManager.java,v
  retrieving revision 1.1.2.15
  retrieving revision 1.1.2.16
  diff -u -r1.1.2.15 -r1.1.2.16
  --- DefaultComponentManager.java	2001/02/14 04:53:25	1.1.2.15
  +++ DefaultComponentManager.java	2001/02/15 21:09:32	1.1.2.16
  @@ -40,7 +40,7 @@
   
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.15 $ $Date: 2001/02/14 04:53:25 $
  + * @version CVS $Revision: 1.1.2.16 $ $Date: 2001/02/15 21:09:32 $
    */
   public class DefaultComponentManager implements ComponentManager, Configurable, Loggable {
   
  @@ -299,12 +299,13 @@
        */
       private void setupComponent(String role, Component c)
       throws ComponentManagerException {
  -        if ( c instanceof Loggable ) {
  -            ((Loggable)c).setLogger(this.log);
  -        }
   
           if ( c instanceof Contextualizable ) {
               ((Contextualizable)c).contextualize(this.context);
  +        }
  +
  +        if ( c instanceof Loggable ) {
  +            ((Loggable)c).setLogger(this.log);
           }
   
           if ( c instanceof Configurable ) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.7   +2 -2      xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpTargetHostMatcherFactory.java
  
  Index: RegexpTargetHostMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpTargetHostMatcherFactory.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- RegexpTargetHostMatcherFactory.java	2001/01/22 21:56:45	1.1.2.6
  +++ RegexpTargetHostMatcherFactory.java	2001/02/15 21:09:43	1.1.2.7
  @@ -27,7 +27,7 @@
    * @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.1.2.6 $ $Date: 2001/01/22 21:56:45 $
  + * @version CVS $Revision: 1.1.2.7 $ $Date: 2001/02/15 21:09:43 $
    */
   
   public class RegexpTargetHostMatcherFactory implements CodeFactory, Loggable {
  @@ -87,7 +87,7 @@
       throws ConfigurationException {
           StringBuffer sb = new StringBuffer ();
           sb.append("HashMap map = new HashMap ();")
  -          .append("String uri = ((HttpServletRequest)objectModel.get(Cocoon.REQUEST_OBJECT)).getHeader(\"Host\");")
  +          .append("String uri = ((HttpServletRequest)objectModel.get(Constants.REQUEST_OBJECT)).getHeader(\"Host\");")
             .append("if(uri.startsWith(\"/\")) uri = uri.substring(1);")
             .append("if(pattern.match(uri)) {");
           /* Handle parenthesised subexpressions. XXX: could be faster if we count
  
  
  
  1.1.2.20  +2 -2      xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpURIMatcherFactory.java
  
  Index: RegexpURIMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/RegexpURIMatcherFactory.java,v
  retrieving revision 1.1.2.19
  retrieving revision 1.1.2.20
  diff -u -r1.1.2.19 -r1.1.2.20
  --- RegexpURIMatcherFactory.java	2001/01/22 21:56:46	1.1.2.19
  +++ RegexpURIMatcherFactory.java	2001/02/15 21:09:47	1.1.2.20
  @@ -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.1.2.19 $ $Date: 2001/01/22 21:56:46 $
  + * @version CVS $Revision: 1.1.2.20 $ $Date: 2001/02/15 21:09:47 $
    */
   
   public class RegexpURIMatcherFactory implements CodeFactory, Loggable {
  @@ -102,7 +102,7 @@
       throws ConfigurationException {
           StringBuffer sb = new StringBuffer ();
           sb.append("HashMap map = new HashMap ();")
  -          .append("String uri = ((HttpServletRequest)objectModel.get(Cocoon.REQUEST_OBJECT)).getRequestURI();")
  +          .append("String uri = ((HttpServletRequest)objectModel.get(Constants.REQUEST_OBJECT)).getRequestURI();")
             .append("if(uri.startsWith(\"/\")) uri = uri.substring(1);")
             .append("if(pattern.match(uri)) {");
             /* Handle parenthesised subexpressions. XXX: could be faster if we count
  
  
  
  1.1.2.28  +3 -3      xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java
  
  Index: WildcardURIMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/matching/Attic/WildcardURIMatcherFactory.java,v
  retrieving revision 1.1.2.27
  retrieving revision 1.1.2.28
  diff -u -r1.1.2.27 -r1.1.2.28
  --- WildcardURIMatcherFactory.java	2001/01/31 15:48:38	1.1.2.27
  +++ WildcardURIMatcherFactory.java	2001/02/15 21:09:50	1.1.2.28
  @@ -24,7 +24,7 @@
    * @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.1.2.27 $ $Date: 2001/01/31 15:48:38 $
  + * @version CVS $Revision: 1.1.2.28 $ $Date: 2001/02/15 21:09:50 $
    */
   
   public class WildcardURIMatcherFactory implements CodeFactory, Loggable {
  @@ -63,9 +63,9 @@
        */
       public String generateMethodSource (NodeIterator conf)
       throws ConfigurationException {
  -               //"String uri = ((org.apache.cocoon.environment.http.HttpRequest) objectModel.get(Cocoon.REQUEST_OBJECT)).getRequestURI();" +
  +               //"String uri = ((org.apache.cocoon.environment.http.HttpRequest) objectModel.get(Constants.REQUEST_OBJECT)).getRequestURI();" +
           return "HashMap map = new HashMap();" +
  -               "String uri = ((HttpServletRequest) objectModel.get(Cocoon.REQUEST_OBJECT)).getRequestURI();" +
  +               "String uri = ((HttpServletRequest) objectModel.get(Constants.REQUEST_OBJECT)).getRequestURI();" +
                  "if (uri.startsWith(\"/\")) uri = uri.substring(1);" +
                  "if (org.apache.cocoon.matching.helpers.WildcardURIMatcher.match (map, uri, pattern)) {" +
                  "return map;" +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.13  +5 -5      xml-cocoon/src/org/apache/cocoon/selection/Attic/BrowserSelectorFactory.java
  
  Index: BrowserSelectorFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/selection/Attic/BrowserSelectorFactory.java,v
  retrieving revision 1.1.2.12
  retrieving revision 1.1.2.13
  diff -u -r1.1.2.12 -r1.1.2.13
  --- BrowserSelectorFactory.java	2000/11/22 12:40:21	1.1.2.12
  +++ BrowserSelectorFactory.java	2001/02/15 21:10:01	1.1.2.13
  @@ -26,7 +26,7 @@
    * @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.1.2.12 $ $Date: 2000/11/22 12:40:21 $
  + * @version CVS $Revision: 1.1.2.13 $ $Date: 2001/02/15 21:10:01 $
   */
   
   
  @@ -70,12 +70,12 @@
       public String generateMethodSource (NodeIterator conf)
       throws ConfigurationException {
           StringBuffer sb = new StringBuffer();
  -         sb.append("if (pattern != null && objectModel.get(Cocoon.REQUEST_OBJECT) != null) {")
  -          .append("javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest) objectModel.get(Cocoon.REQUEST_OBJECT);")
  +         sb.append("if (pattern != null && objectModel.get(Constants.REQUEST_OBJECT) != null) {")
  +          .append("javax.servlet.http.HttpServletRequest request = (javax.servlet.http.HttpServletRequest) objectModel.get(Constants.REQUEST_OBJECT);")
             .append("String userAgent = request.getHeader(\"User-Agent\");")
  -          .append("javax.servlet.http.HttpServletResponse response = (javax.servlet.http.HttpServletResponse) objectModel.get(Cocoon.RESPONSE_OBJECT);")
  +          .append("javax.servlet.http.HttpServletResponse response = (javax.servlet.http.HttpServletResponse) objectModel.get(Constants.RESPONSE_OBJECT);")
             .append("response.addHeader(\"Vary\", \"User-Agent\");")
  -	      .append("for (int i = 0; i < pattern.length; i++) {")
  +          .append("for (int i = 0; i < pattern.length; i++) {")
             .append("if (userAgent.indexOf(pattern[i]) != -1) return true;}");
           return sb.append("} return false;").toString();
       }