Trustin Lee wrote:
Hi community,
I've just checked in very important changes in MINA core API. To feel
what
has changed, please take a look into this diff:
http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/reverser/Main.java?r1=448088&r2=465510
Basically, I changed all IoService implementations to work with only one
service. That is, one IoAcceptor can bind to only one port. Because
IoAcceptor works with only one service at a time, I moved all
parameters in
bind() method to properties with getters and setters. Some setters will
throw IllegalStateException when the handler is already bound and the
settings cannot be changed.
IoConnector works a little bit differently; I moved the parameters in
call()
to properties with getters and setters, but there's no big change
essentially. You can set remoteAddress again and call connect() to
connect
to a different host.
I also removed IoAcceptorBeanFactory in integration-spring package
because
our IoAcceptors are already spring-friendly. All you have to do is to
set
init-method and destroy-method attributes in your <bean/> tag. Binding
class has been removed together.
The next step is to split IoService, IoAcceptor, IoConnector into two
categories; one is read-only, and the other is configurable (e.g.
ConfigurableIoConnector) like spring framework did.
I like this change a lot because (as you've already metioned) it
simplifies configuration a lot, especially when using Spring. My only
concern is that it won't be as straight forward to setup connectors
using Spring. I guess one approach would be to have a factory for each
type of IoConnector. E.g.:
public class SocketConnectorFactory implements IoConnectorFactory {
SocketConnector createConnector(SocketAddress addr);
void setFilters(...);
void setConnectTimeout(...);
... other relevant properties
}
WDYT?
--
Niklas Therning
www.spamdrain.net