public interface Command
This interface must be implemented by all commands.
Typically, each command will define a public constant field that contains the command name, i.e., a String that uniquely identifies the command.
The command name can be a String of any length, but it must not contain an
end of line character and it cannot be the End of Command character,
Protocol.END
.
There is a command instance per GatewayConnection
: this ensures that
each command instance is accessed by only one thread/connection at a time.
Modifier and Type | Method and Description |
---|---|
void |
execute(java.lang.String commandName,
java.io.BufferedReader reader,
java.io.BufferedWriter writer) |
java.lang.String |
getCommandName() |
void |
init(Gateway gateway,
Py4JServerConnection connection)
Called when a command instance is created and assigned to a connection.
|
void execute(java.lang.String commandName, java.io.BufferedReader reader, java.io.BufferedWriter writer) throws Py4JException, java.io.IOException
commandName
- The command name that was extracted of the command.reader
- The reader from which to read the command parts. Each command
part are expected to be on a separate line and readable
through BufferedReader.readLine()
.writer
- The writer to which the return value should be written.Py4JException
- If an error occurs while executing the command. All
exceptions except IOException caused by the reader and the
writer should be wrapper in a Py4JException
instance.java.io.IOException
- If an error occurs while using the reader or the writer.java.lang.String getCommandName()
void init(Gateway gateway, Py4JServerConnection connection)
Called when a command instance is created and assigned to a connection.
gateway
- connection
- the Py4JServerConnection
this socket is assigned to