cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r580312 [4/5] - in /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl: ./ src/main/java/org/apache/cocoon/forms/ src/main/java/org/apache/cocoon/forms/binding/ src/main/java/org/apache/cocoon/forms/binding/library/ src/main/java/org/apache...
Date Fri, 28 Sep 2007 11:33:18 GMT
Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterFilterField.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterFilterField.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterFilterField.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterFilterField.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
 */
 package org.apache.cocoon.forms.formmodel;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.cocoon.forms.binding.BindingException;
 import org.apache.cocoon.forms.event.ValueChangedEvent;
 import org.apache.cocoon.forms.event.ValueChangedListener;
@@ -52,7 +51,7 @@
                     try {
                         repeater.setFilter(field, event.getNewValue());
                     } catch (BindingException e) {
-                        throw new CascadingRuntimeException("Error setting filter", e);
+                        throw new RuntimeException("Error setting filter", e);
                     }
                 }
             }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/AbstractBaseAlgorithm.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/AbstractBaseAlgorithm.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/AbstractBaseAlgorithm.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/AbstractBaseAlgorithm.java Fri Sep 28 04:33:12 2007
@@ -20,27 +20,19 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.logger.Logger;
 import org.apache.cocoon.forms.formmodel.CalculatedFieldAlgorithm;
 
 /**
  * Abstract base class for algorithms. 
  * 
- * <p> This class implements the getTriggerWidgets method and holds the triggers list. It also implements
- * Contextualizable and LogEnabled to give the algorithms access to the cocoon's ObjectModel and Loggers.
+ * <p> This class implements the getTriggerWidgets method and holds the triggers list.
  * </p>
  * 
  * @version $Id$
  */
