public class CmsShell
extends java.lang.Object
The CmsShell has direct access to all methods in the "command objects".
Currently the following classes are used as command objects:
,
CmsShellCommands
and
CmsRequestContext
.CmsObject
Only public methods in the command objects that use supported data types
as parameters can be called from the shell. Supported data types are:
String,
.CmsUUID
, boolean, int, long, double, float
If a method name is ambiguous, i.e. the method name with the same number of parameter exist in more then one of the command objects, the method is only executed on the first matching method object.
CmsShellCommands
,
CmsRequestContext
,
CmsObject
限定符和类型 | 字段和说明 |
---|---|
protected CmsObject |
m_cms
The OpenCms context object.
|
static java.lang.String |
SHELL_PARAM_ADDITIONAL_COMMANDS
Prefix for "additional" parameter.
|
static java.lang.String |
SHELL_PARAM_BASE
Prefix for "base" parameter.
|
static java.lang.String |
SHELL_PARAM_DEFAULT_WEB_APP
Prefix for "servletMapping" parameter.
|
static java.lang.String |
SHELL_PARAM_SCRIPT
Prefix for "script" parameter.
|
static java.lang.String |
SHELL_PARAM_SERVLET_MAPPING
Prefix for "servletMapping" parameter.
|
构造器和说明 |
---|
CmsShell(java.lang.String webInfPath,
java.lang.String servletMapping,
java.lang.String defaultWebAppName,
java.lang.String prompt,
I_CmsShellCommands additionalShellCommands)
Creates a new CmsShell.
|
限定符和类型 | 方法和说明 |
---|---|
void |
exit()
Exits this shell and destroys the OpenCms instance.
|
java.util.Locale |
getLocale()
Private internal helper for localization to the current user's locale
within OpenCms.
|
CmsMessages |
getMessages()
Returns the localized messages object for the current user.
|
CmsUserSettings |
getSettings()
Obtain the additional settings related to the current user.
|
protected void |
help(java.lang.String searchString)
Shows the signature of all methods containing the given search String.
|
protected CmsUserSettings |
initSettings()
Initializes the internal
CmsWorkplaceSettings that contain (amongst other
information) important information additional information about the current user
(an instance of CmsUserSettings ). |
static void |
main(java.lang.String[] args)
Main program entry point when started via the command line.
|
void |
printPrompt()
Prints the shell prompt.
|
protected void |
setEcho(boolean echo)
Sets the echo status.
|
void |
setLocale(java.util.Locale locale)
Sets the locale of the current user.
|
protected void |
setPrompt(java.lang.String prompt)
Sets the current shell prompt.
|
void |
start(java.io.FileInputStream fileInputStream)
Starts this CmsShell.
|
public static final java.lang.String SHELL_PARAM_ADDITIONAL_COMMANDS
public static final java.lang.String SHELL_PARAM_BASE
public static final java.lang.String SHELL_PARAM_DEFAULT_WEB_APP
public static final java.lang.String SHELL_PARAM_SCRIPT
public static final java.lang.String SHELL_PARAM_SERVLET_MAPPING
protected CmsObject m_cms
public CmsShell(java.lang.String webInfPath, java.lang.String servletMapping, java.lang.String defaultWebAppName, java.lang.String prompt, I_CmsShellCommands additionalShellCommands)
webInfPath
- the path to the 'WEB-INF' folder of the OpenCms installationservletMapping
- the mapping of the servlet (or null
to use the default "/opencms/*"
)defaultWebAppName
- the name of the default web application (or null
to use the default "ROOT"
)prompt
- the prompt format to setadditionalShellCommands
- optional object for additional shell commands, or nullpublic static void main(java.lang.String[] args)
args
- parameters passed to the application via the command linepublic void exit()
public java.util.Locale getLocale()
Locale
.public CmsMessages getMessages()
public CmsUserSettings getSettings()
public void printPrompt()
public void setLocale(java.util.Locale locale) throws CmsException
locale
- the locale to setCmsException
- in case the locale of the current user can not be storedpublic void start(java.io.FileInputStream fileInputStream)
fileInputStream
- a (file) input stream from which commands are readprotected void help(java.lang.String searchString)
searchString
- the String to search for in the methods, if null all methods are shownprotected CmsUserSettings initSettings()
CmsWorkplaceSettings
that contain (amongst other
information) important information additional information about the current user
(an instance of CmsUserSettings
).
This step is performed within the CmsShell
constructor directly after
switching to run-level 2 and obtaining the CmsObject
for the guest user as
well as when invoking the CmsShell command login
.
protected void setEcho(boolean echo)
echo
- the echo status to setprotected void setPrompt(java.lang.String prompt)
To set the prompt, the following variables are available:
$u
the current user name
$s
the current site root
$p
the current project name
prompt
- the prompt to set