1 package org.apidesign.aserverinfo.builder;
3 import org.apidesign.aserverinfo.spi.NameProvider;
4 import org.apidesign.aserverinfo.spi.ResetHandler;
5 import org.apidesign.aserverinfo.spi.ShutdownHandler;
6 import org.apidesign.aserverinfo.spi.URLProvider;
10 * @author Jaroslav Tulach <jtulach@netbeans.org>
12 public class ServerInfo {
15 // cumulative factory methods for the builder pattern
18 // BEGIN: aserverinfo.builder.factory
19 public static ServerInfo empty() {
20 return new ServerInfo(null, null, null, null);
23 public final ServerInfo nameProvider(NameProvider np) {
24 return new ServerInfo(np, this.url, this.reset, this.shutdown);
27 public final ServerInfo urlProvider(URLProvider up) {
28 return new ServerInfo(this.name, up, this.reset, this.shutdown);
30 public final ServerInfo reset(ResetHandler h) {
31 return new ServerInfo(this.name, this.url, h, this.shutdown);
33 /** All one needs to do when there is a need to add new
34 * style of creation is to add new method for a builder.
39 public final ServerInfo shutdown(ShutdownHandler handler) {
40 return new ServerInfo(this.name, this.url, this.reset, handler);
43 /** Creates the server connector based on current values in the
44 * info. Builder factory method.
45 * @return server connector
47 public final ServerConnector connect() {
48 return new ServerConnector(name, url, reset, shutdown);
50 // END: aserverinfo.builder.factory
52 private final NameProvider name;
53 private final URLProvider url;
54 private final ResetHandler reset;
55 private final ShutdownHandler shutdown;
58 NameProvider name, URLProvider url,
59 ResetHandler reset, ShutdownHandler shutdown
64 this.shutdown = shutdown;