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.
GatewayServer.GatewayServerBuilder
authToken, DEFAULT_ADDRESS, DEFAULT_CONNECT_TIMEOUT, DEFAULT_IPv6_ADDRESS, 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,
Py4JPythonClientPerThread pythonClient) |
JavaServer(java.lang.Object entryPoint,
int port,
int connectTimeout,
int readTimeout,
java.util.List<java.lang.Class<? extends Command>> customCommands,
Py4JPythonClientPerThread pythonClient,
java.lang.String authToken) |
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, defaultIPv6Address, fireConnectionError, fireConnectionStarted, fireServerError, fireServerPostShutdown, fireServerPreShutdown, fireServerStarted, fireServerStopped, getAddress, getCallbackClient, getConnectTimeout, getCustomCommands, getGateway, getListeners, getListeningPort, getPort, getPythonAddress, getPythonPort, getPythonServerEntryPoint, getReadTimeout, main, processSocket, removeListener, resetCallbackClient, run, shutdown, shutdown, start, start, startSocket, turnAllLoggingOn, turnLoggingOff, turnLoggingOn
connectionError, connectionStarted, serverError, serverPostShutdown, serverPreShutdown, serverStarted, serverStopped
public JavaServer(java.lang.Object entryPoint, int port, int connectTimeout, int readTimeout, java.util.List<java.lang.Class<? extends Command>> customCommands, Py4JPythonClientPerThread 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 Py4JPythonClientPerThread used to call Python.public JavaServer(java.lang.Object entryPoint, int port, int connectTimeout, int readTimeout, java.util.List<java.lang.Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient, java.lang.String authToken)
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 Py4JPythonClientPerThread used to call Python.authToken
- Token for authenticating with the callback server.protected Py4JServerConnection createConnection(Gateway gateway, java.net.Socket socket) throws java.io.IOException
GatewayServer
Creates a server connection from a Python call to the Java side.
createConnection
in class GatewayServer
java.io.IOException