-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've something working for an app I'm migrating to cocoon-2.2. Could one of the other bug hunters check if the attached patch works for her,
too? If so that patch could be a base for how to solve this issue.

TIA and have a nice weekend!

Giacomo

On Fri, 12 May 2006, Giacomo Pati wrote:

Date: Fri, 12 May 2006 16:56:28 +0200 (CEST)
From: Giacomo Pati <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: CallFunctionNode problems in trunk

--[PinePGP]--------------------------------------------------[begin]--

On Fri, 12 May 2006, Carsten Ziegeler wrote:

 Date: Fri, 12 May 2006 16:23:58 +0200
 From: Carsten Ziegeler <[EMAIL PROTECTED]>
 Reply-To: [email protected]
 To: [email protected]
 Subject: Re: CallFunctionNode problems in trunk

 Giacomo Pati schrieb:
>  On Fri, 12 May 2006, Carsten Ziegeler wrote:
> > > > Date: Fri, 12 May 2006 16:05:16 +0200
> > >  From: Carsten Ziegeler <[EMAIL PROTECTED]>
> > >  Reply-To: [email protected]
> > >  To: [email protected]
> > >  Subject: Re: CallFunctionNode problems in trunk
> > > > > > Reinhard Poetz schrieb:
> > > >  Carsten Ziegeler wrote:
> > > > > Ignore my last email - the current code is correct. The > > > > > singleton
> > > > >  variable is set to false some lines below :(
> > > > Just wanted to answer that it doesn't fix it. IIUC the container > > > > with the > > > > builders is setup in SitemapLanguage.java#405-430. But I don't > > > > understand how
> > > >  the selector gets filled with all the builders ...
> > > > > > > Yes, the code is correct. The problem is in the selector (see my > > > reply > > > to Giacomo's mail). I think we should fix the node builder: I guess > > > if > > I've browsed through alost all NodeBuilders and have seen that we have
>  to fix alot of them (many aren't singletons)
> > > > it would use a list of simple beans (where the bean contains the
> > >  resource name, function name etc), and then process this list in
> > >  linkNode() it should work.
> > Well, this is another problem as those values (resource name, function
>  name, ...) are held in member variables too :-( and the linkNode method
>  needs a way to distinguish them (but hase no argument to check for).
>
 Ok, so let's change the strategy and fix the standalone service
 selector... :) If svn works again I can do this on monday evening - if
 noone beats me to it.

I've made a quich hack to see if that will help (and maybe I'm looking
at the wrong place):

Index:
src/main/java/org/apache/cocoon/components/treeprocessor/StandaloneServiceSelector.java
===================================================================
--- src/main/java/org/apache/cocoon/components/treeprocessor/StandaloneServiceSelector.java (revision 405757) +++ src/main/java/org/apache/cocoon/components/treeprocessor/StandaloneServiceSelector.java (working copy)
@@ -38,6 +38,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.core.container.spring.ComponentInfo;
 import org.apache.cocoon.util.ClassUtils;

@@ -107,7 +108,11 @@
         info.setRole(role);
         info.setConfiguration(configuration);
         info.setComponentClassName(componentClass.getName());
-        info.setModel(ComponentInfo.MODEL_SINGLETON);
+        if (ThreadSafe.class.isAssignableFrom(componentClass)) {
+            info.setModel(ComponentInfo.MODEL_SINGLETON);
+        } else {
+            info.setModel(ComponentInfo.MODEL_PRIMITIVE);
+        }
         return info;
     }

Doesn't get me any further. Still getting

java.lang.NullPointerException
         at
         
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:113)

Any additional ideas?

--
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com
--[PinePGP]-----------------------------------------------------------
gpg:  Signature made Fri May 12 16:56:29 2006 CEST using DSA key ID 98E35590
gpg:  Good signature from "Giacomo Pati <[EMAIL PROTECTED]>"
gpg:                  aka "Giacomo Pati <[EMAIL PROTECTED]>"
gpg:                  aka "Giacomo Pati <[EMAIL PROTECTED]>"
--[PinePGP]----------------------------------------------------[end]--


- -- Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEZKplLNdJvZjjVZARAl5tAKCqRsQJCQXkBdLPXtOV+sWpBC8izgCaAzBU
LZdrWbJlBdI76MYvn9rq/Qs=
=ZTOJ
-----END PGP SIGNATURE-----
Index: 
src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
===================================================================
--- 
src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
       (revision 405757)
