Class Gateway
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.
- Author:
- Barthelemy Dagenais
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called when a connection is closed.createProxy
(ClassLoader classLoader, Class[] interfacesToImplement, String objectId) Creates a proxy implementing the provided interfaces with the provided class loader.protected PythonProxyHandler
void
deleteObject
(String objectId) protected AtomicInteger
protected String
protected AtomicInteger
protected Object
getObjectFromId
(String targetObjectId) getReturnObject
(Object object) Invokes a method.Invokes a constructor and returned the constructed object.protected boolean
protected boolean
isDecimalObject
(Object object) protected boolean
protected boolean
protected boolean
isPrimitiveObject
(Object object) protected boolean
boolean
putNewObject
(Object object) Adds a new object to the gateway bindings and return the generated ID.void
resetCallbackClient
(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()
-
Constructor Details
-
Gateway
-
Gateway
-
-
Method Details
-
resetCallbackClient
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
-
getArgCounter
-
getBindings
- Returns:
- The bindings of the Gateway. Should never be called by other classes except subclasses and testing classes.
-
getCallbackClient
-
getDefaultJVMView
-
getEntryPoint
-
getNextObjectId
-
getObjCounter
-
getObject
- Parameters:
objectId
-- Returns:
- The object associated with the id or null if the object id is unknown.
-
getObjectFromId
-
getReflectionEngine
-
getReturnObject
-
invoke
Invokes a constructor and returned the constructed object.
- Parameters:
fqn
- The fully qualified name of the class.args
-- Returns:
-
invoke
Invokes a method.
- Parameters:
methodName
-targetObjectId
-args
-- Returns:
-
isArray
-
isDecimalObject
-
isList
-
isMap
-
isPrimitiveObject
-
isSet
-
isStarted
public boolean isStarted() -
putNewObject
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
-
setStarted
public void setStarted(boolean isStarted) -
createProxy
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
-
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()
-