cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r151736 - in cocoon/trunk: ./ lib/ lib/optional/ src/blocks/javaflow/ src/blocks/javaflow/WEB-INF/xconf/ src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/ src/blocks/javaflow/samples/ src/blocks/paranoid/java/org/apache/cocoon/servlet/ src/webapp/WEB-INF/ src/webapp/WEB-INF/compile/ src/webapp/WEB-INF/compile/org/ src/webapp/WEB-INF/compile/org/apache/cocoon/components/flow/java/ src/webapp/WEB-INF/compile/org/apache/cocoon/forms/flow/java/ src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/ src/webapp/WEB-INF/src/
Date Mon, 07 Feb 2005 18:29:16 GMT
Author: tcurdt
Date: Mon Feb  7 10:29:10 2005
New Revision: 151736

URL: http://svn.apache.org/viewcvs?view=rev&rev=151736
Log:
updated to the latest javaflow and jci,
removed the dependency to the form block for the moment
added the commons logging events to logkit


Added:
    cocoon/trunk/lib/optional/commons-javaflow-0.1-dev.jar   (with props)
    cocoon/trunk/lib/optional/commons-jci-0.1-dev.jar   (with props)
    cocoon/trunk/src/webapp/WEB-INF/compile/
      - copied from r151644, cocoon/trunk/src/webapp/WEB-INF/src/
    cocoon/trunk/src/webapp/WEB-INF/compile/org/
      - copied from r151732, cocoon/trunk/src/webapp/WEB-INF/src/org/
    cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/forms/flow/java/FormInstance.java.disabled
    cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/FormFlow.java.disabled
    cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/PersistenceFlow.java.disabled
Removed:
    cocoon/trunk/lib/optional/javaflow-20041213.jar
    cocoon/trunk/lib/optional/jci-20041217.183004.jar
    cocoon/trunk/src/blocks/javaflow/TODO.txt
    cocoon/trunk/src/blocks/javaflow/javaflow-20041213.tgz
    cocoon/trunk/src/blocks/javaflow/jci-20041213.tgz
    cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/forms/flow/java/FormInstance.java
    cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/FormFlow.java
    cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/PersistenceFlow.java
    cocoon/trunk/src/webapp/WEB-INF/src/
Modified:
    cocoon/trunk/cocoon.sh
    cocoon/trunk/gump.xml
    cocoon/trunk/lib/jars.xml
    cocoon/trunk/src/blocks/javaflow/WEB-INF/xconf/cocoon-javaflow.xconf
    cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/CocoonContinuationContext.java
    cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/JavaInterpreter.java
    cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMap.java
    cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMapHandler.java
    cocoon/trunk/src/blocks/javaflow/samples/sitemap.xmap
    cocoon/trunk/src/blocks/paranoid/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java
    cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/components/flow/java/AbstractContinuable.java
    cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/CalculatorFlow.java
    cocoon/trunk/src/webapp/WEB-INF/logkit.xconf
    cocoon/trunk/src/webapp/WEB-INF/web.xml
    cocoon/trunk/status.xml

Modified: cocoon/trunk/cocoon.sh
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon.sh?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/cocoon.sh (original)
+++ cocoon/trunk/cocoon.sh Mon Feb  7 10:29:10 2005
@@ -76,7 +76,9 @@
 fi
 
 if [ "$JAVA_OPTIONS" = "" ] ; then
-  JAVA_OPTIONS='-Xms32M -Xmx512M'
+#  JAVA_OPTIONS='-Xms32M -Xmx512M'
+  JAVA_OPTIONS='-Xms32M -Xmx512M -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.LogKitLogger'
+#  JAVA_OPTIONS='-Xms32M -Xmx512M -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog'
 fi
 
 if [ "$COCOON_HOME" = "" ] ; then

Modified: cocoon/trunk/gump.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/gump.xml?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/gump.xml (original)
+++ cocoon/trunk/gump.xml Mon Feb  7 10:29:10 2005
@@ -19,6 +19,10 @@
     | Cocoon GUMP Descriptor
     |
     | $Id$
+    |
+    |  see http://brutus.apache.org/gump/public/buildLog.html
+    |  for already existing projects
+    |
     +-->
 <module name="cocoon">
   <url href="http://cocoon.apache.org/"/>
@@ -1203,11 +1207,19 @@
     </ant>
 
     <depend project="cocoon" inherit="all"/>
+<!--
     <depend project="cocoon-block-forms" />
     <depend project="cocoon-block-ojb" type="samples"/>
-    <depend project="javaflow"/>
+-->
+    <depend project="commons-javaflow"/>
+    <depend project="commons-jci"/>
+    <depend project="commons-io"/>
+    <depend project="jdtcore"/>
 
-    <library name="javaflow"/>
+    <library name="commons-javaflow"/>
+    <library name="commons-jci"/>
+    <library name="commons-io"/>
+    <library name="jdtcore"/>
 
     <work nested="tools/anttasks"/>
     <home nested="build/cocoon-@@DATE@@"/>
@@ -1438,8 +1450,16 @@
     <jar name="lib/optional/daisy-util-1.1.jar"/>
   </project>      
 
-  <project name="javaflow">
-    <package>org.apache.javaflow</package>
-    <jar name="lib/optional/javaflow-20041213.jar"/>
+  <project name="commons-javaflow">
+    <package>org.apache.commons.javaflow</package>
+    <home nested="lib/optional"/>
+    <jar name="commons-javaflow-0.1-dev.jar"/>
   </project>      
+
+  <project name="commons-jci">
+    <package>org.apache.jci</package>
+    <home nested="lib/optional"/>
+    <jar name="commons-jci-0.1-dev.jar"/>
+  </project>      
+
 </module>

Modified: cocoon/trunk/lib/jars.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/lib/jars.xml?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/lib/jars.xml (original)
+++ cocoon/trunk/lib/jars.xml Mon Feb  7 10:29:10 2005
@@ -1092,7 +1092,7 @@
       API for compiling java
     </description>
     <used-by>javaflow</used-by>
-    <lib>optional/jci-20041217.183004.jar</lib>
+    <lib>optional/commons-jci-0.1-dev.jar</lib>
     <homepage></homepage>
   </file>
 
@@ -1102,7 +1102,7 @@
       API java continuations
     </description>
     <used-by>javaflow</used-by>
-    <lib>optional/javaflow-20041213.jar</lib>
+    <lib>optional/commons-javaflow-0.1-dev.jar</lib>
     <homepage></homepage>
   </file>
 

Added: cocoon/trunk/lib/optional/commons-javaflow-0.1-dev.jar
URL: http://svn.apache.org/viewcvs/cocoon/trunk/lib/optional/commons-javaflow-0.1-dev.jar?view=auto&rev=151736
==============================================================================
Binary file - no diff available.

