We have a small FTP Server application which is based on old Apache FTP Server code from a couple of years ago, and therefore uses org.apache.ftpserver.config.PropertiesConfiguration, etc., for configuration.

I'm updating it to use the production version of FtpServer, mainly because I need the setPassiveExternalAddress method in org.apache.ftpserver.DataConnectionConfigurationFactory.

The first step is to rewrite the configuration part of our app using the new Spring-based system, but I know almost nothing about Spring (and about the same about FtpServer at the moment), so I'm not totally sure whether my issues relate to Spring or FtpServer. Since we don't actually use Spring for anything else, I'm trying to minimise how much Spring I introduce. My intention is to have the core 'wiring' done in XML bundled with the application, with the host-specific configuration coming from system properties. After a lot of head-scratching, I have the following code:


    XmlBeanFactory factory = new XmlBeanFactory(new UrlResource(
                                ((Application) 
Application.application()).resourceManager()
                                                
.pathURLForResourceNamed("ftpserver.xml", null, null)));
        
    PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
    poc.setIgnoreInvalidKeys(true);
    poc.setProperties((Properties)System.getProperties().clone());
    poc.postProcessBeanFactory(factory);

DefaultFtpServer server = (DefaultFtpServer) factory.getBean("myServer");


(Application is a WebObjects com.webobjects.appserver.WOApplication)
I then started with the following ftpserver.xml:


<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://mina.apache.org/ftpserver/spring/v1";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd "
        id="myServer" max-logins="7">
        <listeners>
                <nio-listener name="default" port="2222" implicit-ssl="true"
                        idle-timeout="60" local-address="1.2.3.4">
                        <data-connection idle-timeout="60">
                                <active enabled="true" local-address="1.2.3.4" 
local-port="2323"
                                        ip-check="true" />
<passive ports="123-125" address="1.2.3.4" external- address="1.2.3.4" />
                        </data-connection>
                </nio-listener>
        </listeners>
</server>


This worked fine, and I was able to determine that e.g. maxLogins had been set to the specified test value. However, I was unable to conjure the appropriate properties file entries to override maxLogins. I then had a go at rewriting the ftpserver.xml file using regular <bean> tags, and came up with the following:


<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd ">

<bean id="ftpserver-connection" class="org.apache.ftpserver.ConnectionConfigFactory">
                <property name="maxLogins" value="7"></property>
        </bean>

        <bean id="myConnectionConfig"
                factory-bean="ftpserver-connection"
                factory-method="createConnectionConfig">
        </bean>

<bean id="ftpServerFactory" class="org.apache.ftpserver.FtpServerFactory">
                <property name="connectionConfig" 
ref="myConnectionConfig"></property>
        </bean>

        <bean id="myServer" factory-bean="ftpServerFactory"
                factory-method="createServer" />

</beans>


Not quite as pretty, but it seemed to work.
I then added the following to a properties file:


ftpserver-connection.maxLogins=11


This had the desired effect - maxLogins now reported the overridden value. However, I'd have preferred something like ftpserver.connection.maxLogins. When I changed the ftpserver- connection bean id to ftpserver.connection, and the factory-bean attribute of the myConnectionConfig bean to the same, the XML part of the configuration still worked. Unfortunately, subsequently changing the property to ftpserver. connection.maxLogins had no effect -- the maxLogins property was not overridden.


My first question is whether there is actually valid set of properties file entries that would work with the first version of ftpserver.xml (the one using the http://mina.apache.org/ftpserver/spring/v1 schema)? My second question (assuming the answer to the first is 'no'), is how to reference a bean with a dot in its name from a properties file?


Thanks!
--
Roger

Reply via email to