-public abstract class AbstractBaseAlgorithm implements CalculatedFieldAlgorithm, LogEnabled, Contextualizable {
+public abstract class AbstractBaseAlgorithm implements CalculatedFieldAlgorithm {
 
     protected List triggers = new ArrayList();
-    private Logger logger = null;
-    private Context context = null;
     
     public Iterator getTriggerWidgets() {
         return triggers.iterator();
@@ -48,22 +40,6 @@
     
     public void addTrigger(String widget) {
         this.triggers.add(widget);
-    }
-
-    public void enableLogging(Logger logger) {
-        this.logger = logger;
-    }
-    
-    protected Logger getLogger() {
-        return this.logger;
-    }
-
-    public void contextualize(Context context) throws ContextException {
-        this.context = context;
-    }
-    
-    protected Context getContext() {
-        return this.context;
     }
 
     public void clearTriggers() {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/AbstractBaseAlgorithmBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/AbstractBaseAlgorithmBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/AbstractBaseAlgorithmBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/AbstractBaseAlgorithmBuilder.java Fri Sep 28 04:33:12 2007
@@ -18,16 +18,6 @@
 
 import java.util.StringTokenizer;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.components.LifecycleHelper;
-import org.apache.cocoon.forms.formmodel.CalculatedFieldAlgorithm;
 import org.apache.cocoon.forms.formmodel.CalculatedFieldAlgorithmBuilder;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.w3c.dom.Element;
@@ -43,14 +33,9 @@
  * </p>
  * @version $Id$
  */
-public abstract class AbstractBaseAlgorithmBuilder implements CalculatedFieldAlgorithmBuilder, LogEnabled, Contextualizable, Serviceable {
-
-    private Logger logger;
-    protected Context context;
-    private ServiceManager manager;
+public abstract class AbstractBaseAlgorithmBuilder implements CalculatedFieldAlgorithmBuilder {
 
     protected void setup(Element algorithmElement, AbstractBaseAlgorithm algorithm) throws Exception {
-        setupComponent(algorithm);        
         setupTriggers(algorithmElement, algorithm);
     }
 
@@ -66,25 +51,5 @@
             String fname = stok.nextToken();
             algorithm.addTrigger(fname);
         }        
-    }
-
-    public void enableLogging(Logger logger) {
-        this.logger = logger;
-    }
-    
-    protected Logger getLogger() {
-        return this.logger;
-    }
-
-    public void contextualize(Context context) throws ContextException {
-        this.context = context;
-    }
-    
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
-
-    public void setupComponent(CalculatedFieldAlgorithm algorithm) throws Exception {
-        LifecycleHelper.setupComponent(algorithm, logger, context, manager, null);        
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/JavaAlgorithmBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/JavaAlgorithmBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/JavaAlgorithmBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/JavaAlgorithmBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,8 +16,13 @@
  */
 package org.apache.cocoon.forms.formmodel.algorithms;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.formmodel.CalculatedFieldAlgorithm;
 import org.apache.cocoon.forms.util.DomHelper;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 import org.w3c.dom.Element;
 
 
@@ -29,19 +34,42 @@
  *
  * @version $Id$
  */
-public class JavaAlgorithmBuilder extends AbstractBaseAlgorithmBuilder {
+public class JavaAlgorithmBuilder extends AbstractBaseAlgorithmBuilder implements BeanFactoryAware{
+
+    private BeanFactory beanFactory;
+    
+    public void setBeanFactory(BeanFactory beanFactory)
+                                                  throws BeansException
+    {
+        this.beanFactory = beanFactory;        
+    }
 
     public CalculatedFieldAlgorithm build(Element algorithmElement) throws Exception {
-        String clazzname = DomHelper.getAttribute(algorithmElement, "class");
-        Class clazz = Thread.currentThread().getContextClassLoader().loadClass(clazzname);
-        if (AbstractBaseAlgorithm.class.isAssignableFrom(clazz)) {
-            AbstractBaseAlgorithm algorithm = (AbstractBaseAlgorithm) clazz.newInstance();
-            super.setup(algorithmElement, algorithm);
-            return algorithm;
-        } else {
-            CalculatedFieldAlgorithm algorithm = (CalculatedFieldAlgorithm) clazz.newInstance();
-            super.setupComponent(algorithm);
-            return algorithm;
+
+        // hard way deprecation
+        if (DomHelper.getAttribute(algorithmElement, "class", null) != null) {
+            throw new RuntimeException("The 'class' attribute is not supported anymore at "
+                                       + DomHelper.getLocationObject( algorithmElement )
+                                       + ". Use a 'ref' attribute to address a Spring bean");
+        }
+        
+        String name = DomHelper.getAttribute(algorithmElement, "ref");
+        try {
+            Class clazz = beanFactory.getType(name);
+            if (AbstractBaseAlgorithm.class.isAssignableFrom(clazz)) {
+                AbstractBaseAlgorithm algorithm = (AbstractBaseAlgorithm)beanFactory.getBean( name );
+                super.setup(algorithmElement, algorithm);
+                return algorithm;
+            } if (CalculatedFieldAlgorithm.class.isAssignableFrom(clazz)) {
+                CalculatedFieldAlgorithm algorithm = (CalculatedFieldAlgorithm)beanFactory.getBean( name );
+                return algorithm;
+            } else {
+                throw new FormsException("Spring bean " + name + " is not a " + CalculatedFieldAlgorithm.class.getName(), DomHelper.getLocationObject( algorithmElement ));
+            }
+        } catch(NoSuchBeanDefinitionException nsbde) {
+            throw new FormsException("Spring bean " + name + " does not exist in Spring context", DomHelper.getLocationObject( algorithmElement ));
+        } catch(BeansException be) {
+            throw new FormsException("Spring bean " + name + " cannot be retrieved/instantiated", DomHelper.getLocationObject( algorithmElement ));
         }
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/JavaScript.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/JavaScript.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/JavaScript.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/JavaScript.java Fri Sep 28 04:33:12 2007
@@ -20,7 +20,6 @@
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.cocoon.forms.datatype.Datatype;
 import org.apache.cocoon.forms.formmodel.CalculatedFieldAlgorithm;
 import org.apache.cocoon.forms.formmodel.Form;
@@ -45,7 +44,7 @@
             // at least between different numbers types and eventually between numbers and strings.
             return JavaScriptHelper.callFunction(this.jsfunction, null, new Object[]{form, parent}, null);
         } catch (Exception e) {
-            throw new CascadingRuntimeException("Error invoking JavaScript server side calculation", e);
+            throw new RuntimeException("Error invoking JavaScript server side calculation", e);
         }        
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/RepeatedFormula.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/RepeatedFormula.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/RepeatedFormula.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/RepeatedFormula.java Fri Sep 28 04:33:12 2007
@@ -20,7 +20,6 @@
 import java.util.Collection;
 import java.util.Iterator;
 
-import org.apache.avalon.framework.CascadingError;
 import org.apache.cocoon.forms.datatype.Datatype;
 import org.apache.cocoon.forms.formmodel.CannotYetResolveWarning;
 import org.apache.cocoon.forms.formmodel.ExpressionContextImpl;
@@ -103,7 +102,7 @@
         } catch (CannotYetResolveWarning w) {
             return null;
         } catch (ExpressionException e) {
-            throw new CascadingError("Error evaluating calculated field formula", e);
+            throw new Error("Error evaluating calculated field formula", e);
         }
     }
     

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/SimpleFormula.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/SimpleFormula.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/SimpleFormula.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/SimpleFormula.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.formmodel.algorithms;
 
-import org.apache.avalon.framework.CascadingError;
 import org.apache.cocoon.forms.datatype.Datatype;
 import org.apache.cocoon.forms.formmodel.CannotYetResolveWarning;
 import org.apache.cocoon.forms.formmodel.ExpressionContextImpl;
@@ -65,7 +64,7 @@
         } catch (CannotYetResolveWarning w) {
             return null;
         } catch (ExpressionException e) {
-            throw new CascadingError("Error evaluating calculated field formula", e);
+            throw new Error("Error evaluating calculated field formula", e);
         }
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/SimpleFormulaBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/SimpleFormulaBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/SimpleFormulaBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/algorithms/SimpleFormulaBuilder.java Fri Sep 28 04:33:12 2007
@@ -19,8 +19,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.forms.expression.ExpressionManager;
 import org.apache.cocoon.forms.formmodel.CalculatedFieldAlgorithm;
 import org.apache.cocoon.forms.util.DomHelper;
@@ -42,8 +40,6 @@
 public class SimpleFormulaBuilder extends AbstractBaseAlgorithmBuilder {
 
     private ExpressionManager expressionManager;
-    private ServiceManager serviceManager;
-    
     
     public CalculatedFieldAlgorithm build(Element algorithmElement) throws Exception {
         String formula = DomHelper.getAttribute(algorithmElement, "eval");
@@ -67,14 +63,8 @@
         }
     }
 
-    public void service(ServiceManager serviceManager) throws ServiceException {
-        this.serviceManager = serviceManager;
-        this.expressionManager = (ExpressionManager)serviceManager.lookup(ExpressionManager.ROLE);
-    }
-
-    public void dispose() {
-        this.serviceManager.release(this.expressionManager);
-        this.expressionManager = null;
-        this.serviceManager = null;
+    public void setExpressionManager( ExpressionManager expressionManager )
+    {
+        this.expressionManager = expressionManager;
     }    
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java Fri Sep 28 04:33:12 2007
@@ -20,10 +20,6 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceSelector;
-
 import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.formmodel.WidgetDefinitionBuilder;
@@ -32,6 +28,8 @@
 import org.apache.cocoon.util.location.LocationAttributes;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.Element;
 
 /**
@@ -39,12 +37,13 @@
  *
  * @version $Id$
  */
-public class Library extends AbstractLogEnabled {
+public class Library {
 
+    private static Log LOG = LogFactory.getLog( Library.class );
     public static final String SEPARATOR = ":";
 
     // managed instances
-    protected ServiceSelector widgetDefinitionBuilderSelector;
+    protected Map widgetDefinitionBuilders;
 
     // own references
     protected LibraryManager manager;
@@ -60,11 +59,11 @@
     protected WidgetDefinitionBuilderContext context;
 
 
-    public Library(LibraryManager lm, ServiceSelector builderSelector) {
+    public Library(LibraryManager lm, Map builderSelector) {
         manager = lm;
         context = new WidgetDefinitionBuilderContext();
         context.setLocalLibrary(this);
-        widgetDefinitionBuilderSelector = builderSelector;
+        widgetDefinitionBuilders = builderSelector;
     }
 
     public void setSourceURI(String uri) {
@@ -161,19 +160,17 @@
 
         // add def to our list of defs
         definitions.put(definition.getId(), definition);
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug(this + ": Added definition '" + definition.getId() + "'");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug(this + ": Added definition '" + definition.getId() + "'");
         }
     }
 
     protected WidgetDefinition buildWidgetDefinition(Element widgetDefinition) throws Exception {
         String widgetName = widgetDefinition.getLocalName();
-        WidgetDefinitionBuilder builder;
-        try {
-            builder = (WidgetDefinitionBuilder) widgetDefinitionBuilderSelector.select(widgetName);
-        } catch (ServiceException e) {
+        WidgetDefinitionBuilder builder = (WidgetDefinitionBuilder) widgetDefinitionBuilders.get(widgetName);
+        if (builder == null) {
             throw new LibraryException("Unknown kind of widget '" + widgetName + "'.",
-                                       e, DomHelper.getLocationObject(widgetDefinition));
+                                       DomHelper.getLocationObject(widgetDefinition));
         }
 
         context.setSuperDefinition(null);
@@ -204,6 +201,12 @@
             Library lib = manager.get(dependencyURI, sourceURI);
             return lib != null && this.shared == lib.shared;
         }
+    }
+
+
+    public void setWidgetDefinitionBuilderSelector( Map widgetDefinitionBuilderSelector )
+    {
+        this.widgetDefinitionBuilders = widgetDefinitionBuilderSelector;
     }
 
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java Fri Sep 28 04:33:12 2007
@@ -16,79 +16,43 @@
  */
 package org.apache.cocoon.forms.formmodel.library;
 
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceException;
-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.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 
+import org.apache.cocoon.core.xml.SAXParser;
 import org.apache.cocoon.forms.CacheManager;
-import org.apache.cocoon.forms.formmodel.WidgetDefinitionBuilder;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.apache.cocoon.util.location.LocationImpl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
+import java.util.Map;
+
 /**
  * @version $Id$
  *
  */
-public class LibraryManagerImpl extends AbstractLogEnabled
-                                implements LibraryManager, Serviceable, Configurable,
-                                           Disposable, ThreadSafe, Component {
+public class LibraryManagerImpl implements LibraryManager {
 
+    private static Log LOG = LogFactory.getLog( LibraryManagerImpl.class );
     private static final String PREFIX = "CocoonFormsLibrary:";
 
-    private ServiceManager manager;
+    private SourceResolver sourceResolver;
     private CacheManager cacheManager;
-
-    private ServiceSelector widgetDefinitionBuilderSelector;
-
-    //
-    // Lifecycle
-    //
-
-    public void configure(Configuration configuration) throws ConfigurationException {
-        // TODO Read config to "preload" libraries
-    }
-
-    public void service(ServiceManager serviceManager) throws ServiceException {
-        this.manager = serviceManager;
-        this.cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
-        this.widgetDefinitionBuilderSelector = (ServiceSelector) manager.lookup(WidgetDefinitionBuilder.class.getName() + "Selector");
-    }
-
-    public void dispose() {
-        if (this.cacheManager != null) {
-            this.manager.release(this.cacheManager);
-            this.cacheManager = null;
-        }
-        this.manager = null;
-    }
-
-    //
-    // Business methods
-    //
+    private Map widgetDefinitionBuilders;
+    private SAXParser parser;
 
     public Library get(String sourceURI) throws LibraryException {
         return get(sourceURI, null);
     }
 
     public Library get(String sourceURI, String baseURI) throws LibraryException {
-        SourceResolver sourceResolver = null;
         Source source = null;
         try {
             try {
-                sourceResolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
                 source = sourceResolver.resolveURI(sourceURI, baseURI, null);
             } catch (Exception e) {
                 throw new LibraryException("Unable to resolve library.",
@@ -97,18 +61,18 @@
 
             Library lib = (Library) this.cacheManager.get(source, PREFIX);
             if (lib != null && lib.dependenciesHaveChanged()) {
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("Library IS REMOVED from cache: '" + sourceURI + "' relative to '" + baseURI + "'");
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Library IS REMOVED from cache: '" + sourceURI + "' relative to '" + baseURI + "'");
                 }
                 this.cacheManager.remove(source, PREFIX); // evict?
                 return null;
             }
 
-            if (getLogger().isDebugEnabled()) {
+            if (LOG.isDebugEnabled()) {
                 if (lib != null) {
-                    getLogger().debug("Library IS in cache: '" + sourceURI + "' relative to '" + baseURI + "'");
+                    LOG.debug("Library IS in cache: '" + sourceURI + "' relative to '" + baseURI + "'");
                 } else {
-                    getLogger().debug("Library IS NOT in cache: '" + sourceURI + "' relative to '" + baseURI + "'");
+                    LOG.debug("Library IS NOT in cache: '" + sourceURI + "' relative to '" + baseURI + "'");
                 }
             }
 
@@ -117,9 +81,6 @@
             if (source != null) {
                 sourceResolver.release(source);
             }
-            if (sourceResolver != null) {
-                manager.release(sourceResolver);
-            }
         }
     }
 
@@ -128,16 +89,14 @@
     }
 
     public Library load(String sourceURI, String baseURI) throws LibraryException {
-        SourceResolver sourceResolver = null;
         Source source = null;
 
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Loading library: '" + sourceURI + "' relative to '" + baseURI + "'");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Loading library: '" + sourceURI + "' relative to '" + baseURI + "'");
         }
 
         try {
             try {
-                sourceResolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
                 source = sourceResolver.resolveURI(sourceURI, baseURI, null);
             } catch (Exception e) {
                 throw new LibraryException("Unable to resolve library.",
@@ -146,22 +105,22 @@
 
             Library lib = (Library) this.cacheManager.get(source, PREFIX);
             if (lib != null && lib.dependenciesHaveChanged()) {
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("Library IS EXPIRED in cache: '" + sourceURI + "' relative to '" + baseURI + "'");
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Library IS EXPIRED in cache: '" + sourceURI + "' relative to '" + baseURI + "'");
                 }
                 lib = null;
             }
 
             if (lib == null) {
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("Library IS NOT in cache, loading: '" + sourceURI + "' relative to '" + baseURI + "'");
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Library IS NOT in cache, loading: '" + sourceURI + "' relative to '" + baseURI + "'");
                 }
 
                 try {
                     InputSource inputSource = new InputSource(source.getInputStream());
                     inputSource.setSystemId(source.getURI());
 
-                    Document doc = DomHelper.parse(inputSource, this.manager);
+                    Document doc = DomHelper.parse(inputSource, this.parser);
                     lib = newLibrary();
                     lib.buildLibrary(doc.getDocumentElement());
 
@@ -177,19 +136,35 @@
             if (source != null) {
                 sourceResolver.release(source);
             }
-            if (sourceResolver != null) {
-                manager.release(sourceResolver);
-            }
         }
     }
 
     public Library newLibrary() {
-        Library lib = new Library(this, widgetDefinitionBuilderSelector);
-        lib.enableLogging(getLogger());
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Created a new library: " + lib);
+        Library lib = new Library(this, widgetDefinitionBuilders);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Created a new library: " + lib);
         }
 
         return lib;
+    }
+
+    public void setWidgetDefinitionBuilders( Map widgetDefinitionBuilders )
+    {
+        this.widgetDefinitionBuilders = widgetDefinitionBuilders;
+    }
+
+    public void setCacheManager( CacheManager cacheManager )
+    {
+        this.cacheManager = cacheManager;
+    }
+
+    public void setSourceResolver( SourceResolver sourceResolver )
+    {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public void setParser( SAXParser parser )
+    {
+        this.parser = parser;
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/DefaultTreeModel.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/DefaultTreeModel.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/DefaultTreeModel.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/DefaultTreeModel.java Fri Sep 28 04:33:12 2007
@@ -144,37 +144,4 @@
         parent.add("2", new DefaultTreeNode("by the application using flowscript, event listeners, etc."));
         return new DefaultTreeModel(root);
     }
-
-    /**
-     * The classical Swing sample tree model, that can be used for demonstration purposes.
-     */
-    public static class Sample extends DefaultTreeModel {
-        public Sample() {
-            super(new DefaultTreeNode("root"));
-            DefaultTreeNode root = (DefaultTreeNode)getRoot();
-
-            DefaultTreeNode      parent;
-            
-            parent = new DefaultTreeNode("Colors");
-            root.add("colors", parent);
-            parent.add("blue", new DefaultTreeNode("Blue"));
-            parent.add("violet", new DefaultTreeNode("Violet"));
-            parent.add("red", new DefaultTreeNode("Red"));
-            parent.add("yellow", new DefaultTreeNode("Yellow"));
-    
-            parent = new DefaultTreeNode("Sports");
-            root.add("sports", parent);
-            parent.add("basketball", new DefaultTreeNode("Basketball"));
-            parent.add("soccer", new DefaultTreeNode("Soccer"));
-            parent.add("football", new DefaultTreeNode("Football"));
-            parent.add("hockey", new DefaultTreeNode("Hockey"));
-    
-            parent = new DefaultTreeNode("Food");
-            root.add("food", parent);
-            parent.add("hotdogs", new DefaultTreeNode("Hot Dogs"));
-            parent.add("pizza", new DefaultTreeNode("Pizza"));
-            parent.add("ravioli", new DefaultTreeNode("Ravioli"));
-            parent.add("bananas", new DefaultTreeNode("Bananas"));
-        }
-    }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/JavaTreeModelDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/JavaTreeModelDefinition.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/JavaTreeModelDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/JavaTreeModelDefinition.java Fri Sep 28 04:33:12 2007
@@ -16,49 +16,37 @@
  */
 package org.apache.cocoon.forms.formmodel.tree;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.cocoon.components.LifecycleHelper;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
 
 /**
- * A {@link org.apache.cocoon.forms.formmodel.tree.TreeModelDefinition} based on an Java class
+ * A {@link org.apache.cocoon.forms.formmodel.tree.TreeModelDefinition} based on a Spring bean
  * implementing {@link org.apache.cocoon.forms.formmodel.tree.TreeModel}.
  *
  * @version $Id$
  */
-public class JavaTreeModelDefinition extends AbstractLogEnabled
-                                     implements TreeModelDefinition, Contextualizable, Serviceable {
+public class JavaTreeModelDefinition implements TreeModelDefinition, BeanFactoryAware {
 
-    private Class modelClass;
+    private String modelBeanRef;
+    private BeanFactory beanFactory;
 
-    Context ctx;
-    ServiceManager manager;
-
-    public void contextualize(Context context) throws ContextException {
-        this.ctx = context;
-    }
-
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
+    public void setBeanFactory( BeanFactory beanFactory)
+                                                  throws BeansException
+    {
+        this.beanFactory = beanFactory;
     }
 
-    public void setModelClass(Class clazz) {
-        this.modelClass = clazz;
+    public void setModelBeanRef(String beanId) {
+        this.modelBeanRef = beanId;
     }
 
     public TreeModel createInstance() {
         TreeModel model;
         try {
-            model = (TreeModel)modelClass.newInstance();
-            LifecycleHelper.setupComponent(model, getLogger(), ctx, manager, null);
+            model = (TreeModel)beanFactory.getBean( modelBeanRef );
         } catch (Exception e) {
-            throw new CascadingRuntimeException("Cannot instanciate class " + modelClass.getName(), e);
+            throw new RuntimeException("Cannot get an instance of Spring bean " + modelBeanRef, e);
         }
 
         return model;

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/SourceTreeModel.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/SourceTreeModel.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/SourceTreeModel.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/SourceTreeModel.java Fri Sep 28 04:33:12 2007
@@ -21,7 +21,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.cocoon.util.WildcardMatcherHelper;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceResolver;
@@ -71,7 +70,7 @@
             try {
                 this.rootSource = (TraversableSource) this.resolver.resolveURI(this.rootURL);
             } catch (Exception e) {
-                throw new CascadingRuntimeException("Cannot resolve " + this.rootURL, e);
+                throw new RuntimeException("Cannot resolve " + this.rootURL, e);
             }
         }
         return this.rootSource;
@@ -84,7 +83,7 @@
                 // Return children if it's a collection, null otherwise
                 return dir.isCollection() ? filterChildren(dir.getChildren()) : null;
             } catch (SourceException e) {
-                throw new CascadingRuntimeException("getChildren", e);
+                throw new RuntimeException("getChildren", e);
             }
         } else {
             return null;
@@ -156,7 +155,7 @@
         try {
             return ((TraversableSource)parent).getChild(key);
         } catch (SourceException e) {
-            throw new CascadingRuntimeException("getChild", e);
+            throw new RuntimeException("getChild", e);
         }
     }
     

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,66 +16,57 @@
  */
 package org.apache.cocoon.forms.formmodel.tree.builder;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-
-import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.formmodel.tree.JavaTreeModelDefinition;
 import org.apache.cocoon.forms.formmodel.tree.TreeModel;
 import org.apache.cocoon.forms.formmodel.tree.TreeModelDefinition;
 import org.apache.cocoon.forms.util.DomHelper;
 
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 import org.w3c.dom.Element;
 
 /**
- * Builds a {@link TreeModelDefinition} based on an arbitrary Java class.
- * Avalon lifecycle will be run on the target class when instanciated.
+ * Builds a {@link TreeModelDefinition} based on an Spring bean subclassing {@TreeModel}.
  *
  * @version $Id$
  */
-public class JavaTreeModelDefinitionBuilder extends AbstractLogEnabled
-                                            implements TreeModelDefinitionBuilder, Contextualizable,
-                                                       Serviceable {
-
-    Context ctx;
-    ServiceManager manager;
+public class JavaTreeModelDefinitionBuilder implements TreeModelDefinitionBuilder, BeanFactoryAware {
 
+    private BeanFactory beanFactory;
     
-    public void contextualize(Context context) throws ContextException {
-        this.ctx = context;
-    }
-
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
+    public void setBeanFactory( BeanFactory beanFactory )
+                                                  throws BeansException
+    {
+        this.beanFactory = beanFactory;
     }
 
     public TreeModelDefinition build(Element treeModelElement) throws Exception {
-        String className = DomHelper.getAttribute(treeModelElement, "class");
 
-        Class modelClass;
-        try {
-            modelClass = Thread.currentThread().getContextClassLoader().loadClass(className);
-        } catch(Exception e) {
-            throw new FormsException("Cannot load class '" + className + "'.",
-                                     e, DomHelper.getLocationObject(treeModelElement));
+        // hard way deprecation
+        if (DomHelper.getAttribute(treeModelElement, "class", null) != null) {
+            throw new RuntimeException("The 'class' attribute is not supported anymore at "
+                                       + DomHelper.getLocationObject( treeModelElement )
+                                       + ". Use a 'ref' attribute to address a Spring bean");
         }
-
-        if (!TreeModel.class.isAssignableFrom(modelClass)) {
-            throw new FormsException("Class '" + className + "' doesn't implement TreeModel.",
+        
+        String beanRefId = DomHelper.getAttribute(treeModelElement, "ref");
+        try {
+            Class clazz = beanFactory.getType(beanRefId);
+            if (!TreeModel.class.isAssignableFrom(clazz)) {
+                throw new FormsException("Spring Bean '" + beanRefId + "' doesn't implement TreeModel.",
+                                         DomHelper.getLocationObject(treeModelElement));
+            }
+        } catch(NoSuchBeanDefinitionException nsbde) {
+            throw new FormsException("Spring Bean '" + beanRefId + "' doesn't exists.",
                                      DomHelper.getLocationObject(treeModelElement));
         }
 
         JavaTreeModelDefinition definition = new JavaTreeModelDefinition();
-
-        LifecycleHelper.setupComponent(definition, getLogger(), ctx, manager, null);
-
-        definition.setModelClass(modelClass);
+        definition.setBeanFactory( beanFactory );
+        definition.setModelBeanRef( beanRefId );
 
         return definition;
     }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/SourceTreeModelDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/SourceTreeModelDefinitionBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/SourceTreeModelDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/SourceTreeModelDefinitionBuilder.java Fri Sep 28 04:33:12 2007
@@ -19,10 +19,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.forms.formmodel.tree.SourceTreeModelDefinition;
 import org.apache.cocoon.forms.formmodel.tree.TreeModelDefinition;
@@ -35,18 +31,9 @@
  * 
  * @version $Id$
  */
-public class SourceTreeModelDefinitionBuilder extends AbstractLogEnabled
-    implements Serviceable, TreeModelDefinitionBuilder {
-
-    private ServiceManager manager;
-
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
-    }
+public class SourceTreeModelDefinitionBuilder implements TreeModelDefinitionBuilder {
 
+    private SourceResolver sourceResolver;
     /**
      * @see org.apache.cocoon.forms.formmodel.tree.builder.TreeModelDefinitionBuilder#build(org.w3c.dom.Element)
      */
@@ -67,7 +54,7 @@
                     getPatterns(dirSet, "exclude"));
         }
         
-        definition.setSourceResolver((SourceResolver)this.manager.lookup(SourceResolver.ROLE));
+        definition.setSourceResolver(sourceResolver);
         
         return definition;
     }
@@ -85,6 +72,11 @@
             result.add(pattern);
         }
         return result;
+    }
+
+    public void setSourceResolver( SourceResolver sourceResolver )
+    {
+        this.sourceResolver = sourceResolver;
     }
 
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java Fri Sep 28 04:33:12 2007
@@ -17,8 +17,7 @@
 package org.apache.cocoon.forms.formmodel.tree.builder;
 
 import java.util.Iterator;
-
-import org.apache.avalon.framework.service.ServiceSelector;
+import java.util.Map;
 
 import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.forms.FormsException;
@@ -38,6 +37,8 @@
  */
 public class TreeDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
+    private Map treeModelDefinitionBuilders;
+    
     public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
         TreeDefinition definition = new TreeDefinition();
         setupDefinition(widgetElement, definition);
@@ -68,15 +69,10 @@
         Element modelElt = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "tree-model", false);
         if (modelElt != null) {
             String type = DomHelper.getAttribute(modelElt, "type");
-            ServiceSelector selector =
-                (ServiceSelector)this.serviceManager.lookup(TreeModelDefinitionBuilder.ROLE + "Selector");
 
-            TreeModelDefinitionBuilder builder = (TreeModelDefinitionBuilder)selector.select(type);
-            try {
+            TreeModelDefinitionBuilder builder = (TreeModelDefinitionBuilder)treeModelDefinitionBuilders.get(type);
+            if (builder != null) {
                 definition.setModelDefinition(builder.build(modelElt));
-            } finally {
-                selector.release(builder);
-                serviceManager.release(selector);
             }
         }
 
@@ -88,5 +84,10 @@
         //TODO: allow child widgets, that will be attached to each node of the tree
         //It may be useful to add TreeModel.getNodeType(Object) so that the container holding child
         //widgets can have a value used by a union widget.
+    }
+
+    public void setTreeModelDefinitionBuilders( Map treeModelDefinitionBuilders )
+    {
+        this.treeModelDefinitionBuilders = treeModelDefinitionBuilders;
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/util/DomHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/util/DomHelper.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/util/DomHelper.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/util/DomHelper.java Fri Sep 28 04:33:12 2007
@@ -17,6 +17,7 @@
 package org.apache.cocoon.forms.util;
 
 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -25,11 +26,9 @@
 import java.util.Map;
 import javax.xml.XMLConstants;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.excalibur.xml.sax.SAXParser;
 import org.apache.excalibur.xml.sax.XMLizable;
 
+import org.apache.cocoon.core.xml.SAXParser;
 import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationAttributes;
@@ -38,6 +37,8 @@
 import org.apache.cocoon.xml.dom.DOMStreamer;
 
 import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Document;
@@ -49,7 +50,6 @@
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotSupportedException;
 
 /**
  * Helper class to create and retrieve information from DOM-trees. It provides
@@ -67,6 +67,8 @@
 public class DomHelper {
 
     public static final String XMLNS_URI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+    
+    private static Log LOG = LogFactory.getLog( DomHelper.class );
 
     public static Location getLocationObject(Element element) {
         return LocationAttributes.getLocation(element);
@@ -307,20 +309,15 @@
      * @param inputSource the inputSource to read the document from
      * @param manager the service manager where to lookup the entity resolver
      */
-    public static Document parse(InputSource inputSource, ServiceManager manager)
-    throws SAXException, SAXNotSupportedException, IOException, ServiceException {
+    public static Document parse(InputSource inputSource, SAXParser parser)
+    throws SAXException, IOException {
 
-        SAXParser parser = (SAXParser)manager.lookup(SAXParser.ROLE);
         DOMBuilder builder = new DOMBuilder();
 
         // Enhance the sax stream with location information
         ContentHandler locationHandler = new LocationAttributes.Pipe(builder);
 
-        try {
-            parser.parse(inputSource, locationHandler);
-        } finally {
-            manager.release(parser);
-        }
+        parser.parse(inputSource, locationHandler);
 
         return builder.getDocument();
     }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/util/JavaScriptHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/util/JavaScriptHelper.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/util/JavaScriptHelper.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/util/JavaScriptHelper.java Fri Sep 28 04:33:12 2007
@@ -21,7 +21,6 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.cocoon.components.flow.FlowHelper;
 import org.apache.cocoon.components.flow.javascript.JavaScriptFlowHelper;
 import org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptFlowHelper;
@@ -132,7 +131,7 @@
                 try {
                     ScriptableObject.defineClass(_rootScope, FOM_SimpleCocoon.class);
                 } catch (Exception e) {
-                    throw new CascadingRuntimeException("Cannot setup a root context with a cocoon object for javascript", e);
+                    throw new RuntimeException("Cannot setup a root context with a cocoon object for javascript", e);
                 }
             } finally {
                 Context.exit();
@@ -150,7 +149,7 @@
                 scope.put("cocoon", scope, cocoon);
                 return scope;
             } catch (Exception e) {
-                throw new CascadingRuntimeException("Cannot setup a root context with a cocoon object for javascript", e);
+                throw new RuntimeException("Cannot setup a root context with a cocoon object for javascript", e);
             } finally {
                 Context.exit();
             }
@@ -190,7 +189,7 @@
                 scope = ctx.newObject(parentScope);
             } catch (Exception e) {
                 // Should normally not happen
-                throw new CascadingRuntimeException("Cannot create script scope", e);
+                throw new RuntimeException("Cannot create script scope", e);
             }
             scope.setParentScope(parentScope);
 
@@ -231,7 +230,7 @@
                     newScope = ctx.newObject(scope);
                 } catch (Exception e) {
                     // Should normally not happen
-                    throw new CascadingRuntimeException("Cannot create function scope", e);
+                    throw new RuntimeException("Cannot create function scope", e);
                 }
                 newScope.setParentScope(scope);
                 scope = newScope;

Added: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/ConfigurableWidgetValidator.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/ConfigurableWidgetValidator.java?rev=580312&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/ConfigurableWidgetValidator.java (added)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/ConfigurableWidgetValidator.java Fri Sep 28 04:33:12 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.validation;
+
+import org.w3c.dom.Element;
+
+/**
+ * A {@link WidgetValidator} that can recieve a configuration {@link Element}
+ * 
+ * @version $Id$
+ */
+public interface ConfigurableWidgetValidator extends WidgetValidator {
+    
+    /**
+     * Set the configuration Element
+     */
+    void setConfiguration(Element element) throws Exception;
+}

Propchange: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/ConfigurableWidgetValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/ConfigurableWidgetValidator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/AbstractJavaValidator.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/AbstractJavaValidator.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/AbstractJavaValidator.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/AbstractJavaValidator.java Fri Sep 28 04:33:12 2007
@@ -16,13 +16,10 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.cocoon.forms.validation.ConfigurableWidgetValidator;
 import org.apache.cocoon.forms.validation.ValidationError;
-import org.apache.cocoon.util.ConfigurationUtil;
 import org.apache.excalibur.xml.sax.XMLizable;
 import org.w3c.dom.Element;
 
@@ -32,16 +29,11 @@
  *
  * @version $Id$
  */
-public abstract class AbstractJavaValidator
-    implements Configurable {
+public abstract class AbstractJavaValidator implements ConfigurableWidgetValidator {
 
     protected ValidationError validationError;
 
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration config) throws ConfigurationException {
-        final Element element = ConfigurationUtil.toElement(config);
+    public void setConfiguration(Element element) throws Exception {
         this.validationError = this.buildFailMessage(element);
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/AssertValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/AssertValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/AssertValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/AssertValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.datatype.validationruleimpl.AssertValidationRuleBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.validation.WidgetValidator;
@@ -29,7 +28,7 @@
  * @version $Id$
  */
 public class AssertValidatorBuilder extends AssertValidationRuleBuilder
-    implements WidgetValidatorBuilder, ThreadSafe {
+    implements WidgetValidatorBuilder {
 
     /**
      * @see org.apache.cocoon.forms.validation.WidgetValidatorBuilder#build(org.w3c.dom.Element, org.apache.cocoon.forms.formmodel.WidgetDefinition)

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/CaptchaValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/CaptchaValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/CaptchaValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/CaptchaValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.validation.WidgetValidator;
 import org.apache.cocoon.forms.validation.WidgetValidatorBuilder;
@@ -29,7 +28,7 @@
  * @see org.apache.cocoon.forms.validation.impl.CaptchaValidator
  * @version $Id$
  */
-public class CaptchaValidatorBuilder implements WidgetValidatorBuilder, ThreadSafe {
+public class CaptchaValidatorBuilder implements WidgetValidatorBuilder {
 
     public WidgetValidator build(Element validationRuleElement,
             WidgetDefinition definition) throws Exception {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/EmailValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/EmailValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/EmailValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/EmailValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.datatype.validationruleimpl.EmailValidationRuleBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.validation.WidgetValidator;
@@ -29,7 +28,7 @@
  * @version $Id$
  */
 public class EmailValidatorBuilder extends EmailValidationRuleBuilder 
-    implements WidgetValidatorBuilder, ThreadSafe {
+    implements WidgetValidatorBuilder {
 
     /**
      * @see org.apache.cocoon.forms.validation.WidgetValidatorBuilder#build(org.w3c.dom.Element, org.apache.cocoon.forms.formmodel.WidgetDefinition)

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaClassValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaClassValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaClassValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaClassValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,75 +16,68 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.components.LifecycleHelper;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.cocoon.forms.validation.ConfigurableWidgetValidator;
 import org.apache.cocoon.forms.validation.WidgetValidator;
 import org.apache.cocoon.forms.validation.WidgetValidatorBuilder;
-import org.apache.cocoon.util.ClassUtils;
-import org.apache.cocoon.util.ConfigurationUtil;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
 import org.w3c.dom.Element;
 
 /**
- * A {@link org.apache.cocoon.forms.validation.WidgetValidatorBuilder} that creates java classes.
+ * A {@link org.apache.cocoon.forms.validation.WidgetValidatorBuilder} that uses Spring beans.
  * <p>
  * The syntax for this validator is as follows :<br/>
  * <pre>
- *   &lt;java class="com.my.SuperValidator"/&gt;
+ *   &lt;java ref="spring-bean-id"/&gt;
  * </pre>
  *
  * @version $Id$
  */
 public class JavaClassValidatorBuilder
-    implements WidgetValidatorBuilder, ThreadSafe, Serviceable, LogEnabled, Contextualizable  {
-
-    private ServiceManager manager;
-    private Logger logger;
-    private Context context;
+    implements WidgetValidatorBuilder, BeanFactoryAware {
     
-
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
+    private BeanFactory beanFactory;
+    
+    public void setBeanFactory( BeanFactory beanFactory )
+                                                  throws BeansException
+    {
+        this.beanFactory = beanFactory;
     }
 
     /**
      * @see org.apache.cocoon.forms.validation.WidgetValidatorBuilder#build(org.w3c.dom.Element, org.apache.cocoon.forms.formmodel.WidgetDefinition)
      */
-    public WidgetValidator build(Element validationRuleElement, WidgetDefinition definition) throws Exception {
-        String name = DomHelper.getAttribute(validationRuleElement, "class");
-
-        Object validator = ClassUtils.newInstance(name);
-        if (validator instanceof WidgetValidator) {
-            LifecycleHelper.setupComponent(validator, logger, context, manager, ConfigurationUtil.toConfiguration(validationRuleElement));
-            return (WidgetValidator)validator;
-        } else {
-            throw new Exception("Class " + validator.getClass() + " is not a " + WidgetValidator.class.getName());
+    public WidgetValidator build(Element validationRuleElement, WidgetDefinition definition) 
+    throws Exception {
+        
+        // hard way deprecation
+        if (DomHelper.getAttribute(validationRuleElement, "class", null) != null) {
+            throw new RuntimeException("The 'class' attribute is not supported anymore at "
+                                       + DomHelper.getLocationObject( validationRuleElement )
+                                       + ". Use a 'ref' attribute to address a Spring bean");
         }
-    }
-    
-    /**
-     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
-     */
-    public void enableLogging(Logger logger) {
-        this.logger = logger;
-    }
 
-    /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException {
-        this.context = context;
+        String name = DomHelper.getAttribute(validationRuleElement, "ref");
+
+        try {
+            Object validator = beanFactory.getBean( name );
+            if (validator instanceof WidgetValidator) {
+                if (validator instanceof ConfigurableWidgetValidator) {
+                    ((ConfigurableWidgetValidator)validator).setConfiguration( validationRuleElement );
+                }
+                return (WidgetValidator)validator;
+            } else {
+                throw new FormsException("Spring bean " + name + " is not a " 
+                                         + WidgetValidator.class.getName(), 
+                                         DomHelper.getLocationObject( validationRuleElement ));
+            }
+        } catch (BeansException be) {
+            throw new FormsException("Spring bean " + name + " does not exist in Spring context", 
+                                     DomHelper.getLocationObject( validationRuleElement ));
+        }
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidator.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidator.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidator.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidator.java Fri Sep 28 04:33:12 2007
@@ -18,14 +18,12 @@
 
 import java.util.Map;
 
-import org.apache.avalon.framework.CascadingRuntimeException;
-import org.apache.avalon.framework.context.Context;
-import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.forms.formmodel.Widget;
 import org.apache.cocoon.forms.util.JavaScriptHelper;
 import org.apache.cocoon.forms.validation.ValidationError;
 import org.apache.cocoon.forms.validation.ValidationErrorAware;
 import org.apache.cocoon.forms.validation.WidgetValidator;
+import org.apache.cocoon.processing.ProcessInfoProvider;
 import org.apache.excalibur.xml.sax.XMLizable;
 import org.mozilla.javascript.Function;
 
@@ -54,16 +52,16 @@
 public class JavaScriptValidator implements WidgetValidator {
     
     private final Function function;
-    private final Context avalonContext;
+    private final ProcessInfoProvider processInfoProvider;
     
-    public JavaScriptValidator(Context context, Function function) {
+    public JavaScriptValidator(ProcessInfoProvider processInfoProvider, Function function) {
         this.function = function;
-        this.avalonContext = context;
+        this.processInfoProvider = processInfoProvider;
     }
 
     public final boolean validate(Widget widget) {
 
-        Map objectModel = ContextHelper.getObjectModel(this.avalonContext);
+        Map objectModel = processInfoProvider.getObjectModel();
 
         Object result;
             
@@ -72,7 +70,7 @@
         } catch(RuntimeException re) {
             throw re; // rethrow
         } catch(Exception e) {
-            throw new CascadingRuntimeException("Error invoking JavaScript event handler", e);
+            throw new RuntimeException("Error invoking JavaScript event handler", e);
         }
 
         if (result == null) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,14 +16,11 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.util.JavaScriptHelper;
 import org.apache.cocoon.forms.validation.WidgetValidator;
 import org.apache.cocoon.forms.validation.WidgetValidatorBuilder;
+import org.apache.cocoon.processing.ProcessInfoProvider;
 import org.mozilla.javascript.Function;
 import org.w3c.dom.Element;
 
@@ -34,25 +31,21 @@
  * @version $Id$
  */
 public class JavaScriptValidatorBuilder 
-    implements WidgetValidatorBuilder, Contextualizable, ThreadSafe {
+    implements WidgetValidatorBuilder {
 
-    private Context avalonContext;
-    
     private static final String[] ARG_NAMES = {"widget"};
 
-    /* (non-Javadoc)
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException {
-        this.avalonContext = context;
-    }
-
+    private ProcessInfoProvider processInfoProvider;
     /* (non-Javadoc)
      * @see org.apache.cocoon.forms.validation.ValidatorBuilder#build(org.apache.cocoon.forms.formmodel.WidgetDefinition, org.w3c.dom.Element)
      */
     public WidgetValidator build(Element element, WidgetDefinition definition) throws Exception {
             Function function = JavaScriptHelper.buildFunction(element, "validate", ARG_NAMES);
 
-            return new JavaScriptValidator(this.avalonContext, function);
+            return new JavaScriptValidator(this.processInfoProvider, function);
+    }
+    public void setProcessInfoProvider( ProcessInfoProvider processInfoProvider )
+    {
+        this.processInfoProvider = processInfoProvider;
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/LengthValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/LengthValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/LengthValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/LengthValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.datatype.validationruleimpl.LengthValidationRuleBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.validation.WidgetValidator;
@@ -30,7 +29,7 @@
  */
 public class LengthValidatorBuilder 
     extends LengthValidationRuleBuilder
-    implements WidgetValidatorBuilder, ThreadSafe {
+    implements WidgetValidatorBuilder {
 
     /**
      * @see org.apache.cocoon.forms.validation.WidgetValidatorBuilder#build(org.w3c.dom.Element, org.apache.cocoon.forms.formmodel.WidgetDefinition)

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/Mod10ValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/Mod10ValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/Mod10ValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/Mod10ValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.datatype.validationruleimpl.Mod10ValidationRuleBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.validation.WidgetValidator;
@@ -30,7 +29,7 @@
  */
 public class Mod10ValidatorBuilder 
     extends Mod10ValidationRuleBuilder
-    implements WidgetValidatorBuilder, ThreadSafe {
+    implements WidgetValidatorBuilder {
 
     /**
      * @see org.apache.cocoon.forms.validation.WidgetValidatorBuilder#build(org.w3c.dom.Element, org.apache.cocoon.forms.formmodel.WidgetDefinition)

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/RangeValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/RangeValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/RangeValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/RangeValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.datatype.validationruleimpl.RangeValidationRuleBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.validation.WidgetValidator;
@@ -30,7 +29,7 @@
  */
 public class RangeValidatorBuilder 
     extends RangeValidationRuleBuilder
-    implements WidgetValidatorBuilder, ThreadSafe {
+    implements WidgetValidatorBuilder {
 
     /**
      * @see org.apache.cocoon.forms.validation.WidgetValidatorBuilder#build(org.w3c.dom.Element, org.apache.cocoon.forms.formmodel.WidgetDefinition)

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/RegExpValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/RegExpValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/RegExpValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/RegExpValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.datatype.validationruleimpl.RegExpValidationRuleBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.validation.WidgetValidator;
@@ -30,7 +29,7 @@
  */
 public class RegExpValidatorBuilder
     extends RegExpValidationRuleBuilder
-    implements WidgetValidatorBuilder, ThreadSafe {
+    implements WidgetValidatorBuilder {
 
     /**
      * @see org.apache.cocoon.forms.validation.WidgetValidatorBuilder#build(org.w3c.dom.Element, org.apache.cocoon.forms.formmodel.WidgetDefinition)

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/ValueCountValidatorBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/ValueCountValidatorBuilder.java?rev=580312&r1=580311&r2=580312&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/ValueCountValidatorBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/validation/impl/ValueCountValidatorBuilder.java Fri Sep 28 04:33:12 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.forms.validation.impl;
 
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.forms.datatype.validationruleimpl.ValueCountValidationRuleBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
 import org.apache.cocoon.forms.validation.WidgetValidator;
@@ -30,7 +29,7 @@
  */
 public class ValueCountValidatorBuilder
     extends ValueCountValidationRuleBuilder
-    implements WidgetValidatorBuilder, ThreadSafe {
+    implements WidgetValidatorBuilder {
 
     /**
      * @see org.apache.cocoon.forms.validation.WidgetValidatorBuilder#build(org.w3c.dom.Element, org.apache.cocoon.forms.formmodel.WidgetDefinition)



Mime
View raw message