public class JavaServer extends GatewayServer
This class extends GatewayServer by implementing a new threading model: a thread always use the same connection to the other side so callbacks are executed in the calling thread.
For example, if Java thread 1 calls Python, and Python calls Java, the callback (from Python to Java) will be executed in Java thread 1.
DEFAULT_ADDRESS, DEFAULT_CONNECT_TIMEOUT, DEFAULT_PORT, DEFAULT_PYTHON_PORT, DEFAULT_READ_TIMEOUT, GATEWAY_SERVER_ID, PY4J_LOGGER| Constructor and Description |
|---|
JavaServer(java.lang.Object entryPoint,
int port,
int connectTimeout,
int readTimeout,
java.util.List<java.lang.Class<? extends Command>> customCommands,
Py4JPythonClient pythonClient) |
| Modifier and Type | Method and Description |
|---|---|
protected Py4JServerConnection |
createConnection(Gateway gateway,
java.net.Socket socket)
Creates a server connection from a Python call to the Java side.
|
addListener, connectionStopped, defaultAddress, fireConnectionError, fireConnectionStarted, fireServerError, fireServerPostShutdown, fireServerPreShutdown, fireServerStarted, fireServerStopped, getAddress, getCallbackClient, getConnectTimeout, getCustomCommands, getGateway, getListeners, getListeningPort, getPort, getPythonAddress, getPythonPort, getReadTimeout, main, processSocket, removeListener, resetCallbackClient, run, shutdown, shutdown, start, start, startSocket, turnAllLoggingOn, turnLoggingOff, turnLoggingOnconnectionError, connectionStarted, serverError, serverPostShutdown, serverPreShutdown, serverStarted, serverStoppedpublic JavaServer(java.lang.Object entryPoint,
int port,
int connectTimeout,
int readTimeout,
java.util.List<java.lang.Class<? extends Command>> customCommands,
Py4JPythonClient pythonClient)
entryPoint - The entry point of this Gateway. Can be null.port - The port the GatewayServer is listening to.connectTimeout - Time in milliseconds (0 = infinite). If a GatewayServer does
not receive a connection request after this time, it closes
the server socket and no other connection is accepted.readTimeout - Time in milliseconds (0 = infinite). Once a Python program is
connected, if a GatewayServer does not receive a request
(e.g., a method call) after this time, the connection with the
Python program is closed.customCommands - A list of custom Command classes to augment the Server
features. These commands will be accessible from Python
programs. Can be null.pythonClient - The Py4JPythonClient used to call Python.protected Py4JServerConnection createConnection(Gateway gateway, java.net.Socket socket) throws java.io.IOException
GatewayServerCreates a server connection from a Python call to the Java side.
createConnection in class GatewayServerjava.io.IOException