+++ 
src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
       (working copy)
@@ -16,6 +16,7 @@
 package org.apache.cocoon.components.treeprocessor.sitemap;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.avalon.framework.configuration.Configurable;
@@ -36,19 +37,14 @@
 public class CallNodeBuilder extends AbstractProcessingNodeBuilder
                              implements LinkedProcessingNodeBuilder {
 
-    protected ProcessingNode node;
+    protected List nodes = new ArrayList();
 
-    protected String resourceName;
-
-    protected String functionName;
-
-    protected String continuationId;
-
     public ProcessingNode buildNode(Configuration config)
     throws Exception {
-        resourceName = config.getAttribute("resource", null);
-        functionName = config.getAttribute("function", null);
-        continuationId = config.getAttribute("continuation", null);
+        ProcessingNode node;
+        String resourceName = config.getAttribute("resource", null);
+        String functionName = config.getAttribute("function", null);
+        String continuationId = config.getAttribute("continuation", null);
 
         if (resourceName == null) {
             // Building a CallFunction node
@@ -83,16 +79,21 @@
             node = new CallNode();
         }
 
-        this.treeBuilder.setupNode(this.node, config);
+        this.treeBuilder.setupNode(node, config);
         if (node instanceof Configurable) {
-            ((Configurable) this.node).configure(config);
+            ((Configurable) node).configure(config);
         }
 
-        return this.node;
+        nodes.add(new NodeItem(resourceName, node));
+        return node;
     }
 
     public void linkNode() throws Exception {
-        if (resourceName != null) {
+        for (final Iterator i = nodes.iterator(); i.hasNext();) {
+            NodeItem nodeItem = (NodeItem)i.next();
+            String resourceName = nodeItem.resourceName;
+            ProcessingNode node = nodeItem.node;
+            if (resourceName != null) {
             // We have a <map:call resource="..."/>
             CategoryNode resources = 
CategoryNodeBuilder.getCategoryNode(treeBuilder, "resources");
 
@@ -100,27 +101,37 @@
                 throw new ConfigurationException(
                     "This sitemap contains no resources. Cannot call at " + 
node.getLocation());
 
-            ((CallNode) this.node).setResource(
-                resources,
-                VariableResolverFactory.getResolver(this.resourceName, 
this.manager)
+            ((CallNode) node).setResource(
+                        resources,
+                        VariableResolverFactory.getResolver(resourceName, 
this.manager)
             );
-        } else {
-            // We have a <map:call> with either "function" or
-            // "continuation", or both specified
+            } else {
+                // We have a <map:call> with either "function" or
+                // "continuation", or both specified
 
-            // Check to see if a flow has been defined in this sitemap
-            FlowNode flow = (FlowNode) treeBuilder.getRegisteredNode("flow");
-            if (flow == null) {
-                throw new ConfigurationException(
-                    "This sitemap contains no control flows defined, cannot 
call at "
-                    + node.getLocation()
-                    + ". Define a control flow using <map:flow>, with embedded 
<map:script> elements.");
+                // Check to see if a flow has been defined in this sitemap
+                FlowNode flow = (FlowNode) 
treeBuilder.getRegisteredNode("flow");
+                if (flow == null) {
+                    throw new ConfigurationException(
+                        "This sitemap contains no control flows defined, 
cannot call at "
+                        + node.getLocation()
+                        + ". Define a control flow using <map:flow>, with 
embedded <map:script> elements.");
+                }
+
+                // Get the Interpreter instance and set it up in the
+                // CallFunctionNode function
+                Interpreter interpreter = flow.getInterpreter();
+                ((CallFunctionNode) node).setInterpreter(interpreter);
             }
+        }
+    }
 
-            // Get the Interpreter instance and set it up in the
-            // CallFunctionNode function
-            Interpreter interpreter = flow.getInterpreter();
-            ((CallFunctionNode) node).setInterpreter(interpreter);
+    private static class NodeItem {
+        String resourceName;
+        ProcessingNode node;
+        NodeItem(String resourceName, ProcessingNode node) {
+            this.resourceName = resourceName;
+            this.node = node;
         }
     }
-}
\ No newline at end of file
+}

Reply via email to