cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler SimpleSitemapExecutor.java
Date Thu, 17 Jun 2004 13:52:35 GMT
cziegeler    2004/06/17 06:52:35

  Modified:    src/java/org/apache/cocoon/components/treeprocessor/sitemap
                        SelectNode.java
               src/java/org/apache/cocoon/sitemap SitemapExecutor.java
               src/java/org/apache/cocoon/sitemap/impl DefaultExecutor.java
               src/blocks/profiler/java/org/apache/cocoon/components/profiler
                        SimpleSitemapExecutor.java
  Log:
  Add selector to profiling
  
  Revision  Changes    Path
  1.4       +17 -8     cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNode.java
  
  Index: SelectNode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNode.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SelectNode.java	5 Mar 2004 13:02:52 -0000	1.3
  +++ SelectNode.java	17 Jun 2004 13:52:35 -0000	1.4
  @@ -68,6 +68,9 @@
           this.otherwhiseNodes = otherwhiseNodes;
       }
   
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)
  +     */
       public void compose(ComponentManager manager) throws ComponentException {
           this.manager = manager;
           setSelector((ComponentSelector)manager.lookup(Selector.ROLE + "Selector"));
  @@ -76,6 +79,9 @@
           this.threadSafeSelector = (Selector)this.getThreadSafeComponent();
       }
   
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.components.treeprocessor.ProcessingNode#invoke(org.apache.cocoon.environment.Environment,
org.apache.cocoon.components.treeprocessor.InvokeContext)
  +     */
       public final boolean invoke(Environment env, InvokeContext context)
       throws Exception {
   
  @@ -83,16 +89,16 @@
           super.invoke(env, context);
   
           // Prepare data needed by the action
  -        Map objectModel = env.getObjectModel();
  -        Parameters resolvedParams = VariableResolver.buildParameters(this.parameters, context,
objectModel);
  +        final Map objectModel = env.getObjectModel();
  +        final Parameters resolvedParams = VariableResolver.buildParameters(this.parameters,
context, objectModel);
   
           // If selector is ThreadSafe, avoid select() and try/catch block (faster !)
           if (this.threadSafeSelector != null) {
   
               for (int i = 0; i < this.whenTests.length; i++) {
  -                if (this.threadSafeSelector.select(
  +                if ( this.executor.invokeSelector(this, objectModel,
  +                        this.threadSafeSelector,
                           whenTests[i].resolve(context, objectModel),
  -                        objectModel,
                           resolvedParams)) {
                       return invokeNodes(this.whenNodes[i], env, context);
                   }
  @@ -105,13 +111,13 @@
               return false;
   
           } else {
  -            Selector selector = (Selector)this.selector.select(this.componentName);
  +            final Selector selector = (Selector)this.selector.select(this.componentName);
               try {
   
                   for (int i = 0; i < this.whenTests.length; i++) {
  -                    if (selector.select(
  +                    if ( this.executor.invokeSelector(this, objectModel,
  +                            selector,
                               whenTests[i].resolve(context, objectModel),
  -                            objectModel,
                               resolvedParams)) {
                           return invokeNodes(this.whenNodes[i], env, context);
                       }
  @@ -128,6 +134,9 @@
           }
       }
   
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.framework.activity.Disposable#dispose()
  +     */
       public void dispose() {
           if (this.threadSafeSelector != null) {
               this.selector.release(this.threadSafeSelector);
  
  
  
  1.4       +21 -5     cocoon-2.1/src/java/org/apache/cocoon/sitemap/SitemapExecutor.java
  
  Index: SitemapExecutor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/sitemap/SitemapExecutor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SitemapExecutor.java	11 Jun 2004 08:51:57 -0000	1.3
  +++ SitemapExecutor.java	17 Jun 2004 13:52:35 -0000	1.4
  @@ -23,6 +23,7 @@
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.matching.Matcher;
   import org.apache.cocoon.matching.PreparableMatcher;
  +import org.apache.cocoon.selection.Selector;
   
   /**
    * The sitemap executor executes all sitemap statements, so it actually
  @@ -48,8 +49,8 @@
                        Action           action, 
                        Redirector       redirector, 
                        SourceResolver   resolver, 
  -                     String           resolvedSource, 
  -                     Parameters       resolvedParams )
  +                     String           source, 
  +                     Parameters       parameters )
       throws Exception;
       
       /**
  @@ -59,7 +60,7 @@
                         Map              objectModel,
                         Matcher          matcher,
                         String           pattern,
  -                      Parameters       resolvedParams )
  +                      Parameters       parameters )
       throws PatternException;
       
       /**
  @@ -69,9 +70,24 @@
                         Map               objectModel,
                         PreparableMatcher matcher,
                         Object            preparedPattern,
  -                      Parameters        resolvedParams )
  +                      Parameters        parameters )
       throws PatternException;
   
  +    /**
  +     * Invoke a selector
  +     * @param context
  +     * @param objectModel
  +     * @param selector
  +     * @param expression
  +     * @param parameters
  +     * @return
  +     */
  +    boolean invokeSelector(ExecutionContext context,
  +            Map               objectModel,
  +            Selector selector, 
  +            String expression, 
  +            Parameters parameters);
  +    
       /**
        * Push map of information on the context stack.
        * @param context The execution context
  
  
  
  1.4       +10 -1     cocoon-2.1/src/java/org/apache/cocoon/sitemap/impl/DefaultExecutor.java
  
  Index: DefaultExecutor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/sitemap/impl/DefaultExecutor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultExecutor.java	11 Jun 2004 08:51:57 -0000	1.3
  +++ DefaultExecutor.java	17 Jun 2004 13:52:35 -0000	1.4
  @@ -23,6 +23,7 @@
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.matching.Matcher;
   import org.apache.cocoon.matching.PreparableMatcher;
  +import org.apache.cocoon.selection.Selector;
   import org.apache.cocoon.sitemap.ExecutionContext;
   import org.apache.cocoon.sitemap.PatternException;
   import org.apache.cocoon.sitemap.SitemapExecutor;
  @@ -75,6 +76,14 @@
                                          Parameters        resolvedParams )
       throws PatternException {
           return matcher.preparedMatch(preparedPattern, objectModel, resolvedParams);
  +    }
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.sitemap.SitemapExecutor#invokeSelector(org.apache.cocoon.sitemap.ExecutionContext,
java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
  +     */
  +    public boolean invokeSelector(ExecutionContext context, Map objectModel,
  +            Selector selector, String expression, Parameters parameters) {
  +        return selector.select(expression, objectModel, parameters);
       }
       
       /* (non-Javadoc)
  
  
  
  1.3       +17 -1     cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/SimpleSitemapExecutor.java
  
  Index: SimpleSitemapExecutor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/SimpleSitemapExecutor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SimpleSitemapExecutor.java	11 Jun 2004 08:51:57 -0000	1.2
  +++ SimpleSitemapExecutor.java	17 Jun 2004 13:52:35 -0000	1.3
  @@ -26,6 +26,7 @@
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.matching.Matcher;
   import org.apache.cocoon.matching.PreparableMatcher;
  +import org.apache.cocoon.selection.Selector;
   import org.apache.cocoon.sitemap.ExecutionContext;
   import org.apache.cocoon.sitemap.PatternException;
   import org.apache.cocoon.sitemap.SitemapExecutor;
  @@ -102,6 +103,21 @@
           return result;
       }
   
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.sitemap.SitemapExecutor#invokeSelector(org.apache.cocoon.sitemap.ExecutionContext,
java.util.Map, org.apache.cocoon.selection.Selector, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
  +     */
  +    public boolean invokeSelector(ExecutionContext context, Map objectModel,
  +            Selector selector, String expression, Parameters parameters) {
  +        this.getLogger().info("- Invoking selector '" + context.getType() + "' (" +
  +                context.getLocation() + ").");
  +        final boolean result = selector.select(expression, objectModel, parameters);
  +        if ( result ) {
  +            this.getLogger().info("- Selector '" + context.getType() + "' succeeded.");
  +        } else {
  +            this.getLogger().info("- Selector '" + context.getType() + "' failed.");  
         
  +        }
  +        return result;
  +    }
       /* (non-Javadoc)
        * @see org.apache.cocoon.sitemap.SitemapExecutor#popVariables(org.apache.cocoon.sitemap.ExecutionContext,
java.util.Map)
        */
  
  
  

Mime
View raw message