Package py4j

Class ClientServer


  • public class ClientServer
    extends java.lang.Object

    This class creates the JavaServer and the PythonClient necessary to communicate with a Python virtual machine with the new threading model.

    • Field Detail

      • javaPort

        protected final int javaPort
      • javaAddress

        protected final java.net.InetAddress javaAddress
      • pythonPort

        protected final int pythonPort
      • pythonAddress

        protected final java.net.InetAddress pythonAddress
      • connectTimeout

        protected final int connectTimeout
      • readTimeout

        protected final int readTimeout
      • sSocketFactory

        protected final javax.net.ServerSocketFactory sSocketFactory
      • socketFactory

        protected final javax.net.SocketFactory socketFactory
      • gateway

        protected final Gateway gateway
      • autoStartJavaServer

        protected final boolean autoStartJavaServer
      • enableMemoryManagement

        protected final boolean enableMemoryManagement
      • authToken

        protected final java.lang.String authToken
      • logger

        protected final java.util.logging.Logger logger
    • Constructor Detail

      • ClientServer

        public ClientServer​(java.lang.Object entryPoint)
        Parameters:
        entryPoint -
      • ClientServer

        public ClientServer​(int javaPort,
                            java.net.InetAddress javaAddress,
                            int pythonPort,
                            java.net.InetAddress pythonAddress,
                            int connectTimeout,
                            int readTimeout,
                            javax.net.ServerSocketFactory sSocketFactory,
                            javax.net.SocketFactory socketFactory,
                            java.lang.Object entryPoint)
        Parameters:
        javaPort -
        javaAddress -
        pythonPort -
        pythonAddress -
        connectTimeout -
        readTimeout -
        sSocketFactory -
        socketFactory -
        entryPoint -
      • ClientServer

        public ClientServer​(int javaPort,
                            java.net.InetAddress javaAddress,
                            int pythonPort,
                            java.net.InetAddress pythonAddress,
                            int connectTimeout,
                            int readTimeout,
                            javax.net.ServerSocketFactory sSocketFactory,
                            javax.net.SocketFactory socketFactory,
                            java.lang.Object entryPoint,
                            boolean autoStartJavaServer,
                            boolean enableMemoryManagement)
        Parameters:
        javaPort -
        javaAddress -
        pythonPort -
        pythonAddress -
        connectTimeout -
        readTimeout -
        sSocketFactory -
        socketFactory -
        entryPoint -
        autoStartJavaServer -
        enableMemoryManagement -
    • Method Detail

      • startServer

        public void startServer()

        Starts the JavaServer on its own thread.

        Does nothing if autoStartJavaServer was set to true when constructing the instance.

      • startServer

        public void startServer​(boolean fork)

        Starts the JavaServer, which will handle requests from the Python side.

        Does nothing if autoStartJavaServer was set to true when constructing the instance.

        Parameters:
        fork - If the JavaServer is started in this thread or in its own thread.
      • shutdown

        public void shutdown()
        Shuts down the Java Server so that it stops accepting requests and it closes existing connections.
      • getPythonServerEntryPoint

        public java.lang.Object getPythonServerEntryPoint​(java.lang.Class[] interfacesToImplement)

        Gets a reference to the entry point on the Python side. This is often necessary if Java is driving the communication because Java cannot call static methods, initialize Python objects or load Python modules yet.

        Parameters:
        interfacesToImplement -
        Returns: