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/woody/java/org/apache/cocoon/woody/acting HandleFormSubmitAction.java MakeFormAction.java
Date Tue, 08 Jul 2003 14:04:41 GMT
cziegeler    2003/07/08 07:04:41

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/acting
                        HandleFormSubmitAction.java MakeFormAction.java
  Log:
  Properly releasing sources
  
  Revision  Changes    Path
  1.5       +28 -22    cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/acting/HandleFormSubmitAction.java
  
  Index: HandleFormSubmitAction.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/acting/HandleFormSubmitAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HandleFormSubmitAction.java	30 Jun 2003 13:25:28 -0000	1.4
  +++ HandleFormSubmitAction.java	8 Jul 2003 14:04:41 -0000	1.5
  @@ -61,6 +61,7 @@
   import org.apache.cocoon.woody.FormContext;
   import org.apache.cocoon.woody.FormHandler;
   import org.apache.cocoon.woody.formmodel.Form;
  +import org.apache.excalibur.source.Source;
   
   import java.util.Map;
   import java.util.Collections;
  @@ -80,33 +81,38 @@
    */
   public class HandleFormSubmitAction extends AbstractWoodyAction implements Action, ThreadSafe,
Composable {
   
  -    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String
source, Parameters parameters)
  +    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String
src, Parameters parameters)
               throws Exception {
           String formSource = parameters.getParameter("form-definition");
           String formAttribute = parameters.getParameter("attribute-name");
           String formHandlerClassName = parameters.getParameter("formhandler", null);
   
  -        Form form = formManager.createForm(resolver.resolveURI(formSource));
  -
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        FormHandler formHandler = null;
  -
  -        if (formHandlerClassName != null) {
  -            // TODO cache these classes
  -            Class clazz = Class.forName(formHandlerClassName);
  -            formHandler = (FormHandler)clazz.newInstance();
  -            formHandler.setup(form);
  -            form.setFormHandler(formHandler);
  +        Source source = resolver.resolveURI(formSource);
  +        try {
  +            Form form = formManager.createForm(source);
  +
  +            Request request = ObjectModelHelper.getRequest(objectModel);
  +            FormHandler formHandler = null;
  +
  +            if (formHandlerClassName != null) {
  +                // TODO cache these classes
  +                Class clazz = Class.forName(formHandlerClassName);
  +                formHandler = (FormHandler)clazz.newInstance();
  +                formHandler.setup(form);
  +                form.setFormHandler(formHandler);
  +            }
  +
  +            FormContext formContext = new FormContext(request, Locale.US);
  +
  +            boolean finished = form.process(formContext);
  +            request.setAttribute(formAttribute, form);
  +
  +            if (finished)
  +                return Collections.EMPTY_MAP;
  +            else
  +                return null;
  +        } finally {
  +            resolver.release(source);
           }
  -
  -        FormContext formContext = new FormContext(request, Locale.US);
  -
  -        boolean finished = form.process(formContext);
  -        request.setAttribute(formAttribute, form);
  -
  -        if (finished)
  -            return Collections.EMPTY_MAP;
  -        else
  -            return null;
       }
   }
  
  
  
  1.4       +12 -5     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/acting/MakeFormAction.java
  
  Index: MakeFormAction.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/acting/MakeFormAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MakeFormAction.java	15 May 2003 10:31:01 -0000	1.3
  +++ MakeFormAction.java	8 Jul 2003 14:04:41 -0000	1.4
  @@ -57,6 +57,7 @@
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.woody.FormManager;
   import org.apache.cocoon.woody.formmodel.Form;
  +import org.apache.excalibur.source.Source;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.component.Composable;
  @@ -82,15 +83,21 @@
           formManager = (FormManager)componentManager.lookup(FormManager.ROLE);
       }
   
  -    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String
source, Parameters parameters)
  +    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String
src, Parameters parameters)
               throws Exception {
           String formSource = parameters.getParameter("form-definition");
           String formAttribute = parameters.getParameter("attribute-name");
   
  -        Form form = formManager.createForm(resolver.resolveURI(formSource));
  -
  -        Request request = ObjectModelHelper.getRequest(objectModel);
  -        request.setAttribute(formAttribute, form);
  +        Source source = null;
  +        try {
  +            source = resolver.resolveURI(formSource);
  +            Form form = formManager.createForm(source);
  +
  +            Request request = ObjectModelHelper.getRequest(objectModel);
  +            request.setAttribute(formAttribute, form);
  +        } finally {
  +            resolver.release(source);
  +        }
   
           return null;
       }
  
  
  

Mime
View raw message