Skip to content

Commit

Permalink
[WFLY-2517] Restoration of removed methods, restoration is to bring A…
Browse files Browse the repository at this point in the history
…PI in line with JBoss AS 7.2.0.Final - restored methods subsequently deprecated with references to new alternatives.
  • Loading branch information
darranl committed Nov 15, 2013
1 parent 34ec842 commit f08d12f
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 1 deletion.
22 changes: 21 additions & 1 deletion cli/src/main/java/org/jboss/as/cli/CliConfig.java
Expand Up @@ -29,6 +29,26 @@
*/
public interface CliConfig {

/**
* The default server controller host to connect to.
*
* @deprecated Use {@link CliConfig#getDefaultControllerAddress()} instead.
*
* @return default server controller host to connect to
*/
@Deprecated
String getDefaultControllerHost();

/**
* The default server controller port to connect to.
*
* @deprecated Use {@link CliConfig#getDefaultControllerAddress()} instead.
*
* @return default server controller port to connect to
*/
@Deprecated
int getDefaultControllerPort();

/**
* The default server controller protocol for addresses where no protocol is specified.
*
Expand All @@ -47,7 +67,7 @@ public interface CliConfig {
/**
* The default address of the controller from the configuration.
*
* @return The defailt address.
* @return The default address.
*/
ControllerAddress getDefaultControllerAddress();

Expand Down
43 changes: 43 additions & 0 deletions cli/src/main/java/org/jboss/as/cli/CommandContext.java
Expand Up @@ -140,6 +140,22 @@ public interface CommandContext {
*/
void connectController(String controller) throws CommandLineException;

/**
* Connects the controller client using the host and the port.
* If the host is null, the default controller host will be used,
* which is localhost.
* If the port is less than zero, the default controller port will be used,
* which is 9999.
*
* @deprecated Use {@link #connectController(String)} instead.
*
* @param host the host to connect with
* @param port the port to connect on
* @throws CommandLineException in case the attempt to connect failed
*/
@Deprecated
void connectController(String host, int port) throws CommandLineException;

/**
* Bind the controller to an existing, connected client.
*/
Expand All @@ -151,6 +167,33 @@ public interface CommandContext {
*/
void disconnectController();

/**
* Returns the default host the controller client will be connected to.
*
* @deprecated Use {@link CommandContext#getDefaultControllerAddress()} instead.
*
* @return the default host the controller client will be connected to.
*/
@Deprecated
String getDefaultControllerHost();

/**
* Returns the default port the controller client will be connected to.
*
* @deprecated Use {@link CommandContext#getDefaultControllerAddress()} instead.
*
* @return the default port the controller client will be connected to.
*/
@Deprecated
int getDefaultControllerPort();

/**
* The default address of the default controller to connect to.
*
* @return The default address.
*/
ControllerAddress getDefaultControllerAddress();

/**
* Returns the host the controller client is connected to or
* null if the connection hasn't been established yet.
Expand Down
22 changes: 22 additions & 0 deletions cli/src/main/java/org/jboss/as/cli/CommandContextFactory.java
Expand Up @@ -65,4 +65,26 @@ public abstract CommandContext newCommandContext(String controller, String usern
public abstract CommandContext newCommandContext(String controller, String username, char[] password, InputStream consoleInput,
OutputStream consoleOutput) throws CliInitializationException;

/**
* @deprecated Use {@link #newCommandContext(String, String, char[])} instead.
*/
@Deprecated
public abstract CommandContext newCommandContext(String controllerHost, int controllerPort,
String username, char[] password) throws CliInitializationException;

/**
* @deprecated Use {@link #newCommandContext(String, int, String, char[], boolean, int)} instead.
*/
@Deprecated
public abstract CommandContext newCommandContext(String controllerHost, int controllerPort,
String username, char[] password, boolean initConsole, final int connectionTimeout) throws CliInitializationException;

/**
* @deprecated Use {@link #newCommandContext(String, int, String, char[], InputStream, OutputStream)} instead.
*/
@Deprecated
public abstract CommandContext newCommandContext(String controllerHost, int controllerPort,
String username, char[] password,
InputStream consoleInput, OutputStream consoleOutput) throws CliInitializationException;

}
12 changes: 12 additions & 0 deletions cli/src/main/java/org/jboss/as/cli/impl/CliConfigImpl.java
Expand Up @@ -223,6 +223,18 @@ public boolean isUseLegacyOverride() {
return useLegacyOverride;
}

@Override
@Deprecated
public String getDefaultControllerHost() {
return getDefaultControllerAddress().getHost();
}

@Override
@Deprecated
public int getDefaultControllerPort() {
return getDefaultControllerAddress().getPort();
}

@Override
public ControllerAddress getDefaultControllerAddress() {
return defaultController;
Expand Down
Expand Up @@ -23,6 +23,8 @@

import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;

import org.jboss.as.cli.CliInitializationException;
import org.jboss.as.cli.CommandContext;
Expand Down Expand Up @@ -84,6 +86,42 @@ public CommandContext newCommandContext(String controller,
return ctx;
}

@Override
@Deprecated
public CommandContext newCommandContext(String controllerHost, int controllerPort, String username, char[] password)
throws CliInitializationException {
try {
return newCommandContext(new URI(null, null, controllerHost, controllerPort, null, null, null).toString().substring(2),
username, password);
} catch (URISyntaxException e) {
throw new CliInitializationException("Unable to construct URI for connection.", e);
}
}

@Override
@Deprecated
public CommandContext newCommandContext(String controllerHost, int controllerPort, String username, char[] password,
boolean initConsole, int connectionTimeout) throws CliInitializationException {
try {
return newCommandContext(new URI(null, null, controllerHost, controllerPort, null, null, null).toString().substring(2),
username, password, initConsole, connectionTimeout);
} catch (URISyntaxException e) {
throw new CliInitializationException("Unable to construct URI for connection.", e);
}
}

@Override
@Deprecated
public CommandContext newCommandContext(String controllerHost, int controllerPort, String username, char[] password,
InputStream consoleInput, OutputStream consoleOutput) throws CliInitializationException {
try {
return newCommandContext(new URI(null, null, controllerHost, controllerPort, null, null, null).toString().substring(2),
username, password, consoleInput, consoleOutput);
} catch (URISyntaxException e) {
throw new CliInitializationException("Unable to construct URI for connection.", e);
}
}

protected void addShutdownHook(final CommandContext cmdCtx) {
CliShutdownHook.add(new CliShutdownHook.Handler(){
@Override
Expand Down
29 changes: 29 additions & 0 deletions cli/src/main/java/org/jboss/as/cli/impl/CommandContextImpl.java
Expand Up @@ -29,6 +29,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.MessageDigest;
Expand Down Expand Up @@ -794,6 +796,16 @@ public void connectController(String controller) throws CommandLineException {
} while (retry);
}

@Override
@Deprecated
public void connectController(String host, int port) throws CommandLineException {
try {
connectController(new URI(null, null, host, port, null, null, null).toString().substring(2));
} catch (URISyntaxException e) {
throw new CommandLineException("Unable to construct URI for connection.", e);
}
}

@Override
public void bindClient(ModelControllerClient newClient) {
initNewClient(newClient, null);
Expand Down Expand Up @@ -966,6 +978,23 @@ public void disconnectController() {
promptConnectPart = null;
}

@Override
@Deprecated
public String getDefaultControllerHost() {
return config.getDefaultControllerHost();
}

@Override
@Deprecated
public int getDefaultControllerPort() {
return config.getDefaultControllerPort();
}

@Override
public ControllerAddress getDefaultControllerAddress() {
return config.getDefaultControllerAddress();
}

@Override
public String getControllerHost() {
return currentAddress != null ? currentAddress.getHost() : null;
Expand Down
Expand Up @@ -42,6 +42,18 @@ public String getDefaultControllerProtocol() {
return "http-remoting";
}

@Override
@Deprecated
public String getDefaultControllerHost() {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
public int getDefaultControllerPort() {
throw new UnsupportedOperationException();
}

@Override
public boolean isUseLegacyOverride() {
return true;
Expand Down
Expand Up @@ -31,6 +31,7 @@
import org.jboss.as.cli.CommandHistory;
import org.jboss.as.cli.CommandLineCompleter;
import org.jboss.as.cli.CommandLineException;
import org.jboss.as.cli.ControllerAddress;
import org.jboss.as.cli.batch.BatchManager;
import org.jboss.as.cli.batch.BatchedCommand;
import org.jboss.as.cli.operation.OperationCandidatesProvider;
Expand Down Expand Up @@ -187,6 +188,12 @@ public void connectController(String controller) {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
public void connectController(String host, int port) throws CommandLineException {
throw new UnsupportedOperationException();
}

@Override
public void bindClient(ModelControllerClient newClient) {
throw new UnsupportedOperationException();
Expand All @@ -198,6 +205,24 @@ public void disconnectController() {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
public String getDefaultControllerHost() {
throw new UnsupportedOperationException();
}

@Override
@Deprecated
public int getDefaultControllerPort() {
throw new UnsupportedOperationException();
}

@Override
public ControllerAddress getDefaultControllerAddress() {
// TODO Auto-generated method stub
return null;
}

@Override
public String getControllerHost() {
return null;
Expand Down

0 comments on commit f08d12f

Please sign in to comment.