Package py4j
Class JavaServer
java.lang.Object
py4j.DefaultGatewayServerListener
py4j.GatewayServer
py4j.JavaServer
- All Implemented Interfaces:
Runnable
,GatewayServerListener
,Py4JJavaServer
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class py4j.GatewayServer
GatewayServer.GatewayServerBuilder
-
Field Summary
Fields inherited from class py4j.GatewayServer
authToken, DEFAULT_ADDRESS, DEFAULT_CONNECT_TIMEOUT, DEFAULT_IPv6_ADDRESS, DEFAULT_PORT, DEFAULT_PYTHON_PORT, DEFAULT_READ_TIMEOUT, GATEWAY_SERVER_ID, PY4J_LOGGER
-
Constructor Summary
ConstructorsConstructorDescriptionJavaServer
(Object entryPoint, int port, int connectTimeout, int readTimeout, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient) JavaServer
(Object entryPoint, int port, int connectTimeout, int readTimeout, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient, String authToken) -
Method Summary
Modifier and TypeMethodDescriptionprotected Py4JServerConnection
createConnection
(Gateway gateway, Socket socket) Creates a server connection from a Python call to the Java side.Methods inherited from class py4j.GatewayServer
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
Methods inherited from class py4j.DefaultGatewayServerListener
connectionError, connectionStarted, serverError, serverPostShutdown, serverPreShutdown, serverStarted, serverStopped
-
Constructor Details
-
JavaServer
public JavaServer(Object entryPoint, int port, int connectTimeout, int readTimeout, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient) - Parameters:
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.
-
JavaServer
public JavaServer(Object entryPoint, int port, int connectTimeout, int readTimeout, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient, String authToken) - Parameters:
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.
-
-
Method Details
-
createConnection
Description copied from class:GatewayServer
Creates a server connection from a Python call to the Java side.
- Overrides:
createConnection
in classGatewayServer
- Returns:
- Throws:
IOException
-