1 Reply Latest reply: Oct 26, 2009 8:35 PM by Trustin Lee RSS

Remoting 3: Builder pattern for service registration

David Lloyd Master

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.