Propchange: cocoon/trunk/lib/optional/commons-javaflow-0.1-dev.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: cocoon/trunk/lib/optional/commons-jci-0.1-dev.jar
URL: http://svn.apache.org/viewcvs/cocoon/trunk/lib/optional/commons-jci-0.1-dev.jar?view=auto&rev=151736
==============================================================================
Binary file - no diff available.

Propchange: cocoon/trunk/lib/optional/commons-jci-0.1-dev.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: cocoon/trunk/src/blocks/javaflow/WEB-INF/xconf/cocoon-javaflow.xconf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/javaflow/WEB-INF/xconf/cocoon-javaflow.xconf?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/blocks/javaflow/WEB-INF/xconf/cocoon-javaflow.xconf (original)
+++ cocoon/trunk/src/blocks/javaflow/WEB-INF/xconf/cocoon-javaflow.xconf Mon Feb  7 10:29:10 2005
@@ -20,11 +20,12 @@
     | SVN $Id$
     +-->
 <components>
-  <!-- Include dependencies -->
+  <!-- Include dependencies
   <include src="context://WEB-INF/xconf/cocoon-forms.xconf"/>
   <include src="context://WEB-INF/xconf/cocoon-ojb.xconf"/>
+  -->
 
   <flow-interpreters>
-    <component-instance name="java" class="org.apache.cocoon.components.flow.java.JavaInterpreter"/>
+    <component-instance name="java" class="org.apache.cocoon.components.flow.java.JavaInterpreter" logger="flow"/>
   </flow-interpreters>
 </components>

Modified: cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/CocoonContinuationContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/CocoonContinuationContext.java?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/CocoonContinuationContext.java (original)
+++ cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/CocoonContinuationContext.java Mon Feb  7 10:29:10 2005
@@ -20,7 +20,7 @@
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.environment.Redirector;
-import org.apache.javaflow.ContinuationContext;
+import org.apache.commons.javaflow.ContinuationContext;
 
 /**
  * Helper class to associate cocoon flow informations to the continuation.

Modified: cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/JavaInterpreter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/JavaInterpreter.java?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/JavaInterpreter.java (original)
+++ cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/JavaInterpreter.java Mon Feb  7 10:29:10 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.components.flow.java;
 
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -30,198 +29,165 @@
 import org.apache.cocoon.components.flow.InvalidContinuationException;
 import org.apache.cocoon.components.flow.WebContinuation;
 import org.apache.cocoon.environment.Redirector;
-import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.environment.Session;
-import org.apache.cocoon.util.ReflectionUtils;
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.MethodLookup;
+import org.apache.commons.javaflow.utils.ReflectionUtils;
 import org.apache.commons.jxpath.JXPathIntrospector;
-import org.apache.javaflow.Continuable;
-import org.apache.javaflow.Continuation;
 
 /**
  * Implementation of the java flow interpreter.
  *
  * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
+ * @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
  * @version CVS $Id$
  */
