public class ShellAgent extends Agent
Modifier and Type | Class and Description |
---|---|
protected class |
ShellAgent.InitScript |
protected class |
ShellAgent.InputStreamCacheEntry |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ABORT |
protected java.lang.Thread |
consoleThread |
protected boolean |
enabled |
protected ScriptEngine |
engine |
protected boolean |
ephemeral |
protected java.util.concurrent.Callable<java.lang.Void> |
exec |
protected CyclicBehavior |
executor |
protected java.util.List<ShellAgent.InitScript> |
initScripts |
protected java.util.Map<java.lang.String,ShellAgent.InputStreamCacheEntry> |
isCache |
protected java.util.List<MessageListener> |
listeners |
protected boolean |
quit |
protected Shell |
shell |
Constructor and Description |
---|
ShellAgent(ScriptEngine engine)
Create a shell agent without a user console.
|
ShellAgent(ScriptEngine engine,
boolean ephemeral)
Create a transient shell agent without a user console.
|
ShellAgent(Shell shell,
ScriptEngine engine)
Create a shell for user interaction.
|
Modifier and Type | Method and Description |
---|---|
void |
addInitrc(java.io.File script)
Adds a initialization script file to setup the console environment.
|
void |
addInitrc(java.lang.String script)
Adds a name of the initialization script to setup the console environment.
|
void |
addInitrc(java.lang.String name,
java.io.Reader reader)
Adds a initialization script from a reader to setup the console environment.
|
void |
addMessageListener(MessageListener ml)
Adds a message listener for incoming notifications.
|
void |
clearMessageListeners()
Removes all message listeners.
|
void |
enable(boolean b)
Enable/disable user interaction in shell.
|
java.lang.String |
getDescription()
Get description of the shell agent.
|
java.lang.String |
getLanguage()
Get supported script language.
|
java.lang.String |
getTitle()
Get title of the shell agent.
|
void |
init()
Called by the container when the agent is started.
|
boolean |
isEnabled()
Checks if user interaction in shell is enabled.
|
void |
removeMessageListener(MessageListener ml)
Removes a message listener.
|
void |
setInitrc(java.io.File script)
Sets the initialization script file to setup the console environment.
|
void |
setInitrc(java.lang.String script)
Sets the name of the initialization script to setup the console environment.
|
void |
setInitrc(java.lang.String name,
java.io.Reader reader)
Sets the initialization script from a reader to setup the console environment.
|
void |
shutdown()
Called by the container when the agent is terminated.
|
java.lang.String |
toString()
Gets a string representation of the agent.
|
add, agent, agentForService, agentForService, agentsForService, agentsForService, block, block, clone, currentTimeMillis, delay, deregister, deregister, die, getAgentID, getContainer, getName, getPlatform, getState, getStore, getType, getYieldDuringReceive, nanoTime, platformSend, prepareRequest, println, receive, receive, receive, receive, receive, receive, receive, receive, register, register, request, request, run, send, setLogLevel, setQueueSize, setYieldDuringReceive, stop, subscribe, topic, topic, topic, topic, topic, topic, unsubscribe, wake
public static final java.lang.String ABORT
protected Shell shell
protected java.lang.Thread consoleThread
protected ScriptEngine engine
protected java.util.concurrent.Callable<java.lang.Void> exec
protected CyclicBehavior executor
protected java.util.List<MessageListener> listeners
protected java.util.List<ShellAgent.InitScript> initScripts
protected java.util.Map<java.lang.String,ShellAgent.InputStreamCacheEntry> isCache
protected boolean quit
protected boolean ephemeral
protected boolean enabled
public ShellAgent(ScriptEngine engine)
engine
- script engine to usepublic ShellAgent(ScriptEngine engine, boolean ephemeral)
engine
- script engine to useephemeral
- true for transient shell, false for long-lived shellpublic ShellAgent(Shell shell, ScriptEngine engine)
shell
- user consoleengine
- script engine to usepublic void init()
Agent
public void shutdown()
Agent
public void setInitrc(java.lang.String script)
script
- script name.public void setInitrc(java.io.File script)
script
- script file.public void setInitrc(java.lang.String name, java.io.Reader reader)
name
- name of the reader.reader
- script reader.public void addInitrc(java.lang.String script)
script
- script name.public void addInitrc(java.io.File script)
script
- script file.public void addInitrc(java.lang.String name, java.io.Reader reader)
name
- name of the reader.reader
- script reader.public void addMessageListener(MessageListener ml)
ml
- message listener.public void removeMessageListener(MessageListener ml)
ml
- message listener.public void clearMessageListeners()
public void enable(boolean b)
b
- true to enable, false to disable.public boolean isEnabled()
public java.lang.String getLanguage()
public java.lang.String getTitle()
public java.lang.String getDescription()