Knopflerfish OSGi 5.2.0

org.osgi.service.command
Interface CommandSession


public interface CommandSession

A Command Session holds the executable state of a script engine as well as the keyboard and console streams. A Command Session is not thread safe and should not be used from different threads at the same time. TODO The javadoc in this class need a good scrub before release.

Version:
$Revision: 5654 $
NotThreadSafe

Method Summary
 void close()
          Close this command session.
 java.lang.Object convert(java.lang.Class type, java.lang.Object instance)
          Convert an object to another type.
 java.lang.Object execute(java.lang.CharSequence commandline)
          Execute a program in this session.
 java.lang.Object execute(java.lang.CharSequence commandline, java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err)
          Execute a program in this session but override the different streams for this call only.
 java.lang.CharSequence format(java.lang.Object target, int level)
          Convert an object to string form (CharSequence).
 java.lang.Object get(java.lang.String name)
          Get the value of a variable.
 java.io.PrintStream getConsole()
          Return the PrintStream for the console.
 java.io.InputStream getKeyboard()
          Return the input stream that is the first of the pipeline.
 void put(java.lang.String name, java.lang.Object value)
          Set the value of a variable.
 

Method Detail

execute

java.lang.Object execute(java.lang.CharSequence commandline)
                         throws java.lang.Exception
Execute a program in this session.

Parameters:
commandline - ###
Returns:
the result of the execution
Throws:
java.lang.Exception - ###

execute

java.lang.Object execute(java.lang.CharSequence commandline,
                         java.io.InputStream in,
                         java.io.PrintStream out,
                         java.io.PrintStream err)
                         throws java.lang.Exception
Execute a program in this session but override the different streams for this call only.

Parameters:
commandline -
in - ###
out - ###
err - ###
Returns:
the result of the execution
Throws:
java.lang.Exception - ###

close

void close()
Close this command session. After the session is closed, it will throw IllegalStateException when it is used.


getKeyboard

java.io.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

java.io.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:
###

get

java.lang.Object get(java.lang.String name)
Get the value of a variable.

Parameters:
name - ###
Returns:
###

put

void put(java.lang.String name,
         java.lang.Object value)
Set the value of a variable.

Parameters:
name - Name of the variable.
value - Value of the variable

format

java.lang.CharSequence format(java.lang.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:
###

convert

java.lang.Object convert(java.lang.Class type,
                         java.lang.Object instance)
Convert an object to another type.

Parameters:
type - ###
instance - ###
Returns:
###

Knopflerfish OSGi 5.2.0