SHL-91 SHL-80 Provide ability to disable built-in commands

This commit is contained in:
mpollack
2014-04-02 02:01:26 -04:00
parent b2a004398c
commit 6de9c8b1ae
5 changed files with 30 additions and 4 deletions

View File

@@ -86,7 +86,11 @@ public class Bootstrap {
configureApplicationContext(ctx);
//built-in commands and converters
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
scanner.scan("org.springframework.shell.commands", "org.springframework.shell.converters", "org.springframework.shell.plugin.support");
if (commandLine.getDisableInternalCommands()) {
scanner.scan("org.springframework.shell.converters", "org.springframework.shell.plugin.support");
} else {
scanner.scan("org.springframework.shell.commands", "org.springframework.shell.converters", "org.springframework.shell.plugin.support");
}
//user contributed commands
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) ctx);
reader.loadBeanDefinitions(contextPath);

View File

@@ -26,6 +26,7 @@ public class CommandLine {
private String[] args;
private int historySize;
private String[] shellCommandsToExecute;
private boolean disableInteralCommands;
/**
* Construct a new CommandLine
@@ -33,10 +34,11 @@ public class CommandLine {
* @param historySize the size of this history buffer
* @param shellCommandsToExecute semi-colon delimited list of commands for the shell to execute
*/
public CommandLine(String[] args, int historySize, String[] shellCommandsToExecute) {
public CommandLine(String[] args, int historySize, String[] shellCommandsToExecute, boolean disableInteralCommands) {
this.args = args;
this.historySize = historySize;
this.shellCommandsToExecute = shellCommandsToExecute;
this.disableInteralCommands = disableInteralCommands;
}
/**
@@ -60,5 +62,13 @@ public class CommandLine {
public String[] getShellCommandsToExecute() {
return shellCommandsToExecute;
}
/**
*
* @return the disableInteralCommands value
*/
public boolean getDisableInternalCommands() {
return disableInteralCommands;
}
}

View File

@@ -38,6 +38,7 @@ public class SimpleShellCommandLineOptions {
String[] executeThenQuit = null;
Map<String, String> extraSystemProperties = new HashMap<String, String>();
int historySize = DEFAULT_HISTORY_SIZE;
boolean disableCommands;
public static CommandLine parseCommandLine(String[] args)
throws IOException {
@@ -79,6 +80,8 @@ public class SimpleShellCommandLineOptions {
} catch (ArrayIndexOutOfBoundsException ae) {
LOGGER.warning("No value specified for --histsize option");
}
} else if (arg.equals("--disableInternalCommands")) {
options.disableCommands = true;
} else if (arg.equals("--help")) {
printUsage();
System.exit(0);
@@ -112,7 +115,7 @@ public class SimpleShellCommandLineOptions {
System.setProperty(entry.getKey(), entry.getValue());
}
return new CommandLine(args, options.historySize, options.executeThenQuit);
return new CommandLine(args, options.historySize, options.executeThenQuit, options.disableCommands);
}
private static void printUsage() {