py4j

## Class Gateway

- java.lang.Object
- - py4j.Gateway

-     public class Gateway
      extends java.lang.Object

  A Gateway manages various states: entryPoint, references to objects returned to a Python program, etc.

  This class is not intended to be directly accessed by users.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Gateway(java.lang.Object entryPoint)`
    `Gateway(java.lang.Object entryPoint, Py4JPythonClient cbClient)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closeConnection()` Called when a connection is closed.
    `java.lang.Object` | `createProxy(java.lang.ClassLoader classLoader, java.lang.Class[] interfacesToImplement, java.lang.String objectId)` Creates a proxy implementing the provided interfaces with the provided class loader.
    `protected PythonProxyHandler` | `createPythonProxyHandler(java.lang.String id)`
    `void` | `deleteObject(java.lang.String objectId)`
    `protected java.util.concurrent.atomic.AtomicInteger` | `getArgCounter()`
    `java.util.Map<java.lang.String,java.lang.Object>` | `getBindings()`
    `Py4JPythonClient` | `getCallbackClient()`
    `JVMView` | `getDefaultJVMView()`
    `java.lang.Object` | `getEntryPoint()`
    `protected java.lang.String` | `getNextObjectId()`
    `protected java.util.concurrent.atomic.AtomicInteger` | `getObjCounter()`
    `java.lang.Object` | `getObject(java.lang.String objectId)`
    `protected java.lang.Object` | `getObjectFromId(java.lang.String targetObjectId)`
    `ReflectionEngine` | `getReflectionEngine()`
    `ReturnObject` | `getReturnObject(java.lang.Object object)`
    `ReturnObject` | `invoke(java.lang.String fqn, java.util.List<java.lang.Object> args)` Invokes a constructor and returned the constructed object.
    `ReturnObject` | `invoke(java.lang.String methodName, java.lang.String targetObjectId, java.util.List<java.lang.Object> args)` Invokes a method.
    `protected boolean` | `isArray(java.lang.Object object)`
    `protected boolean` | `isDecimalObject(java.lang.Object object)`
    `protected boolean` | `isList(java.lang.Object object)`
    `protected boolean` | `isMap(java.lang.Object object)`
    `protected boolean` | `isPrimitiveObject(java.lang.Object object)`
    `protected boolean` | `isSet(java.lang.Object object)`
    `boolean` | `isStarted()`
    `java.lang.String` | `putNewObject(java.lang.Object object)` Adds a new object to the gateway bindings and return the generated ID.
    `java.lang.Object` | `putObject(java.lang.String id, java.lang.Object object)`
    `void` | `resetCallbackClient(java.net.InetAddress pythonAddress, int pythonPort)` Replace the callback client with the new one which connects to the given address and port.
    `void` | `setStarted(boolean isStarted)`
    `void` | `shutdown()` Releases all objects that were referenced by this Gateway and shuts down the CallbackClient.
    `void` | `shutdown(boolean shutdownCallbackClient)` Releases all objects that were referenced by this Gateway and optionally shut down the callback client.
    `void` | `startup()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Gateway

          public Gateway(java.lang.Object entryPoint)

    - #### Gateway

          public Gateway(java.lang.Object entryPoint,
                         Py4JPythonClient cbClient)

  - ### Method Detail

    - #### resetCallbackClient

          public void resetCallbackClient(java.net.InetAddress pythonAddress,
                                          int pythonPort)

      Replace the callback client with the new one which connects to the given address and port. This method is useful if for some reason your CallbackServer changes its address or you come to know of the address after Gateway has already instantiated.

      This method is not thread-safe! Make sure that only one thread calls this method.

      Parameters:
        `pythonAddress` - The address used by a PythonProxyHandler to connect to a Python gateway.
        `pythonPort` - The port used by a PythonProxyHandler to connect to a Python gateway. Essentially the port used for Python callbacks.

    - #### closeConnection

          public void closeConnection()

      Called when a connection is closed.

    - #### deleteObject

          public void deleteObject(java.lang.String objectId)

    - #### getArgCounter

          protected java.util.concurrent.atomic.AtomicInteger getArgCounter()

    - #### getBindings

          public java.util.Map<java.lang.String,java.lang.Object> getBindings()

      Returns:
        The bindings of the Gateway. Should never be called by other classes except subclasses and testing classes.

    - #### getCallbackClient

          public Py4JPythonClient getCallbackClient()

    - #### getDefaultJVMView

          public JVMView getDefaultJVMView()

    - #### getEntryPoint

          public java.lang.Object getEntryPoint()

    - #### getNextObjectId

          protected java.lang.String getNextObjectId()

    - #### getObjCounter

          protected java.util.concurrent.atomic.AtomicInteger getObjCounter()

    - #### getObject

          public java.lang.Object getObject(java.lang.String objectId)

      Parameters:
        `objectId` -
      Returns:
        The object associated with the id or null if the object id is unknown.

    - #### getObjectFromId

          protected java.lang.Object getObjectFromId(java.lang.String targetObjectId)

    - #### getReflectionEngine

          public ReflectionEngine getReflectionEngine()

    - #### getReturnObject

          public ReturnObject getReturnObject(java.lang.Object object)

    - #### invoke

          public ReturnObject invoke(java.lang.String fqn,
                                     java.util.List<java.lang.Object> args)

      Invokes a constructor and returned the constructed object.

      Parameters:
        `fqn` - The fully qualified name of the class.
        `args` -
      Returns:

    - #### invoke

          public ReturnObject invoke(java.lang.String methodName,
                                     java.lang.String targetObjectId,
                                     java.util.List<java.lang.Object> args)

      Invokes a method.

      Parameters:
        `methodName` -
        `targetObjectId` -
        `args` -
      Returns:

    - #### isArray

          protected boolean isArray(java.lang.Object object)

    - #### isDecimalObject

          protected boolean isDecimalObject(java.lang.Object object)

    - #### isList

          protected boolean isList(java.lang.Object object)

    - #### isMap

          protected boolean isMap(java.lang.Object object)

    - #### isPrimitiveObject

          protected boolean isPrimitiveObject(java.lang.Object object)

    - #### isSet

          protected boolean isSet(java.lang.Object object)

    - #### isStarted

          public boolean isStarted()

    - #### putNewObject

          public java.lang.String putNewObject(java.lang.Object object)

      Adds a new object to the gateway bindings and return the generated ID. Should NEVER be called by other classes except subclasses and testing classes.

      Parameters:
        `object` -
      Returns:

    - #### putObject

          public java.lang.Object putObject(java.lang.String id,
                                            java.lang.Object object)

    - #### setStarted

          public void setStarted(boolean isStarted)

    - #### createProxy

          public java.lang.Object createProxy(java.lang.ClassLoader classLoader,
                                              java.lang.Class[] interfacesToImplement,
                                              java.lang.String objectId)

      Creates a proxy implementing the provided interfaces with the provided class loader.

      This method is part of the Gateway instance to allow overriding or customizing per Gateway instance.

      Parameters:
        `classLoader` -
        `interfacesToImplement` -
        `objectId` -
      Returns:

    - #### createPythonProxyHandler

          protected PythonProxyHandler createPythonProxyHandler(java.lang.String id)

    - #### shutdown

          public void shutdown()

      Releases all objects that were referenced by this Gateway and shuts down the CallbackClient.

    - #### shutdown

          public void shutdown(boolean shutdownCallbackClient)

      Releases all objects that were referenced by this Gateway and optionally shut down the callback client.

      Parameters:
        `shutdownCallbackClient` - Shuts down the CallbackClient instance if true.

    - #### startup

          public void startup()