I have a need to extend the
org.apache.ftpserver.config.PropertiesConfiguration class and made a
couple of minor changes to the class to make it easier to do so.
Firstly, most of the code within getConfiguration() has been moved
into a new method getPropertySubset() which returns the Properties
being searched for.
Secondly, the getConfiguration() method is now simplified by calling
getPropertySubset() before creating the new constructor.
This makes the class more extendible, because getConfiguration() can
be implemented in the sub-class in order to return the correct
instance of the Congfiguration.
I've attached a context diff from the October source release for
consideration and comment.
- Dave.
*** PropertiesConfiguration.java~ Tue Oct 25 11:32:52 2005
--- PropertiesConfiguration.java Tue Dec 20 13:35:27 2005
***************
*** 207,216 ****
return retVal;
}
! /**
! * Get sub configuration - if not found throws FtpException.
! */
! public Configuration getConfiguration(String param) throws FtpException {
Properties prop = new Properties();
Enumeration propNames = m_prop.propertyNames();
String prefix = param + '.';
--- 207,213 ----
return retVal;
}
! public Properties getPropertySubset( String param ) throws FtpException {
Properties prop = new Properties();
Enumeration propNames = m_prop.propertyNames();
String prefix = param + '.';
***************
*** 228,233 ****
--- 225,238 ----
if(prop.isEmpty()) {
throw new FtpException("Not found : " + param);
}
+ return prop;
+ }
+
+ /**
+ * Get sub configuration - if not found throws FtpException.
+ */
+ public Configuration getConfiguration(String param) throws FtpException {
+ Properties prop = getPropertySubset( param );
return new PropertiesConfiguration(prop);
}