public abstract class AbstractShell extends AbstractShellStatusPublisher implements Shell
Shell implementation.| Modifier and Type | Field and Description |
|---|---|
static String |
completionKeys |
protected ExitShellRequest |
exitShellRequest |
protected boolean |
inBlockComment |
protected Logger |
logger |
protected static String |
ROO_PROMPT |
static String |
shellPrompt |
shellStatus, shellStatusListenersWINDOW_TITLE_SLOT| Constructor and Description |
|---|
AbstractShell() |
| Modifier and Type | Method and Description |
|---|---|
void |
addListerner(CommandListener listener)
To add new CommandListener on Shell object, use addListener method.
|
void |
blockCommentBegin() |
void |
blockCommentFinish() |
static String |
buildInfo() |
String |
date() |
boolean |
executeCommand(String line)
Runs the specified command.
|
protected boolean |
executeScriptLine(String line)
Execute the single line from a script.
|
protected abstract Collection<URL> |
findResources(String path)
Returns any classpath resources with the given path
|
void |
flash(Level level,
String message,
String slot)
Simple implementation of
flash(Level, String, String) that
simply displays the message via the logger. |
protected abstract ExecutionStrategy |
getExecutionStrategy() |
ExitShellRequest |
getExitShellRequest() |
File |
getHome()
Obtains the home directory for the current shell instance.
|
protected abstract String |
getHomeAsString() |
protected abstract Parser |
getParser() |
String |
getShellPrompt() |
void |
inlineComment() |
protected void |
logCommandIfRequired(String line,
boolean successful)
Allows a subclass to log the execution of a well-formed command.
|
protected void |
logCommandToOutput(String processedLine)
Allows a subclass to actually write the resulting logged command to some
form of output.
|
String |
props() |
void |
removeListener(CommandListener listener)
To remove CommandListener on Shell object, use removeListener method
|
void |
script(File script,
boolean lineNumbers,
String ignoreLines) |
void |
setPromptPath(String path)
Base implementation of the
Shell.setPromptPath(String) method,
designed for simple shell implementations. |
void |
setPromptPath(String path,
boolean overrideStyle)
Default implementation of
Shell#setPromptPath(String, boolean))
method to satisfy STS compatibility. |
void |
setRooPrompt(String prompt)
This method changes setPromptPath with a new one
|
void |
setTailor(Tailor tailor)
To support API compatibility with STS shell, tailor implementation should
be injected explicitly when activated.
|
String |
version(String extra) |
static String |
versionInfo() |
static String |
versionInfoWithoutGit() |
addShellStatusListener, getShellStatus, removeShellStatusListener, setShellStatus, setShellStatusclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisDevelopmentMode, promptLoop, setDevelopmentModeaddShellStatusListener, getShellStatus, removeShellStatusListenerprotected static final String ROO_PROMPT
public static String completionKeys
public static String shellPrompt
protected final Logger logger
protected boolean inBlockComment
protected ExitShellRequest exitShellRequest
public static String versionInfo()
public static String buildInfo()
public static String versionInfoWithoutGit()
public void blockCommentBegin()
public void blockCommentFinish()
public String date()
public boolean executeCommand(String line)
ShellexecuteCommand in interface Shellline - to execute (required)protected boolean executeScriptLine(String line)
This method can be overridden by sub-classes to pre-process script lines.
protected abstract Collection<URL> findResources(String path)
path - the path for which to search (never null)null if the search can't be performedpublic void flash(Level level, String message, String slot)
flash(Level, String, String) that
simply displays the message via the logger. It is strongly recommended
shell implementations override this method with a more effective
approach.protected abstract ExecutionStrategy getExecutionStrategy()
public ExitShellRequest getExitShellRequest()
getExitShellRequest in interface Shellpublic File getHome()
Note: calls the getHomeAsString() method to allow subclasses to
provide the home directory location as string using different
environment-specific strategies.
If the path indicated by getHomeAsString() exists and refers to
a directory, that directory is returned.
If the path indicated by getHomeAsString() exists and refers to
a file, an exception is thrown.
If the path indicated by getHomeAsString() does not exist, it
will be created as a directory. If this fails, an exception will be
thrown.
protected abstract String getHomeAsString()
protected abstract Parser getParser()
public String getShellPrompt()
getShellPrompt in interface ShellPromptAccessorpublic void inlineComment()
protected void logCommandIfRequired(String line, boolean successful)
Implementations should consider specially handling the "script" commands,
and also indicating whether a command was successful or not.
Implementations that wish to behave consistently with other
AbstractShell subclasses are encouraged to simply override
logCommandToOutput(String) instead, and only override this
method if you actually need to fine-tune the output logic.
line - the parsed line (any comments have been removed; never null)successful - if the command was successful or notprotected void logCommandToOutput(String processedLine)
logCommandIfRequired(String, boolean).
Implementations should invoke getExitShellRequest() to monitor
any attempts to exit the shell and release resources such as output log
files.
processedLine - the line that should be appended to some type of
output (excluding the \n character)public String props()
public void setPromptPath(String path)
Shell.setPromptPath(String) method,
designed for simple shell implementations. Advanced implementations (eg
those that support ANSI codes etc) will likely want to override this
method and set the shellPrompt variable directly.setPromptPath in interface Shellpath - to set (can be null or empty; must NOT be formatted in any
special way eg ANSI codes)public void setRooPrompt(String prompt)
path - public void setPromptPath(String path, boolean overrideStyle)
Shell#setPromptPath(String, boolean))
method to satisfy STS compatibility.setPromptPath in interface Shellpath - to set (can be null or empty)overrideStyle - public void setTailor(Tailor tailor)
Shellpublic void addListerner(CommandListener listener)
ShelladdListerner in interface Shellpublic void removeListener(CommandListener listener)
ShellremoveListener in interface ShellCopyright © 2009–2017 Pivotal Software, Inc.. All rights reserved.