Package org.apache.felix.gogo.runtime
Class CommandSessionImpl
java.lang.Object
org.apache.felix.gogo.runtime.CommandSessionImpl
- All Implemented Interfaces:
AutoCloseable
,CommandSession
,Converter
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.felix.service.command.CommandSession
CommandSession.Utils
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Channel[]
static final String
static final String
protected OutputStream
protected InputStream
protected OutputStream
protected PrintStream
protected PrintStream
static final String
protected final ConcurrentMap
<String, Object> static final String
Fields inherited from interface org.apache.felix.service.command.CommandSession
OPTION_NO_GLOB
Fields inherited from interface org.apache.felix.service.command.Converter
CONVERTER_CLASSES, INSPECT, LINE, PART
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CommandSessionImpl
(CommandProcessorImpl shell, InputStream in, OutputStream out, OutputStream err) protected
CommandSessionImpl
(CommandProcessorImpl shell, CommandSessionImpl parent) -
Method Summary
Modifier and TypeMethodDescriptionvoid
classLoader
(ClassLoader classLoader) void
close()
Close this command session.Convert an object to another type.org.apache.felix.gogo.runtime.CommandSessionImpl.JobImpl
createJob
(CharSequence command) void
currentDir
(Path path) static org.apache.felix.gogo.runtime.CommandSessionImpl.JobImpl
execute
(CharSequence commandline) Execute a program in this session.expr
(CharSequence expr) org.apache.felix.gogo.runtime.CommandSessionImpl.JobImpl
Get the current foreground job or null.Convert an object to string form (CharSequence).Convert an objet to a CharSequence object in the requested format.Get the value of a variable.Return the PrintStream for the console.Return the input stream that is the first of the pipeline.jobs()
List jobs.Set the value of a variable.void
setJobListener
(JobListener listener) Set the job listener for this session.
-
Field Details
-
SESSION_CLOSED
- See Also:
-
VARIABLES
- See Also:
-
COMMANDS
- See Also:
-
CONSTANTS
- See Also:
-
in
-
out
-
pout
-
err
-
perr
-
channels
-
variables
-
-
Constructor Details
-
CommandSessionImpl
-
CommandSessionImpl
protected CommandSessionImpl(CommandProcessorImpl shell, InputStream in, OutputStream out, OutputStream err)
-
-
Method Details
-
processor
-
getVariables
-
currentDir
- Specified by:
currentDir
in interfaceCommandSession
-
currentDir
- Specified by:
currentDir
in interfaceCommandSession
-
classLoader
- Specified by:
classLoader
in interfaceCommandSession
-
classLoader
- Specified by:
classLoader
in interfaceCommandSession
-
close
public void close()Description copied from interface:CommandSession
Close this command session. After the session is closed, it will throw IllegalStateException when it is used.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCommandSession
-
execute
Description copied from interface:CommandSession
Execute a program in this session.- Specified by:
execute
in interfaceCommandSession
- Parameters:
commandline
- the commandline- Returns:
- the result of the execution
- Throws:
Exception
- on exception
-
getKeyboard
Description copied from interface:CommandSession
Return the input stream that is the first of the pipeline. This stream is sometimes necessary to communicate directly to the end user. For example, a "less" or "more" command needs direct input from the keyboard to control the paging.- Specified by:
getKeyboard
in interfaceCommandSession
- Returns:
- InpuStream used closest to the user or null if input is from a file.
-
get
Description copied from interface:CommandSession
Get the value of a variable.- Specified by:
get
in interfaceCommandSession
- Parameters:
name
- the name- Returns:
- Object
-
put
Description copied from interface:CommandSession
Set the value of a variable.- Specified by:
put
in interfaceCommandSession
- Parameters:
name
- Name of the variable.value
- Value of the variable- Returns:
- Object
-
getConsole
Description copied from interface:CommandSession
Return the PrintStream for the console. This must always be the stream "closest" to the user. This stream can be used to post messages that bypass the piping. If the output is piped to a file, then the object returned must be null.- Specified by:
getConsole
in interfaceCommandSession
- Returns:
- PrintStream the console print stream
-
format
Description copied from interface:Converter
Convert an objet to a CharSequence object in the requested format. The format can be INSPECT, LINE, or PART. Other values must throw IllegalArgumentException. -
convert
Description copied from interface:CommandSession
Convert an object to another type.- Specified by:
convert
in interfaceCommandSession
- Specified by:
convert
in interfaceConverter
- Parameters:
desiredType
- the typein
- the instance- Returns:
- Object
-
doConvert
-
format
Description copied from interface:CommandSession
Convert an object to string form (CharSequence). The level is defined in the Converter interface, it can be one of INSPECT, LINE, PART. This function always returns a non null value. As a last resort, toString is called on the Object.- Specified by:
format
in interfaceCommandSession
- Parameters:
result
- the targetinspect
- the level- Returns:
- CharSequence
-
expr
-
invoke
- Throws:
Exception
-
redirect
-
jobs
Description copied from interface:CommandSession
List jobs. Always return a non-null list.- Specified by:
jobs
in interfaceCommandSession
- Returns:
- List<Job>
-
currentJob
public static org.apache.felix.gogo.runtime.CommandSessionImpl.JobImpl currentJob() -
foregroundJob
public org.apache.felix.gogo.runtime.CommandSessionImpl.JobImpl foregroundJob()Description copied from interface:CommandSession
Get the current foreground job or null.- Specified by:
foregroundJob
in interfaceCommandSession
- Returns:
- Job
-
setJobListener
Description copied from interface:CommandSession
Set the job listener for this session.- Specified by:
setJobListener
in interfaceCommandSession
- Parameters:
listener
- the listener
-
createJob
-