Package org.apache.felix.service.command
Interface CommandSession
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
CommandSessionImpl
public interface CommandSession extends AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
CommandSession.Utils
Return the current session.
-
Field Summary
Fields Modifier and Type Field Description static String
OPTION_NO_GLOB
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ClassLoader
classLoader()
void
classLoader(ClassLoader classLoader)
void
close()
Close this command session.Object
convert(Class<?> type, Object instance)
Convert an object to another type.Path
currentDir()
void
currentDir(Path path)
Object
execute(CharSequence commandline)
Execute a program in this session.Job
foregroundJob()
Get the current foreground job or null.CharSequence
format(Object target, int level)
Convert an object to string form (CharSequence).Object
get(String name)
Get the value of a variable.PrintStream
getConsole()
Return the PrintStream for the console.InputStream
getKeyboard()
Return the input stream that is the first of the pipeline.List<Job>
jobs()
List jobs.Object
put(String name, Object value)
Set the value of a variable.void
setJobListener(JobListener listener)
Set the job listener for this session.
-
-
-
Field Detail
-
OPTION_NO_GLOB
static final String OPTION_NO_GLOB
- See Also:
- Constant Field Values
-
-
Method Detail
-
currentDir
Path currentDir()
-
currentDir
void currentDir(Path path)
-
classLoader
ClassLoader classLoader()
-
classLoader
void classLoader(ClassLoader classLoader)
-
execute
Object execute(CharSequence commandline) throws Exception
Execute a program in this session.- Parameters:
commandline
-- Returns:
- the result of the execution
- Throws:
Exception
-
close
void close()
Close this command session. After the session is closed, it will throw IllegalStateException when it is used.- Specified by:
close
in interfaceAutoCloseable
-
getKeyboard
InputStream getKeyboard()
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.- Returns:
- InpuStream used closest to the user or null if input is from a file.
-
getConsole
PrintStream getConsole()
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.- Returns:
-
put
Object put(String name, Object value)
Set the value of a variable.- Parameters:
name
- Name of the variable.value
- Value of the variable
-
format
CharSequence format(Object target, int level)
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.- Parameters:
target
-level
-- Returns:
-
foregroundJob
Job foregroundJob()
Get the current foreground job or null.
-
setJobListener
void setJobListener(JobListener listener)
Set the job listener for this session.
-
-