py4j
Class GatewayConnection

java.lang.Object
  extended by 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

Field Summary
protected static List<Class<? extends py4j.commands.Command>> baseCommands
           
protected  Map<String,py4j.commands.Command> commands
           
protected  List<GatewayServerListener> listeners
           
protected  Logger logger
           
protected  BufferedReader reader
           
protected  Socket socket
           
protected  BufferedWriter writer
           
 
Constructor Summary
GatewayConnection(Gateway gateway, Socket socket)
           
GatewayConnection(Gateway gateway, Socket socket, List<Class<? extends py4j.commands.Command>> customCommands, List<GatewayServerListener> listeners)
           
 
Method Summary
protected  void fireConnectionStopped()
           
static List<Class<? extends py4j.commands.Command>> getBaseCommands()
           
 Socket getSocket()
           
protected  void initCommands(Gateway gateway, List<Class<? extends py4j.commands.Command>> commandsClazz)
           Override this method to initialize custom commands.
protected  void quietSendError(BufferedWriter writer, Throwable exception)
           
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

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
Method Detail

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