[ 
https://issues.apache.org/jira/browse/FTPSERVER-271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12669717#action_12669717
 ] 

Niklas Gustavsson commented on FTPSERVER-271:
---------------------------------------------

While I agree that the API now requires additional steps, calling the nearly 
impossible might be stretching it a bit to far. Here's a comparison between how 
to set the port:
// old API
FtpServer server = new FtpServer();
server.getListener("default").setPort(2221);
server.start();

// new API
FtpServerFactory serverFactory = new FtpServerFactory();        
ListenerFactory factory = new ListenerFactory();
factory.setPort(2221);
serverFactory.addListener("default", factory.createListener());
FtpServer server = serverFactory.createServer();        
server.start();

There is clearly more code in the second example, however, I find it more 
truthful in what it actually provides. For example, in the old API; you could 
set the port after starting the server (and thus the listener), but it would 
not change anything.

There was three main reason the API was changed:
* Make the implementation as close to immutable as possible. This is a huge 
advantage since it allows more efficient implementations and removed lots of 
concurrency issues we had before
* Removed the need for initialization of various implementation classes. We did 
a lot of weird lazy inits of stuff before, now we do not have to, again making 
the code more efficient and safe
* Now works much better with OSGi as our implementations are never exposed in 
the public API

I'm very grateful for discovering the embedding documentation which was out of 
date. I've now replaced it with the new page that was already existing.

> Embedding FtpServer in RC2 nearly impossible
> --------------------------------------------
>
>                 Key: FTPSERVER-271
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-271
>             Project: FtpServer
>          Issue Type: Bug
>    Affects Versions: 1.0.0-RC2
>            Reporter: Claus Ibsen
>            Priority: Critical
>
> Hi
> I might be a bit dissapointed now that when the upgrade from M3 to RC3 with 
> an embedded FtpServer is very complicated as you have changed the API too 
> much.
> Its hard to set the FTP port number that is a very reasonable configuration 
> to do.
> This was baiscally how you could do it in M3 but now you have to fight with a 
> NioListener and no way a public setPort method exsists.
> http://mina.apache.org/ftpserver/embedding-ftpserver.html
> Could you please reconsider the RC2 to ease the embedding of FtpServer. Its 
> very cool for unit testing other frameworks.
> Claus Ibsen, a committer on the Apache Camel project
> http://davsclaus.blogspot.com/

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to