[jboss-dev-forums] [JBoss Remoting Development] - Remoting 3: Builder pattern for service registration
david.lloyd@jboss.com
do-not-reply at jboss.com
Mon Oct 26 20:13:50 EDT 2009
I was looking at service registration and thought that it might be better/more user-friendly to switch this to use the builder pattern to construct the services.
Compare:
| final Registration handle = endpoint.serviceBuilder()
| .setRequestType(String.class).setReplyType(String.class)
| .setGroupName("main").setServiceType("simple.rot13")
| .setClientListener(new StringRot13ClientListener())
| .register();
|
with:
| final LocalServiceConfiguration<String, String> config =
| LocalServiceConfiguration.create(new StringRot13ClientListener(), String.class, String.class);
| config.setGroupName("main");
| config.setServiceType("simple.rot13");
| final Registration handle = endpoint.registerService(config);
|
In the latter case, you need to import the LocalServiceConfiguration class, and the create line is very long even if you wrap it. The builder approach just looks cleaner to me. The change is trivial to code, so I'd like to do it unless someone thinks this API is just too ugly.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262301#4262301
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4262301
More information about the jboss-dev-forums
mailing list