py4j
Class GatewayConnection
java.lang.Object
py4j.GatewayConnection
- All Implemented Interfaces:
- Runnable
public class GatewayConnection
- extends Object
- implements Runnable
Manage the connection between a Python program and a Gateway. A
GatewayConnection lives in its own thread and is created on demand (e.g., one
per concurrent thread).
The request to connect to the JVM goes through the GatewayServer
first and is then passed to a GatewayConnection.
This class is not intended to be directly accessed by users.
- Author:
- Barthelemy Dagenais
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
baseCommands
protected static final List<Class<? extends py4j.commands.Command>> baseCommands
socket
protected final Socket socket
writer
protected final BufferedWriter writer
reader
protected final BufferedReader reader
commands
protected final Map<String,py4j.commands.Command> commands
logger
protected final Logger logger
listeners
protected final List<GatewayServerListener> listeners
GatewayConnection
public GatewayConnection(Gateway gateway,
Socket socket)
throws IOException
- Throws:
IOException
GatewayConnection
public GatewayConnection(Gateway gateway,
Socket socket,
List<Class<? extends py4j.commands.Command>> customCommands,
List<GatewayServerListener> listeners)
throws IOException
- Throws:
IOException
getBaseCommands
public static List<Class<? extends py4j.commands.Command>> getBaseCommands()
- Returns:
- The list of base commands that are provided by default. Can be
hidden by custom commands with the same command id by passing a
list of custom commands to the
GatewayServer
.
fireConnectionStopped
protected void fireConnectionStopped()
getSocket
public Socket getSocket()
- Returns:
- The socket used by this gateway connection.
initCommands
protected void initCommands(Gateway gateway,
List<Class<? extends py4j.commands.Command>> commandsClazz)
Override this method to initialize custom commands.
- Parameters:
gateway
-
quietSendError
protected void quietSendError(BufferedWriter writer,
Throwable exception)
run
public void run()
- Specified by:
run
in interface Runnable