Back in January, there was a change to the class
org.apache.ftpserver.config.PropertiesConfiguration, to make it
easier for extending.  A couple of changes since then have moved
things on.

Here's the goal: to be able to extend PropertiesConfiguration such
that an application can use it's own Configuration class which has
something extra, but retains the basic functionality of the
PropertiesConfiguration class.

The current problem is that the subset() method creates and returns
a copy of PropertiesConfiguration, and therefore any extra
functionality in the sub-class is lost.

One proposal I have is attached in the patch: add protected methods
for getting and setting both the properties and the prefix.  That
way, any subclass can implement the subset() method itself.

An alternative would be to change subset() such that rather than
creating an instance of PropertiesConfiguration, it calls a
protected method called getInstanceOfClass() or something, which
instantiates the right class which subset can then make use of. It
didn't seem the right way to me.

Of course, neither option precludes any other ideas.

- Dave.
Index: src/java/org/apache/ftpserver/config/PropertiesConfiguration.java
===================================================================
--- src/java/org/apache/ftpserver/config/PropertiesConfiguration.java   
(revision 470756)
+++ src/java/org/apache/ftpserver/config/PropertiesConfiguration.java   
(working copy)
@@ -43,7 +43,7 @@
     /**
      * Private constructor - used internally to get configuration subset.
      */
-    private PropertiesConfiguration() {
+    protected PropertiesConfiguration() {
     }
     
     /**
@@ -223,6 +223,34 @@
     }
     
     /**
+     * Get the properties
+     */
+    protected Properties getProperties() {
+       return prop;
+    }
+    
+    /**
+     * Set a new bunch of properties
+     */
+    protected void setProperties( Properties p ) {
+       prop = p;
+    }
+    
+    /**
+     * Obtain the prefix currently in use
+     */
+    protected String getPrefix() {
+       return prefix;
+    }
+    
+    /**
+     * Set a new prefix
+     */
+    protected void setPrefix( String p ) {
+       prefix = p;
+    }
+    
+    /**
      * Get configuration keys.
      */
     public Iterator getKeys() {

Reply via email to