/** Connect to {@code host}:{@code port}. */ public OptionalOnlineOptions hostAndPort(String host, int port) { if (data.host != null) { throw new IllegalStateException("Host and port were already set"); } if (host == null || host.isEmpty()) { throw new IllegalArgumentException("Host must be set"); } if (port <= 0) { throw new IllegalArgumentException("Port must be set"); } data.host = host; data.port = port; return new OptionalOnlineOptions(data); }
/** * <p>Connect to {@code localhost} and use the default management port of the application server. * This is {@code 9999} by default (JBoss AS 7), and if the system property {@code creaper.wildfly} is defined, * it changes to 9990 or (if {@link OptionalOnlineOptions#ssl(SslOptions) ssl} is used) to 9993 (WildFly). * This makes it easy to run the same code against both AS7 and WildFly only by defining a single system * property.</p> * * <p>Alternatively, the {@link OptionalOnlineOptions#protocol(ManagementProtocol) protocol()} method * can be used, which takes precedence over the methods described above. When it is called, the default port * depends on chosen {@link ManagementProtocol}.</p> */ public OptionalOnlineOptions localDefault() { data.localDefault = true; return new OptionalOnlineOptions(data); }