-public class JavaInterpreter extends AbstractInterpreter {
+public final class JavaInterpreter extends AbstractInterpreter {
 
     private int timeToLive = 600000;
 
-    /**
-     * Key for storing a global scope object in the Cocoon session
-     */
-    public static final String USER_GLOBAL_SCOPE = "JAVA GLOBAL SCOPE";
-
     static {
         JXPathIntrospector.registerDynamicClass(VarMap.class, VarMapHandler.class);
     }
 
-    public void continueFlow( final WebContinuation parentwk, final List params, final Redirector redirector, final Continuation parentContinuation, final CocoonContinuationContext context) throws Exception {
+    private class ContinuationHandler {
+        private Continuation continuation;
+        
+        public Continuation getContinuation() {
+            return continuation;
+        }
+        public void setContinuation(final Continuation continuation) {
+            this.continuation = continuation;
+        }
+    }
+    
+    private Map methods = new HashMap();
 
+    private MethodLookup lookup = new MethodLookup() {
+        public Method getMethod(final String methodName) {
+            final Method method = (Method) methods.get(methodName);            
+            return method;
+        }
+        
+    };
+    
+    private CocoonContinuationContext createContinuationContext( final List params, final Redirector redirector ) {
+        final CocoonContinuationContext context = new CocoonContinuationContext();
+        
         context.setAvalonContext(avalonContext);
         context.setLogger(getLogger());
         context.setServiceManager(manager);
         context.setRedirector(redirector);
+        context.setMethodLookup(lookup);
 
         final Parameters parameters = new Parameters();
-        for(Iterator i = params.iterator(); i.hasNext();) {
+        for(final Iterator i = params.iterator(); i.hasNext();) {
             final Argument argument = (Argument)i.next();
             parameters.setParameter(argument.name, argument.value);
         }
         context.setParameters(parameters);
-
-        final Continuation continuation = (parentContinuation != null)
-        ? new Continuation(parentContinuation, context)
-        : new Continuation(context);
-
-        if (getLogger().isDebugEnabled()) { 
-            getLogger().debug("created new continuation " + continuation);
-        }
-
-        final WebContinuation wk = continuationsMgr.createWebContinuation(
-                continuation, parentwk, timeToLive, getInterpreterID(), null);
-
-        FlowHelper.setWebContinuation(ContextHelper.getObjectModel(this.avalonContext), wk);
-                
-        continuation.registerThread();
-
-        if (parentContinuation != null) {
-            if (getLogger().isDebugEnabled()) { 
-                getLogger().debug("resuming continuation " + continuation + continuation.getStack());
-            }            
-        }
-        
-        try {
-            if (getLogger().isDebugEnabled()) { 
-                getLogger().debug("calling " + context.getMethod());
-            }
-
-            context.getMethod().invoke(context.getObject(), new Object[0]);
-
-            if (getLogger().isDebugEnabled()) { 
-                getLogger().debug("back from " + context.getMethod());
-            }
-
-        } catch (InvocationTargetException ite) {
-            if (ite.getTargetException() != null) {
-                if (ite.getTargetException() instanceof Exception) {
-                    throw (Exception) ite.getTargetException();
-                } else if (ite.getTargetException() instanceof Error) {
-                    throw new ProcessingException("An internal error occured", ite.getTargetException());
-                } else if (ite.getTargetException() instanceof RuntimeException) {
-                    throw (RuntimeException) ite.getTargetException();
-                } else {
-                    throw ite;
-                }
-            }
-            throw ite;
-
-        } finally {
-            // remove last object reference, which is not needed to
-            // reconstruct the invocation path
-
-            if (continuation.isCapturing()) {
-                continuation.getStack().popReference();
-            }
-
-            continuation.deregisterThread();
-
-            System.out.println("state saved in continuation" + continuation + continuation.getStack());                
-            if (getLogger().isDebugEnabled()) { 
-                getLogger().debug("state saved in continuation" + continuation + continuation.getStack());
-            }
-        }
         
+        return context;
     }
     
-    public void callFunction(String function, List params, Redirector redirector) throws Exception {
-
+    
+    private void updateMethodIndex() throws ClassNotFoundException {
         final Map methods = new HashMap();
 
-        // REVISIT: this is ugly as hell!
-        // but something better would require an
-        // imcompatible change of the flow handling.
-        // Make sure you don't have overlapping method
-        // names you want to call
-        
-        for (Iterator it = needResolve.iterator(); it.hasNext();) {
+        for (final Iterator it = needResolve.iterator(); it.hasNext();) {
             final String clazzName = (String) it.next();
 
-            System.out.println("loading " + clazzName);
             if (getLogger().isDebugEnabled()) { 
                 getLogger().debug("loading " + clazzName);
             }        
 
             final Class clazz = Thread.currentThread().getContextClassLoader().loadClass(clazzName);
-            final Map m = ReflectionUtils.discoverMethods(clazz);
-            methods.putAll(m);
-        }
-
-        final Method method = (Method) methods.get(function);
+            
+            final Map m = ReflectionUtils.discoverMethods(
+                    clazz,
+                    new ReflectionUtils.DefaultMatcher(),
+                    new ReflectionUtils.Indexer() {
+                        public void put(final Map pMap, final String pKey, final Object pObject) {
+                            final Method method = (Method) pObject;
+                            
+                            final String fullName = method.getDeclaringClass().getName() + "." + method.getName();
+                            final String shortName = method.getName();
+                            
+                            pMap.put(shortName, method);
+                            pMap.put(fullName, method);
+
+                            if (getLogger().isDebugEnabled()) { 
+                                getLogger().debug("registered method " + shortName + ", " + fullName); 
+                            }        
+                        }
+                    }
+                    );
 
-        if (method == null) {
-            throw new ProcessingException("no method '" + function + "' found. " + methods);
-        }
+            for (Iterator i = m.entrySet().iterator(); i.hasNext(); ) {
+                final Map.Entry e = (Map.Entry) i.next();
+                
+                if (getLogger().isWarnEnabled()) { 
+                    if (methods.containsKey(e.getKey())) {
+                            getLogger().warn("method name clash for " + e.getKey()); 
+                        
+                    }
+                }        
+                
+                methods.put(e.getKey(), e.getValue());
+            }        
 
-        if (getLogger().isDebugEnabled()) { 
-            getLogger().debug("setting up continuation context");
         }
+        
+        // REVISIT: synchronize?
+        this.methods = methods;
+    }
+    
+    public void callFunction( final String methodName, final List params, final Redirector redirector ) throws Exception {
 
-        final Request request = ContextHelper.getRequest(this.avalonContext);
-        final Session session = request.getSession(true);
-
-        HashMap userScopes = (HashMap) session.getAttribute(USER_GLOBAL_SCOPE);
-        if (userScopes == null) {
-            userScopes = new HashMap();
+        // REVISIT: subscribe to jci events and only update accordingly
+        updateMethodIndex();
+        
+        if (lookup.getMethod(methodName) == null) {
+            throw new ProcessingException("no method '" + methodName + "' found in " + methods);
         }
 
-        final CocoonContinuationContext context = new CocoonContinuationContext();
+        final CocoonContinuationContext context = createContinuationContext(params, redirector);
         
-        Continuable flow = null; //(Continuable) userScopes.get(method.getDeclaringClass());
-
-        if (flow == null) {
-            
-            if (getLogger().isDebugEnabled()) { 
-                getLogger().debug("creating flow class " + method.getDeclaringClass().getName());
-            }
-
-            flow = (Continuable) method.getDeclaringClass().newInstance();
+        final ContinuationHandler handler = new ContinuationHandler();
+        
+        final WebContinuation wk = continuationsMgr.createWebContinuation(
+                handler, null, timeToLive, getInterpreterID(), null);
 
-            userScopes.put(method.getDeclaringClass(), flow);
-            //session.setAttribute(USER_GLOBAL_SCOPE, userScopes);
-        }
+        FlowHelper.setWebContinuation(
+                ContextHelper.getObjectModel(avalonContext), wk);
 
-        context.setObject(flow);
-        context.setMethod(method);
+        final Continuation newContinuation = Continuation.startWith(methodName, context);
 
-        continueFlow(null, params, redirector, null, context);
+        handler.setContinuation(newContinuation);        
     }
 
-    public void handleContinuation(String id, List params, Redirector redirector)
-            throws Exception {
+    public void handleContinuation( final String id, final List params, final Redirector redirector ) throws Exception {
 
-        final WebContinuation parentwk = continuationsMgr.lookupWebContinuation(id, getInterpreterID());
+        final WebContinuation oldWebContinuation = continuationsMgr.lookupWebContinuation(
+                id, getInterpreterID());
 
-        if (parentwk == null) {
-            /*
-             * Throw an InvalidContinuationException to be handled inside the
-             * <map:handle-errors> sitemap element.
-             */
-            throw new InvalidContinuationException("Invalid continuation id " + id);
+        if (oldWebContinuation == null) {
+            throw new InvalidContinuationException("invalid continuation id " + id);
         }
 
-        if (getLogger().isDebugEnabled()) { 
-            getLogger().debug("continue with continuation " + id);
-        }
+        final CocoonContinuationContext context = createContinuationContext(params, redirector);
 
-        final CocoonContinuationContext context = new CocoonContinuationContext();
+        final ContinuationHandler oldHandler = (ContinuationHandler) oldWebContinuation.getContinuation();
+        final ContinuationHandler newHandler = new ContinuationHandler();
 
-        final Continuation parentContinuation = (Continuation) parentwk.getContinuation();
-        final CocoonContinuationContext parentContext = (CocoonContinuationContext) parentContinuation.getContext();
-        context.setObject(parentContext.getObject());
-        context.setMethod(parentContext.getMethod());
+        final WebContinuation newWebContinuation = continuationsMgr.createWebContinuation(
+                newHandler, oldWebContinuation, timeToLive, getInterpreterID(), null);
 
-        continueFlow(parentwk, params, redirector, parentContinuation, context);
+        FlowHelper.setWebContinuation(
+                ContextHelper.getObjectModel(avalonContext), newWebContinuation);
+
+        final Continuation oldContinuation = oldHandler.getContinuation();
+        final Continuation newContinuation = Continuation.continueWith(oldContinuation, context);
+
+        newHandler.setContinuation(newContinuation);
     }
-        
 }

Modified: cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMap.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMap.java?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMap.java (original)
+++ cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMap.java Mon Feb  7 10:29:10 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.components.flow.java;
 
+import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -24,54 +25,53 @@
  * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
  * @version CVS $Id$
  */
-public class VarMap {
-    private HashMap map = new HashMap();
-    
-    public VarMap(){
+public final class VarMap implements Serializable {
+    private final Map map = new HashMap();
     
+    public VarMap() {        
     }
-
-    public VarMap(String name, Object value) {
+    
+    public VarMap(final String name, final Object value) {
         add(name, value);
     }
 
-    public VarMap(String name, int value) {
+    public VarMap(final String name, final int value) {
         add(name, value);
     }
 
-    public VarMap(String name, long value) {
+    public VarMap(final String name, final long value) {
         add(name, value);
     }
 
-    public VarMap(String name, float value) {
+    public VarMap(final String name, final float value) {
         add(name, value);
     }
 
-    public VarMap(String name, double value) {
+    public VarMap(final String name, final double value) {
         add(name, value);
     }
 
-    public VarMap add(String name, Object value) {
+    public VarMap add(final String name, final Object value) {
         map.put(name, value);
         return this;
     }
 
-    public VarMap add(String name, int value) {
+    public VarMap add(final String name, final int value) {
         add(name, new Integer(value));
         return this;
     }
 
-    public VarMap add(String name, long value) {
+    public VarMap add(final String name, final long value) {
         add(name, new Long(value));
         return this;
     }
 
-    public VarMap add(String name, float value) {
+    public VarMap add(final String name, final float value) {
         add(name, new Float(value));
         return this;
     }
 
-    public VarMap add(String name, double value) {
+    public VarMap add(final String name, final double value) {
         add(name, new Double(value));
         return this;
     }

Modified: cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMapHandler.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMapHandler.java?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMapHandler.java (original)
+++ cocoon/trunk/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/VarMapHandler.java Mon Feb  7 10:29:10 2005
@@ -28,9 +28,9 @@
  * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
  * @version CVS $Id$
  */
-public class VarMapHandler implements DynamicPropertyHandler {
+public final class VarMapHandler implements DynamicPropertyHandler {
 
-    public String[] getPropertyNames(Object object){
+    public String[] getPropertyNames(final Object object){
 
         Map map = ((VarMap)object).getMap();
         ArrayList list = new ArrayList();
@@ -41,13 +41,13 @@
         return array;
     }
 
-    public Object getProperty(Object object, String property){
+    public Object getProperty(final Object object, final String property){
 
         Map map = ((VarMap)object).getMap();
         return map.get(property);
     }
 
-    public void setProperty(Object object, String property, Object value){
+    public void setProperty(final Object object, final String property, final Object value){
 
         Map map = ((VarMap)object).getMap();
         map.put(property, value);

Modified: cocoon/trunk/src/blocks/javaflow/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/javaflow/samples/sitemap.xmap?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/blocks/javaflow/samples/sitemap.xmap (original)
+++ cocoon/trunk/src/blocks/javaflow/samples/sitemap.xmap Mon Feb  7 10:29:10 2005
@@ -32,8 +32,8 @@
  <!-- indicates what flow classes to attach to this sitemap -->
  <map:flow language="java">
   <map:script src="org.apache.cocoon.samples.flow.java.CalculatorFlow"/>
-  <map:script src="org.apache.cocoon.samples.flow.java.FormFlow"/>
 <!--
+  <map:script src="org.apache.cocoon.samples.flow.java.FormFlow"/>
   <map:script src="org.apache.cocoon.samples.flow.java.PersistenceFlow"/>
 -->
  </map:flow>
@@ -51,6 +51,7 @@
     <map:serialize/>
    </map:match>
 
+<!--
    <map:match pattern="form/*">
     <map:generate src="forms/{1}-template.xml"/>
     <map:transform type="forms"/>
@@ -63,6 +64,7 @@
     <map:transform src="context://samples/blocks/forms/resources/forms-samples-styling.xsl"/>
     <map:serialize/>
    </map:match>
+-->
 
   </map:pipeline>
 

Modified: cocoon/trunk/src/blocks/paranoid/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/paranoid/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/blocks/paranoid/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java (original)
+++ cocoon/trunk/src/blocks/paranoid/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java Mon Feb  7 10:29:10 2005
@@ -262,7 +262,9 @@
                 final Class classLoaderClass = Class.forName(className);
                 final Class[] parameterClasses = new Class[] { ClassLoader.class, File.class };
                 final Constructor constructor = classLoaderClass.getConstructor(parameterClasses);
-                final Object[] parameters = new Object[] { this.getClass().getClassLoader(), new File(contextDir, "WEB-INF/src") };
+                // REVISIT: make the path configurable
+                final Object[] parameters = new Object[] { this.getClass().getClassLoader(),
+                        new File(contextDir, "WEB-INF/compile") };
                 final ClassLoader classloader = (ClassLoader) constructor.newInstance(parameters);
                 return classloader;
             } catch (InstantiationException e) {

Modified: cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/components/flow/java/AbstractContinuable.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/components/flow/java/AbstractContinuable.java?view=diff&r1=151732&r2=151736
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/components/flow/java/AbstractContinuable.java (original)
+++ cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/components/flow/java/AbstractContinuable.java Mon Feb  7 10:29:10 2005
@@ -29,9 +29,9 @@
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.Request;
 import org.apache.excalibur.source.SourceUtil;
-import org.apache.javaflow.Continuable;
-import org.apache.javaflow.Continuation;
-import org.apache.javaflow.ContinuationContext;
+import org.apache.commons.javaflow.Continuable;
+import org.apache.commons.javaflow.Continuation;
+import org.apache.commons.javaflow.ContinuationContext;
 
 /**
  * Abstract class to add basic methods for flow handling.

Added: cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/forms/flow/java/FormInstance.java.disabled
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/forms/flow/java/FormInstance.java.disabled?view=auto&rev=151736
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/forms/flow/java/FormInstance.java.disabled (added)
+++ cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/forms/flow/java/FormInstance.java.disabled Mon Feb  7 10:29:10 2005
@@ -0,0 +1,303 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cocoon.forms.flow.java;
+
+import java.util.Locale;
+
+import org.apache.avalon.framework.CascadingRuntimeException;
+import org.apache.cocoon.components.flow.FlowHelper;
+import org.apache.cocoon.components.flow.java.AbstractContinuable;
+import org.apache.cocoon.components.flow.java.VarMap;
+import org.apache.cocoon.forms.FormContext;
+import org.apache.cocoon.forms.FormManager;
+import org.apache.cocoon.forms.binding.Binding;
+import org.apache.cocoon.forms.binding.BindingManager;
+import org.apache.cocoon.forms.formmodel.Form;
+import org.apache.cocoon.forms.formmodel.Widget;
+import org.apache.cocoon.forms.transformation.FormsPipelineConfig;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.w3c.dom.Element;
+
+/**
+ * Implementation of the Cocoon Forms/Java Flow integration.
+ *
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
+ * @version CVS $Id: FormInstance.java 30932 2004-07-29 17:35:38Z vgritsenko $
+ */
+public class FormInstance extends AbstractContinuable {
+
+    private Form form;
+    private Binding binding;
+    private Locale locale;
+    private boolean isValid;
+    private Object validator; // Used?
+  
+    /**
+     * Create a form, given the URI of its definition file
+     */
+    public FormInstance(String uri) {
+        FormManager formMgr = null;
+        SourceResolver resolver = null;
+        Source src = null;
+        try {
+            formMgr = (FormManager)getComponent(FormManager.ROLE);
+            resolver = (SourceResolver)getComponent(SourceResolver.ROLE);
+            src = resolver.resolveURI(uri);
+            this.form = formMgr.createForm(src);
+            this.binding = null;
+            // this.validator = null;
+            // TODO : do we keep this ?
+            // this.formWidget = new Widget(this.form); could not create instance
+        } catch (Exception e) {
+            throw new CascadingRuntimeException("Could not create form instance", e);
+        } finally {
+            releaseComponent(formMgr);
+            if (src != null) resolver.release(src);
+            releaseComponent(resolver);
+        }
+    }
+
+    /**
+     * Create a form, given the URI of its definition file, the
+     * binding file.
+     */
+    public FormInstance(String definitionFile, String bindingFile) {
+        this(definitionFile);
+        createBinding(bindingFile);
+    }
+
+    /**
+     * Create a form of an fd:form element in the form of a org.w3c.dom.Element
+     */
+    public FormInstance(Element formDefinition) {
+        FormManager formMgr = null;
+        SourceResolver resolver = null;
+        Source src = null;
+        try {
+            formMgr = (FormManager)getComponent(FormManager.ROLE);
+            resolver = (SourceResolver)getComponent(SourceResolver.ROLE);
+            this.form = formMgr.createForm(formDefinition);
+            this.binding = null;
+        } catch (Exception e) {
+            throw new CascadingRuntimeException("Could not create form instance", e);
+        } finally {
+            releaseComponent(formMgr);
+            if (src != null) resolver.release(src);
+            releaseComponent(resolver);
+        }
+    }
+
+    public Widget getModel() {
+        return this.form;
+    }
+
+    /**
+     * Get a Widget (the java object) from the form.
+     * If <code>name</code> is undefined, the form widget itself is returned.
+     * Otherwise, the form's child widget of name <code>name</code> is returned.
+     */
+    public Widget getChild(String name) {
+        if (name == null) {
+            return this.form;
+        } else {
+            return this.form.getChild(name);
+        }
+    }
+
+		public String getSubmitId() {
+			
+		    Widget widget = this.form.getSubmitWidget();
+  	    // Can be null on "normal" submit
+				return  widget == null ? null : widget.getId();
+		}
+
+    /**
+     * Sets the point in your script that will be returned to when the form is
+     * redisplayed. If setBookmark() is not called, this is implicitly set to
+     * the beginning of showForm().
+     */
+/*    public WebContinuation setBookmark() {
+          return (this.local_.webContinuation = cocoon.createWebContinuation());
+    }*/
+
+    /**
+     * Returns the bookmark continuation associated with this form, or undefined
+     * if setBookmark() has not been called.
+     *
+     */
+/*    public WebContinuation getBookmark() {
+        return this.local_.webContinuation;
+    }  */
+
+    public void show(String uri) {
+        show(uri, new VarMap());
+    }
+    
+    /**
+     * Manages the display of a form and its validation.
+     *
+     * This uses some additionnal propertied on the form object :
+     * - "locale" : the form locale (default locale is used if not set)
+     * - "validator" : additional validation function. This function receives
+     *   the form object as parameter and should return a boolean indicating
+     *   if the form handling is finished (true) or if the form should be
+     *   redisplayed again (false)
+     *
+     * On return, the calling code can check some properties to know the form result :
+     * - "isValid" : true if the form was sucessfully validated
+     * - "submitId" : the id of the widget that triggered the form submit (can be null)
+     *
+     * @param uri the page uri (like in cocoon.sendPageAndWait())
+     * @param bizData some business data for the view (like in cocoon.sendPageAndWait()).
+     *            The "{FormsPipelineConfig.CFORMSKEY}" and "locale" properties are added to this object.
+     */
+    public void show(String uri, Object bizData) {
+
+        if (bizData==null) bizData = new VarMap();
+        ((VarMap)bizData).add(FormsPipelineConfig.CFORMSKEY, this.form);
+
+        if (this.locale == null)
+            this.locale = java.util.Locale.getDefault();
+        ((VarMap)bizData).add("locale", this.locale);
+    
+        // Keep the first continuation that will be created as the result of this function
+        //var result = null;
+
+        boolean finished = false;
+        this.isValid = false;
+
+        do {
+            sendPageAndWait(uri, bizData);
+        
+            FormContext formContext = new FormContext(getRequest(), locale);
+
+            // Prematurely add the bizData as a request attribute so that event listeners can use it
+            // (the same is done by cocoon.sendPage())
+            FlowHelper.setContextObject(AbstractContinuable.getObjectModel(), bizData);
+
+            finished = this.form.process(formContext);
+          
+            // Additional flow-level validation
+            if (finished) {
+                if (this.validator == null) {
+                    this.isValid = this.form.isValid();
+                } else {
+                    this.isValid = this.form.isValid() /*& this.validator(this.form, bizData)*/;
+                }
+                finished = this.isValid;
+            }
+        
+            // FIXME: Theoretically, we should clone the form widget (this.form) to ensure it keeps its
+            // value with the continuation. We don't do it since there should me not much pratical consequences
+            // except a sudden change of repeaters whose size changed from a continuation to another.
+        
+        } while(!finished);
+    }
+    /*
+    /**
+     * Manages the display of a form and its validation.
+     * @param uri the page uri (like in cocoon.sendPageAndWait())
+     * @param fun optional function which will be executed after pipeline
+     *  processing. Useful for releasing resources needed during pipeline
+     *  processing but which should not become part of the continuation
+     * @param ttl Time to live (in milliseconds) for the continuation
+     *  created
+     * @return The web continuation associated with submitting this form
+     *
+    public showForm(String uri, Object fun, ttl) {
+        if (!this.getBookmark()) {
+            this.setBookmark();
+        }
+        FormContext formContext = FormsFlowHelper.getFormContext(cocoon, this.locale);
+        // this is needed by the FormTemplateTransformer:
+        //var javaWidget = this.formWidget_.unwrap();;
+        //this.formWidget_["CocoonFormsInstance"] = javaWidget;
+        getRequest().setAttribute(Packages.org.apache.cocoon.forms.transformation.CFORMSKEY, this.formWidget);
+        WebContinuation wk = sendPageAndWait(uri, this.formWidget, fun, ttl);
+        var formContext = new FormContext(cocoon.request, javaWidget.getLocale());
+        var userErrors = 0;
+        this.formWidget_.validationErrorListener = function(widget, error) {
+            if (error != null) {
+                userErrors++;
+            }
+        }
+        var finished = javaWidget.process(formContext);
+        if (this.onValidate) {
+            this.onValidate(this);
+        }
+        if (!finished || userErrors > 0) {
+            cocoon.continuation = this.local_.webContinuation;
+            this.local_.webContinuation.continuation(this.local_.webContinuation);
+        }
+        return wk;
+    }*/
+
+    public void createBinding(String bindingURI) {
+        BindingManager bindingManager = null;
+        Source source = null;
+        SourceResolver resolver = null;
+        try {
+            bindingManager = (BindingManager)getComponent(BindingManager.ROLE);
+            resolver = (SourceResolver)getComponent(SourceResolver.ROLE);
+            source = resolver.resolveURI(bindingURI);
+            this.binding = bindingManager.createBinding(source);
+        } catch (Exception e) {
+            throw new CascadingRuntimeException("Could not create bindinh", e);
+        } finally {
+            if (source != null)
+                resolver.release(source);
+            releaseComponent(bindingManager);
+            releaseComponent(resolver);
+        }
+    }
+
+    public void load(Object object) {
+        if (this.binding == null)
+            throw new Error("Binding not configured for this form.");
+
+        try {
+            this.binding.loadFormFromModel(this.form, object);
+        } catch (Exception e) {
+            throw new CascadingRuntimeException("Could not load form from model", e);
+        }
+    }
+
+    public void save(Object object) {
+        if (this.binding == null)
+            throw new Error("Binding not configured for this form.");
+
+        try {
+            this.binding.saveFormToModel(this.form, object);
+        } catch (Exception e) {
+            throw new CascadingRuntimeException("Could not save form into model", e);
+        }
+    }
+
+    public void setAttribute(String name, Object value) {
+        this.form.setAttribute(name, value);
+    }
+
+    public Object getAttribute(String name) {
+        return this.form.getAttribute(name);
+    }
+
+    public void removeAttribute(String name) {
+        this.form.removeAttribute(name);
+    }
+}

Modified: cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/CalculatorFlow.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/CalculatorFlow.java?view=diff&r1=151732&r2=151736
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/CalculatorFlow.java (original)
+++ cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/CalculatorFlow.java Mon Feb  7 10:29:10 2005
@@ -22,7 +22,7 @@
 
     private int count = 1;
 
-    public void doCalculator() {
+    public void calculator() {
         float a = getNumber("a", 0f, 0f);
         float b = getNumber("b", a, 0f);
         String op = getOperator(a, b);

Added: cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/FormFlow.java.disabled
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/FormFlow.java.disabled?view=auto&rev=151736
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/FormFlow.java.disabled (added)
+++ cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/FormFlow.java.disabled Mon Feb  7 10:29:10 2005
@@ -0,0 +1,81 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.samples.flow.java;
+
+import java.util.Date;
+
+import org.apache.cocoon.components.flow.java.AbstractContinuable;
+import org.apache.cocoon.components.flow.java.VarMap;
+import org.apache.cocoon.forms.binding.BindingException;
+import org.apache.cocoon.forms.flow.java.FormInstance;
+import org.apache.cocoon.forms.formmodel.BooleanField;
+import org.apache.cocoon.forms.formmodel.Field;
+import org.apache.cocoon.forms.formmodel.Repeater;
+import org.apache.cocoon.forms.samples.Contact;
+import org.apache.cocoon.forms.samples.Form2Bean;
+import org.apache.cocoon.forms.samples.Sex;
+
+public class FormFlow extends AbstractContinuable {
+
+    public void doEditForm1() {
+
+        FormInstance form = new FormInstance("forms/form1.xml");
+
+        Field birthDate = (Field) form.getChild("birthdate");
+        birthDate.setValue(new Date());
+
+        Repeater repeater = (Repeater) form.getChild("contacts");
+        repeater.addRow();
+        Field field = (Field) repeater.getWidget(0, "firstname");
+        field.setValue("Jules");
+
+        repeater.addRow();
+        field = (Field) repeater.getWidget(1, "firstname");
+        field.setValue("Lucien");
+
+	System.out.println("** start");
+        form.show("form/form1");
+	System.out.println("** continue");
+
+        sendPage("page/form1-result", new VarMap().add("email", ((Field)form.getChild("email")).getValue())
+                                                  .add("somebool", ((BooleanField)form.getChild("somebool")).getValue())
+                                                  .add("firstname", ((Field)((Repeater)form.getChild("contacts")).getWidget(1, "firstname")).getValue()));
+    }
+
+    public void doEditForm2() throws BindingException {
+        Form2Bean bean = new Form2Bean();
+
+        // fill bean with some data to avoid users having to type to much
+        bean.setEmail("yourname@yourdomain.com");
+        bean.setIpAddress("10.0.0.1");
+        bean.setPhoneCountry("32");
+        bean.setPhoneZone("2");
+        bean.setPhoneNumber("123456");
+        bean.setBirthday(new java.util.Date());
+        bean.setSex(Sex.FEMALE);
+        Contact contact = new Contact();
+        contact.setId(1);
+        contact.setFirstName("Hermann");
+        bean.addContact(contact);
+
+        FormInstance form = new FormInstance("forms/form2.xml", "forms/form2-binding.xml");
+        form.load(bean);
+        form.show("form/form2");
+        form.save(bean);
+                                         
+        sendPage("page/form2-result", new VarMap().add("form2bean", bean));
+    }
+}

Added: cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/PersistenceFlow.java.disabled
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/PersistenceFlow.java.disabled?view=auto&rev=151736
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/PersistenceFlow.java.disabled (added)
+++ cocoon/trunk/src/webapp/WEB-INF/compile/org/apache/cocoon/samples/flow/java/PersistenceFlow.java.disabled Mon Feb  7 10:29:10 2005
@@ -0,0 +1,143 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.samples.flow.java;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+
+import org.apache.cocoon.components.flow.java.AbstractContinuable;
+import org.apache.cocoon.components.flow.java.VarMap;
+import org.apache.cocoon.forms.binding.BindingException;
+import org.apache.cocoon.forms.flow.java.FormInstance;
+import org.apache.cocoon.ojb.broker.components.PBFactory;
+import org.apache.cocoon.ojb.samples.bean.Employee;
+import org.apache.ojb.broker.Identity;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.query.Criteria;
+import org.apache.ojb.broker.query.QueryByCriteria;
+
+public class PersistenceFlow extends AbstractContinuable {
+
+    private transient PersistenceBroker broker = null;
+
+    public PersistenceFlow() {
+        PBFactory factory = (PBFactory)getComponent(PBFactory.ROLE);
+        broker = factory.defaultPersistenceBroker();
+        releaseComponent(factory);
+    }
+
+    public void doInsertEmployee() throws BindingException {
+
+        // Create a empty Bean
+        Employee employee = new Employee();
+        // Fill some initial data to the bean
+        employee.setId(1);
+        // Load form descriptor
+        FormInstance form = new FormInstance("forms/employee.xml");
+        // Load form binding
+        form.createBinding("forms/employee-binding.xml");
+        // Load the Bean to the form
+        form.load(employee);
+        // Let Cocoon Forms handle the form
+        form.show("form/employee");
+        // Update the Bean based on user input
+        form.save(employee);
+        // Update Bean in Database
+        broker.store(employee);
+        // Send response to the user
+        doShowEmployee();
+    }
+
+    public void doUpdateEmployee() throws BindingException {
+
+        // Get id as parameter
+        int id = 1;
+        if (getRequest().getParameter("id")!=null)
+            id = Integer.parseInt(getRequest().getParameter("id")); 
+        else
+            throw new IllegalStateException("No parameter 'id'");
+
+        // Create a empty Bean
+        Employee employee = new Employee();
+        // Fill some initial data to the bean
+        employee.setId(id);
+        // Load bean based on the given PrimaryKey
+        employee = (Employee) broker.getObjectByIdentity(new Identity(employee, broker));
+        // Load form descriptor
+        FormInstance form = new FormInstance("forms/employee.xml");
+        // Load form binding
+        form.createBinding("forms/employee-binding.xml");
+        // Load the Bean to the form
+        form.load(employee);
+        // Let Cocoon Forms handle the form
+        form.show("form/employee");
+        // Update the Bean based on user input
+        form.save(employee);
+
+        // Update Bean in Database
+        broker.store(employee);
+
+        // Send response to the user
+        doShowEmployee();
+    }
+
+    public void doRemoveEmployee() {
+
+        // Get id as parameter
+        int id = 1;
+        if (getRequest().getParameter("id")!=null)
+            id = Integer.parseInt(getRequest().getParameter("id"));
+        else
+            throw new IllegalStateException("No parameter 'id'");
+
+        // Create a empty Bean
+        Employee employee = new Employee();
+        // Fill some initial data to the bean
+        employee.setId(id);
+        // Load bean based on the given PrimaryKey
+        employee = (Employee) broker.getObjectByIdentity(new Identity(employee, broker));
+        // Remove bean
+        broker.delete(employee);
+        // Send response to the user
+        doShowEmployee();
+    }
+
+    public void doShowEmployee() {
+
+        // Query all objects
+        ArrayList results = new ArrayList();
+        QueryByCriteria query = new QueryByCriteria(Employee.class, new Criteria());
+        for(Iterator i=broker.getCollectionByQuery(query).iterator(); i.hasNext();) {
+            results.add(i.next());
+        }
+        // Sort result
+        Collections.sort(results, new EmployeeComparator());
+        // Send response to the user
+        sendPage("page/employee-result", new VarMap().add("employee", results));
+    }
+
+    public class EmployeeComparator implements Comparator {
+        public int compare(Object o1, Object o2) {
+            return ((Employee)o1).getId()-((Employee)o2).getId();
+        }
+      
+        public boolean equals(Object obj) {
+            return true;
+        }
+    }
+}

Modified: cocoon/trunk/src/webapp/WEB-INF/logkit.xconf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/logkit.xconf?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/logkit.xconf (original)
+++ cocoon/trunk/src/webapp/WEB-INF/logkit.xconf Mon Feb  7 10:29:10 2005
@@ -1,5 +1,4 @@
-<?xml version="1.0"?>
-<!--
+<?xml version="1.0" encoding="UTF-8"?><!--
   Copyright 1999-2004 The Apache Software Foundation
 
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,14 +12,12 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
--->
-
-<logkit>
+--><logkit>
   <factories>
-    <factory type="priority-filter" class="org.apache.avalon.excalibur.logger.factory.PriorityFilterTargetFactory"/>
-    <factory type="servlet" class="org.apache.avalon.excalibur.logger.factory.ServletTargetFactory"/>
-    <factory type="cocoon" class="org.apache.cocoon.util.log.CocoonTargetFactory"/>
-    <factory type="lf5" class="org.apache.avalon.excalibur.logger.factory.LF5TargetFactory"/>
+    <factory class="org.apache.avalon.excalibur.logger.factory.PriorityFilterTargetFactory" type="priority-filter"/>
+    <factory class="org.apache.avalon.excalibur.logger.factory.ServletTargetFactory" type="servlet"/>
+    <factory class="org.apache.cocoon.util.log.CocoonTargetFactory" type="cocoon"/>
+    <factory class="org.apache.avalon.excalibur.logger.factory.LF5TargetFactory" type="lf5"/>
   </factories>
 
   <targets>
@@ -99,7 +96,66 @@
         <append>false</append>
       </cocoon>
     </priority-filter>
-  </targets>
+  
+    
+    <cocoon id="forms">
+      <filename>${context-root}/WEB-INF/logs/forms.log</filename>
+
+      <format type="cocoon">
+        %7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}
+      </format>
+      <append>false</append>
+    </cocoon>
+    
+
+    
+    <cocoon id="apples">
+      <filename>${context-root}/WEB-INF/logs/apples.log</filename>
+
+      <format type="cocoon">
+        %7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}
+      </format>
+      <append>false</append>
+    </cocoon>
+    
+
+    <!-- The logger for the cron components -->
+    <cocoon id="cron">
+        <filename>${context-root}/WEB-INF/logs/cron.log</filename>
+        <format type="cocoon">
+            %7.7{priority} %{time}   [%{category}] %{thread}/%{class:short}: %{message}\n%{throwable}
+        </format>
+        <append>true</append>
+    </cocoon>
+
+    
+    <cocoon id="portal">
+      <filename>${context-root}/WEB-INF/logs/portal.log</filename>
+
+      <format type="cocoon">
+        %7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}
+      </format>
+      <append>false</append>
+    </cocoon>
+    
+
+    <!-- The logger for the Slide components -->
+    <cocoon id="slide">
+      <filename>${context-root}/WEB-INF/logs/slide.log</filename>
+      <format type="cocoon">
+        %7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}
+      </format>
+      <append>false</append>
+    </cocoon>
+
+    <cocoon id="commons">
+      <filename>${context-root}/WEB-INF/logs/commons.log</filename>
+      <format type="cocoon">
+        %7.7{priority} %{time}   [%{category}] (%{uri}) %{thread}/%{class:short}: %{message}\n%{throwable}
+      </format>
+      <append>false</append>
+    </cocoon>
+</targets>
 
   <categories>
     <!--
@@ -112,20 +168,50 @@
       When defining subcategory manually, it is required to specify log
       targets, because they are not inherited in this case.
     -->
-    <category name="core" log-level="@loglevel@">
+
+
+    <category log-level="DEBUG" name="org">
+      <log-target id-ref="commons"/>
+      <log-target id-ref="error"/>
+
+      <category log-level="DEBUG" name="apache">
+        <log-target id-ref="commons"/>
+        <log-target id-ref="error"/>
+    
+        <category log-level="DEBUG" name="jci">
+          <log-target id-ref="commons"/>
+          <log-target id-ref="error"/>
+        </category>
+
+        <category log-level="DEBUG" name="commons">
+          <log-target id-ref="commons"/>
+          <log-target id-ref="error"/>
+
+          <category log-level="DEBUG" name="javaflow">
+            <log-target id-ref="commons"/>
+            <log-target id-ref="error"/>
+          </category>
+        </category>
+
+      </category>
+    </category>
+
+    <category log-level="INFO" name="core">
+
       <!-- Startup component manager logger -->
-      <category name="startup" log-level="@loglevel@">
+
+      <category log-level="INFO" name="startup">
         <log-target id-ref="core"/>
         <log-target id-ref="error"/>
       </category>
 
-      <category name="roles" log-level="@loglevel@">
+      <category log-level="INFO" name="roles">
         <log-target id-ref="core"/>
         <log-target id-ref="error"/>
       </category>
 
-      <category name="instrument" log-level="@loglevel@">
-        <category name="values" log-level="@loglevel@">
+      <category log-level="INFO" name="instrument">
+        <category log-level="INFO" name="values">
           <log-target id-ref="core"/>
           <log-target id-ref="error"/>
         </category>
@@ -134,14 +220,14 @@
       </category>
 
       <!-- Cocoon component manager logger -->
-      <category name="manager" log-level="@loglevel@">
+      <category log-level="INFO" name="manager">
         <log-target id-ref="core"/>
         <log-target id-ref="error"/>
       </category>
 
       <!-- Cocoon cache and stores logger -->
-      <category name="store" log-level="@loglevel@">
-        <category name="janitor" log-level="@loglevel@">
+      <category log-level="INFO" name="store">
+        <category log-level="INFO" name="janitor">
           <log-target id-ref="core"/>
           <log-target id-ref="error"/>
         </category>
@@ -153,32 +239,65 @@
       <log-target id-ref="error"/>
     </category>
 
-    <category name="sitemap" log-level="@loglevel@">
+    <category log-level="INFO" name="sitemap">
       <log-target id-ref="sitemap"/>
       <log-target id-ref="error"/>
 
-      <category name="handled-errors" log-level="@loglevel@">
+      <category log-level="INFO" name="handled-errors">
         <!-- Exceptions that will be handled by a sitemap errorhandler are
              logged to this target. -->
         <log-target id-ref="handled-errors"/>
       </category>
     </category>
 
-    <category name="access" log-level="@loglevel@">
+    <category log-level="INFO" name="access">
       <log-target id-ref="access"/>
       <log-target id-ref="error"/>
     </category>
 
-    <category name="flow" log-level="@loglevel@">
+    <category log-level="DEBUG" name="flow">
       <log-target id-ref="flow"/>
       <log-target id-ref="error"/>
     </category>
 
-    <category name="" log-level="@loglevel@">
+    <category log-level="INFO" name="">
       <log-target id-ref="core"/>
       <log-target id-ref="error"/>
     </category>
-  </categories>
+  
+    
+    <category log-level="ERROR" name="forms">
+      <log-target id-ref="forms"/>
+      <log-target id-ref="error"/>
+    </category>
+    
+
+
+    <category log-level="ERROR" name="apples">
+      <log-target id-ref="apples"/>
+      <log-target id-ref="error"/>
+    </category>
+
+
+
+    <category log-level="INFO" name="cron">
+        <log-target id-ref="cron"/>
+        <log-target id-ref="error"/>
+    </category>
+    
+
+    
+    <category log-level="ERROR" name="portal">
+      <log-target id-ref="portal"/>
+      <log-target id-ref="error"/>
+    </category>
+    
+
+    <category log-level="INFO" name="slide">
+      <log-target id-ref="slide"/>
+      <log-target id-ref="error"/>
+    </category>
+</categories>
   
   <!-- Include logging confs from different blocks -->
   <include dir="context://WEB-INF/xconf" pattern="*.logkit"/>

Modified: cocoon/trunk/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/webapp/WEB-INF/web.xml?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/src/webapp/WEB-INF/web.xml (original)
+++ cocoon/trunk/src/webapp/WEB-INF/web.xml Mon Feb  7 10:29:10 2005
@@ -46,17 +46,17 @@
 
     <!--
       The regular servlet class (trusts the servlet container classloader)
-      -->
     <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
+      -->
     <!--
       The paranoid servlet class, to be used instead of regular one when
       having conflicts between libraries used by Cocoon and the servlet
       container.
-    <servlet-class>org.apache.cocoon.servlet.ParanoidCocoonServlet</servlet-class>
     -->
+    <servlet-class>org.apache.cocoon.servlet.ParanoidCocoonServlet</servlet-class>
     <init-param>
       <param-name>classloader-class</param-name>
-      <param-value>org.apache.javaflow.ContinuationClassLoader</param-value>
+      <param-value>org.apache.commons.javaflow.ContinuationCompilingClassLoader</param-value>
     </init-param>
 
     <!--
@@ -135,7 +135,7 @@
     -->
     <init-param>
       <param-name>log-level</param-name>
-      <param-value>WARN</param-value>
+      <param-value>DEBUG</param-value>
     </init-param>
 
     <!--

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?view=diff&r1=151735&r2=151736
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Mon Feb  7 10:29:10 2005
@@ -202,6 +202,12 @@
 
   <changes>
  <release version="@version@" date="@date@">
+   <action dev="TC" type="add">
+    javaflow: updated to the API change,
+    lazy method lookups,
+    cleaner context handling,
+    for the moment removed the dependency to the form block
+   </action>
    <action dev="RP" type="add">
      hsqldb: make name and path of database parameterizable - this way the database can be located outside of Cocoon
    </action>   



Mime
View raw message