cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/datatype DefaultDatatypeManager.java
Date Thu, 15 Apr 2004 18:09:04 GMT
bruno       2004/04/15 11:09:03

  Modified:    src/blocks/forms/java/org/apache/cocoon/forms/util
                        SimpleServiceSelector.java
               src/blocks/forms/java/org/apache/cocoon/forms/datatype/typeimpl
                        AbstractDatatypeBuilder.java
               src/blocks/forms/java/org/apache/cocoon/forms/datatype
                        DefaultDatatypeManager.java
  Log:
  make sure all datatype- and convertorbuilders are both serviceable and
  contextualizable
  
  Revision  Changes    Path
  1.2       +11 -3     cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/util/SimpleServiceSelector.java
  
  Index: SimpleServiceSelector.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/util/SimpleServiceSelector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleServiceSelector.java	9 Mar 2004 10:34:09 -0000	1.1
  +++ SimpleServiceSelector.java	15 Apr 2004 18:09:03 -0000	1.2
  @@ -29,6 +29,9 @@
   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.context.Contextualizable;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
   import org.apache.cocoon.components.LifecycleHelper;
   
   /**
  @@ -37,11 +40,12 @@
    * @version $Id$
    */
   public class SimpleServiceSelector extends AbstractLogEnabled implements ServiceSelector,
Configurable, LogEnabled,
  -        Serviceable, Disposable {
  +        Serviceable, Disposable, Contextualizable {
       private final String hintShortHand;
       private final Class componentClass;
       private Map components = new HashMap();
       private ServiceManager serviceManager;
  +    private Context context;
   
       public SimpleServiceSelector(String hintShortHand, Class componentClass) {
           this.hintShortHand = hintShortHand;
  @@ -52,6 +56,10 @@
           this.serviceManager = serviceManager;
       }
   
  +    public void contextualize(Context context) throws ContextException {
  +        this.context = context;
  +    }
  +
       public void configure(Configuration configuration) throws ConfigurationException {
           Configuration[] componentConfs = configuration.getChildren(hintShortHand);
           for (int i = 0; i < componentConfs.length; i++) {
  @@ -71,7 +79,7 @@
               Object component = null;
               try {
                   component = clazz.newInstance();
  -                LifecycleHelper lifecycleHelper = new LifecycleHelper(getLogger(), null,
serviceManager, null, componentConfs[i]);
  +                LifecycleHelper lifecycleHelper = new LifecycleHelper(getLogger(), context,
serviceManager, null, componentConfs[i]);
                   lifecycleHelper.setupComponent(component);
               } catch (Exception e) {
                   throw new ConfigurationException("Error creating " + hintShortHand + "
declared at " + componentConfs[i].getLocation(), e);
  
  
  
  1.3       +16 -2     cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/datatype/typeimpl/AbstractDatatypeBuilder.java
  
  Index: AbstractDatatypeBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/datatype/typeimpl/AbstractDatatypeBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractDatatypeBuilder.java	9 Mar 2004 13:08:46 -0000	1.2
  +++ AbstractDatatypeBuilder.java	15 Apr 2004 18:09:03 -0000	1.3
  @@ -21,6 +21,9 @@
   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.context.Contextualizable;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
   import org.apache.cocoon.forms.Constants;
   import org.apache.cocoon.forms.datatype.DatatypeBuilder;
   import org.apache.cocoon.forms.datatype.DatatypeManager;
  @@ -36,18 +39,29 @@
    * will derive from this class.
    * @version $Id$
    */
  -public abstract class AbstractDatatypeBuilder implements DatatypeBuilder, Serviceable,
Configurable {
  +public abstract class AbstractDatatypeBuilder implements DatatypeBuilder, Serviceable,
Configurable, Contextualizable {
       protected ServiceManager serviceManager;
       private SimpleServiceSelector convertorBuilders;
       private String defaultConvertorHint;
       private Convertor plainConvertor;
  +    private Context context;
   
       public void service(ServiceManager serviceManager) throws ServiceException {
           this.serviceManager = serviceManager;
       }
   
  +    public void contextualize(Context context) throws ContextException {
  +        this.context = context;
  +    }
  +
       public void configure(Configuration configuration) throws ConfigurationException {
           convertorBuilders = new SimpleServiceSelector("convertor", ConvertorBuilder.class);
  +        try {
  +            convertorBuilders.contextualize(context);
  +            convertorBuilders.service(serviceManager);
  +        } catch (Exception e) {
  +            throw new ConfigurationException("Error setting up convertor builder selector.",
e);
  +        }
           Configuration convertorsConf = configuration.getChild("convertors");
           convertorBuilders.configure(convertorsConf);
           defaultConvertorHint = convertorsConf.getAttribute("default");
  
  
  
  1.2       +12 -2     cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/datatype/DefaultDatatypeManager.java
  
  Index: DefaultDatatypeManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/datatype/DefaultDatatypeManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultDatatypeManager.java	9 Mar 2004 10:34:00 -0000	1.1
  +++ DefaultDatatypeManager.java	15 Apr 2004 18:09:03 -0000	1.2
  @@ -26,6 +26,9 @@
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.CascadingException;
  +import org.apache.avalon.framework.context.Contextualizable;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
   import org.apache.cocoon.forms.datatype.convertor.Convertor;
   import org.apache.cocoon.forms.util.DomHelper;
   import org.apache.cocoon.forms.util.SimpleServiceSelector;
  @@ -43,11 +46,16 @@
    *
    */
   public class DefaultDatatypeManager extends AbstractLogEnabled implements DatatypeManager,
ThreadSafe, Serviceable,
  -        Configurable, Initializable, Disposable {
  +        Configurable, Initializable, Disposable, Contextualizable {
       private SimpleServiceSelector typeBuilderSelector;
       private SimpleServiceSelector validationRuleBuilderSelector;
       private ServiceManager serviceManager;
       private Configuration configuration;
  +    private Context context;
  +
  +    public void contextualize(Context context) throws ContextException {
  +        this.context = context;
  +    }
   
       public void configure(Configuration configuration) throws ConfigurationException {
           this.configuration = configuration;
  @@ -59,10 +67,12 @@
   
       public void initialize() throws Exception {
           typeBuilderSelector = new SimpleServiceSelector("datatype", DatatypeBuilder.class);
  +        typeBuilderSelector.contextualize(context);
           typeBuilderSelector.service(serviceManager);
           typeBuilderSelector.configure(configuration.getChild("datatypes"));
   
           validationRuleBuilderSelector = new SimpleServiceSelector("validation-rule", ValidationRuleBuilder.class);
  +        validationRuleBuilderSelector.contextualize(context);
           validationRuleBuilderSelector.service(serviceManager);
           validationRuleBuilderSelector.configure(configuration.getChild("validation-rules"));
   
  
  
  

Mime
View raw message