|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.shell.event.AbstractShellStatusPublisher
org.springframework.shell.core.AbstractShell
public abstract class AbstractShell
Provides a base Shell
implementation.
Field Summary | |
---|---|
static String |
completionKeys
|
protected ExitShellRequest |
exitShellRequest
|
protected boolean |
inBlockComment
|
protected Logger |
logger
|
protected static String |
ROO_PROMPT
|
static String |
shellPrompt
|
Fields inherited from class org.springframework.shell.event.AbstractShellStatusPublisher |
---|
shellStatus, shellStatusListeners |
Fields inherited from interface org.springframework.shell.core.Shell |
---|
WINDOW_TITLE_SLOT |
Constructor Summary | |
---|---|
AbstractShell()
|
Method Summary | |
---|---|
void |
blockCommentBegin()
|
void |
blockCommentFinish()
|
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. |
void |
flashCustom()
|
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()
|
protected void |
handleExecutionResult(Object result)
Handles the result of execution of a command. |
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 |
script(File script,
boolean lineNumbers)
|
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. |
String |
version(String extra)
|
String |
versionInfo()
|
Methods inherited from class org.springframework.shell.event.AbstractShellStatusPublisher |
---|
addShellStatusListener, getShellStatus, removeShellStatusListener, setShellStatus, setShellStatus |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.shell.core.Shell |
---|
isDevelopmentMode, promptLoop, setDevelopmentMode |
Methods inherited from interface org.springframework.shell.event.ShellStatusProvider |
---|
addShellStatusListener, getShellStatus, removeShellStatusListener |
Field Detail |
---|
protected static final String ROO_PROMPT
public static String completionKeys
public static String shellPrompt
protected final Logger logger
protected boolean inBlockComment
protected ExitShellRequest exitShellRequest
Constructor Detail |
---|
public AbstractShell()
Method Detail |
---|
protected abstract Collection<URL> findResources(String path)
path
- the path for which to search (never null)
null
if the search can't be performedprotected abstract String getHomeAsString()
protected abstract ExecutionStrategy getExecutionStrategy()
protected abstract Parser getParser()
public void script(File script, boolean lineNumbers)
protected boolean executeScriptLine(String line)
This method can be overridden by sub-classes to pre-process script lines.
public boolean executeCommand(String line)
Shell
executeCommand
in interface Shell
line
- to execute (required)
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 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 Shell
path
- to set (can be null or empty; must NOT be formatted in any special way eg ANSI codes)public void setPromptPath(String path, boolean overrideStyle)
Shell#setPromptPath(String, boolean))
method to satisfy STS compatibility.
setPromptPath
in interface Shell
path
- to set (can be null or empty)overrideStyle
- public ExitShellRequest getExitShellRequest()
getExitShellRequest
in interface Shell
public void inlineComment()
public void blockCommentBegin()
public void blockCommentFinish()
public String props()
public String date()
public void flashCustom() throws Exception
Exception
public String version(String extra)
public String versionInfo()
public String getShellPrompt()
getShellPrompt
in interface ShellPromptAccessor
public 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.
getHome
in interface Shell
public 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.
flash
in interface Shell
level
- the importance of the message (cannot be null)message
- to display (cannot be null, but may be empty)slot
- the identification slot for the message (cannot be null or empty)protected void handleExecutionResult(Object result)
null
. If result is a
Iterable
object, it will be iterated through to print
the output of toString. For other type of objects, simply output
of toString is shown. Subclasses can alter this implementation
to handle the result differently.
result
- not null
result of execution of a command.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |