Hi,

I would be very pleased to have some feedback on the above proposed
modifications, espacially with the exceptions problem.

I asume that if nobody has given an opinion on this, they should agree
with modifications so you will find enclosed my first proposed
modification : Adding parameters support to ContentInterceptors to allow
them to be plugged smothly and cleanly.

This patch affects org/apache/slide/common/NamespaceConfig.java and
org/apache/slide/content/ContentInterceptor.java and add parameters
support through Domain.xml file in this way :

<content-interceptor class="[contentInterceptorClass]">
     <parameter name="[paramName]">[paramValue]</parameter>
</content-interceptor>

ContentInterceptors parameters are stored into a new ContentInteceptor's
property (Hashtable parameters) accessible via method getParameters().

As Remy has suggested it some time ago, I've made ContentInterceptor
class abstract.

Regards

JP

ps : this patch is for banch SLIDE_1_0. I will port it (and the
      following) to HEAD branch as soon as it will be approved.

Jean-Philippe Courson wrote:
> Hi,
> 
> Some time ago, I sent some patches that make slide support users quota, 
> a feature requested by a lot of users.
> 
> These patches have never been commited to the cvs tree.
> I asume it's because they were not considered clean enougth and/or too
> big by commiters so, wishing to see them integrated into SLIDE_1_0,
> I will take some time to make them cleaner and smaller.
> 
> To reach this purpose,
> 1) I would be pleased if some people who deeply know slide's internals
>    could answer some questions.
> 2) Rather than sending in one time a lot of big patches, I will send
>    several little patches that will be easier for commiters to manage.
> 
> 
> 1) Some questions :
> 
> - What to do with exceptions ?
> 
> Firstly, ContentInterceptors's preStoreContent method is called before
> the content to be stored so if there is a problem with the node (node
> doesn't exist, access to it is denied,...), exceptions may be thrown.
> 
> Secondly, ContentInterceptors may have to access stores (for retreiving
> or updating data) to complete their processing and once again,
> exceptions may be thrown.
> 
> So what ContentInterceptors could do else than throwing again these
> exceptions ?
> 
> - ContentInterceptors parameters :
> 
> Would not it be great (and clean) to be able to give ContentInterceptors
> parameters in the following way ?
> <content-interceptor class="[contentInterceptorClass]">
>   <parameter name="[paramName]">[paramValue]</parameter>
> </content-interceptor>
> 
> - ContentInterceptors's methods new arguments :
> 
> As I just said above, ContentInterceptors may have to access stores or
> namespace configuration to complete their processing, so would not it be
> usefull to add a Namespace object to their methods arguments ?
> 
> 
> 2) "Patches planning"
> 
> As soon as I will have some feedback with the above questions, I will
> propose a "patches planning" to make commiters work easier as possible.
> I am planning to firstly send generic ContentInterceptors changes (one
> by one) and secondly send changes to support users quotas.
> 
> Any feedback will be welcome
> 
> Thanks in advance for your help
> 
> JP
--- slide/src/share/org/apache/slide/common/NamespaceConfig.java        Fri Mar 29 
11:53:13 2002
+++ 
+slide_1_0_Quota_1_parameters/src/share/org/apache/slide/common/NamespaceConfig.java 
+Mon Apr  8 09:40:03 2002
@@ -820,12 +820,26 @@
                 Configuration contentInterceptorDef =
                     (Configuration) contentInteceptorsDef.nextElement();
                 String classname = contentInterceptorDef.getAttribute("class");
+
+                // Load contentInterceptor parameters
+                Enumeration contentInterceptorParametersDef =
+                    contentInterceptorDef.getConfigurations("parameter");
+                Hashtable contentInterceptorParameters = new Hashtable();
+                while (contentInterceptorParametersDef.hasMoreElements()) {
+                    Configuration parameterDefinition = (Configuration)
+                        contentInterceptorParametersDef.nextElement();
+                    String parameterName = parameterDefinition.getAttribute("name");
+                    String parameterValue = parameterDefinition.getValue();
+                    contentInterceptorParameters.put(parameterName, parameterValue);
+                }
+
                 try {
                     Class contentInterceptorClass =
                         Class.forName(classname);
                     ContentInterceptor contentInterceptor = 
                         (ContentInterceptor) 
                         contentInterceptorClass.newInstance();
+                    contentInterceptor.setParameters(contentInterceptorParameters);
                     ContentInterceptor[] tempArray = 
                         new ContentInterceptor[contentInterceptors.length + 1];
                     for (int i = 0; i < contentInterceptors.length; i++) {
--- slide/src/share/org/apache/slide/content/ContentInterceptor.java    Fri Mar 29 
11:53:13 2002
+++ 
+slide_1_0_Quota_1_parameters/src/share/org/apache/slide/content/ContentInterceptor.java
+     Mon Apr  8 09:40:03 2002
@@ -71,9 +71,42 @@
  * 
  * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
  */
-public class ContentInterceptor {
+public abstract class ContentInterceptor {
     
     
+    // ----------------------------------------------------- Instance Variables
+
+
+    /**
+     * ContentInterceptor's parameters.
+     */
+    private Hashtable parameters;
+
+
+    // ------------------------------------------------------------- Properties
+
+
+    /**
+     * Parameters accessor.
+     *
+     * @return Hashtable Parameters
+     */
+    public Hashtable getParameters() {
+        return parameters;
+    }
+
+
+    /**
+     * Parameters modifier.
+     *
+     * @param parameters Hashtable containing the parameters' name
+     * and associated value
+     */
+    public void setParameters(Hashtable parameters) {
+        this.parameters = parameters;
+    }
+
+
     // ---------------------------------------------------------------- Methods
     
     

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to