stephan     2004/03/30 03:10:53

  Modified:    src/blocks/javaflow TODO.txt
               src/blocks/javaflow/java/org/apache/cocoon/components/flow/java
                        JavaInterpreter.java
               src/blocks/javaflow/java/org/apache/cocoon/samples/flow/java
                        PersistenceFlow.java
               src/blocks/javaflow/samples/forms employee-binding.xml
                        employee-template.xml employee.xml
  Log:
  Sort the output of the OJB example.
  Unroll Errors and RuntimeExceptions.
  
  Revision  Changes    Path
  1.2       +6 -0      cocoon-2.1/src/blocks/javaflow/TODO.txt
  
  Index: TODO.txt
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/javaflow/TODO.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TODO.txt  29 Mar 2004 17:47:21 -0000      1.1
  +++ TODO.txt  30 Mar 2004 11:10:53 -0000      1.2
  @@ -24,3 +24,9 @@
      is no ContinuationContext availble. This makes lookups of components
      impossible. The move of the continuation context into an
      independent ThreadLocal variable might be an option.
  +
  + - The classloader seems to have problems with inner classes, because the
  +   the inner classes is not transformed by the ContinuationClassLoader, which
  +   caused a LinkageError.
  +   Temporary solution is to implement Continuable for the inner class.
  +
  
  
  
  1.2       +19 -7     
cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/JavaInterpreter.java
  
  Index: JavaInterpreter.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/components/flow/java/JavaInterpreter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JavaInterpreter.java      29 Mar 2004 17:47:21 -0000      1.1
  +++ JavaInterpreter.java      30 Mar 2004 11:10:53 -0000      1.2
  @@ -163,9 +163,15 @@
               method.invoke(flow, new Object[0]);
   
           } catch (InvocationTargetException ite) {
  -            if ((ite.getTargetException() != null)
  -                    && (ite.getTargetException() instanceof Exception)) {
  -                throw (Exception) ite.getTargetException();
  +            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;
               } else {
                   throw ite;
               }
  @@ -223,9 +229,15 @@
               method.invoke(flow, new Object[0]);
   
           } catch (InvocationTargetException ite) {
  -            if ((ite.getTargetException() != null)
  -                    && (ite.getTargetException() instanceof Exception)) {
  -                throw (Exception) ite.getTargetException();
  +            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;
               } else {
                   throw ite;
               }
  
  
  
  1.4       +14 -2     
cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/samples/flow/java/PersistenceFlow.java
  
  Index: PersistenceFlow.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/javaflow/java/org/apache/cocoon/samples/flow/java/PersistenceFlow.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PersistenceFlow.java      29 Mar 2004 20:56:14 -0000      1.3
  +++ PersistenceFlow.java      30 Mar 2004 11:10:53 -0000      1.4
  @@ -19,7 +19,7 @@
   
   import javax.jdo.PersistenceManager;
   
  -import org.apache.cocoon.components.flow.java.VarMap;
  +import org.apache.cocoon.components.flow.java.*;
   import org.apache.cocoon.forms.binding.*;
   import org.apache.cocoon.forms.flow.java.AbstractFormFlow;
   import org.apache.cocoon.forms.formmodel.Form;
  @@ -118,16 +118,28 @@
           PersistenceBroker broker = getPersistenceBroker();
   
           // Query all objects
  -        Set results = new HashSet();
  +        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 PersistenceBroker getPersistenceBroker() {
           return 
((PBFactory)getComponent(PBFactory.ROLE)).defaultPersistenceBroker();
  +    }
  +
  +    public class EmployeeComparator implements Comparator, Continuable {
  +        public int compare(Object o1, Object o2) {
  +            return ((Employee)o1).getId()-((Employee)o2).getId();
  +        }
  +      
  +        public boolean equals(Object obj) {
  +            return true;
  +        }
       }
   }
  
  
  
  1.2       +1 -2      
cocoon-2.1/src/blocks/javaflow/samples/forms/employee-binding.xml
  
  Index: employee-binding.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/javaflow/samples/forms/employee-binding.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- employee-binding.xml      29 Mar 2004 17:47:22 -0000      1.1
  +++ employee-binding.xml      30 Mar 2004 11:10:53 -0000      1.2
  @@ -22,7 +22,6 @@
    * @version CVS $Revision$ $Date$
   -->
   <fd:context xmlns:fd="http://apache.org/cocoon/forms/1.0#binding"; path="/" >
  -    <fd:value id="id" path="id"/>
       <fd:value id="name" path="name"/>
       <fd:value id="department_id" path="departmentId"/>
   </fd:context>
  
  
  
  1.2       +1 -2      
cocoon-2.1/src/blocks/javaflow/samples/forms/employee-template.xml
  
  Index: employee-template.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/javaflow/samples/forms/employee-template.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- employee-template.xml     29 Mar 2004 17:47:22 -0000      1.1
  +++ employee-template.xml     30 Mar 2004 11:10:53 -0000      1.2
  @@ -35,7 +35,6 @@
         <fi:styling type="fieldset" layout="columns"/>
         <fi:label>Employee</fi:label>
         <fi:items>
  -       <ft:widget id="id"/>
          <ft:widget id="name"/>
          <ft:widget id="department_id"/>
         </fi:items>
  
  
  
  1.2       +0 -5      cocoon-2.1/src/blocks/javaflow/samples/forms/employee.xml
  
  Index: employee.xml
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/javaflow/samples/forms/employee.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- employee.xml      29 Mar 2004 17:47:22 -0000      1.1
  +++ employee.xml      30 Mar 2004 11:10:53 -0000      1.2
  @@ -17,11 +17,6 @@
   <fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"; 
xmlns:i18n="http://apache.org/cocoon/i18n/2.1";>
   
     <fd:widgets>
  -    <fd:field id="id" required="true">
  -      <fd:label>ID</fd:label>
  -      <fd:datatype base="integer"/>
  -    </fd:field>
  -
       <fd:field id="name" required="true">
         <fd:label>Name</fd:label>
         <fd:datatype base="string">
  
  
  

Reply via email to