On 10/14/08, Sisk, Brad <[EMAIL PROTECTED]> wrote: > Can anyone recommend a simple way to force Spring to automatically call > FTPServer.start() when Spring gets an instance of it through > BeanFactory? Keep in mind, FTPServer is not registered with Spring > through the applicationContext, but rather using the <server> </server> > element configuration file.
FtpServer is certainly registered in the Spring application context, using the custom XML elements or the standard Spring elements. However, as you point out, we do not support starting FtpServer using the custom elements (and I don't think we should as I think it's a bad idea, more on that further down). However, if using the regular Spring <bean> element you could likely call start() as the init-method. I haven't tried it though. > Why is this necessary? Because of the way Spring works, and the fact > that FTPServer is a standalone Server application-not an HttpServlet. > Therefore, something has to call .start() on the Server---but you can't > just write a main() method to do it, because there is no way to command > a main() method to be executed by Spring when it is deployed to and run > on an Application server. You get to deploy an EAR file to a remote > server. From there, Spring and the remote server call all the shots. > So there has to be some configuration to tell Spring to call .start() > on the instance of FtpServer it automatically instantiates. If you know > Spring, you'll know why. The reason I think calling start from the Spring config is that you should really fit FtpServer within your runtime lifecycle. Let's say you deploy FtpServer as part of a WAR, a reasonable way would be to start it from a context listener. That way, the servlet container gets to control the lifecycle of FtpServer, that way it should work. I hoping we will have an example of this type of setup pretty soon. David said he might donate an example. If he runs out of time, I might wip something up after M4 is done. /niklas
