py4j
Class DefaultGateway

java.lang.Object
  extended by py4j.DefaultGateway
All Implemented Interfaces:
Gateway
Direct Known Subclasses:
BufferGateway, DefaultSynchronizedGateway, ExampleGateway, StackGateway

public class DefaultGateway
extends Object
implements Gateway

Provides default implementation of a JavaGateway.

This class is not thread-safe. If the GatewayServer allows multiple connections to the same gateway (acceptOnlyOne == false), the javascript engine might be invoked by multiple threads with unexpected consequences. The object and argument identifiers used by the script engine are allocated in a thread-safe manner though.

If you plan to allow concurrent connections to a gateway, use DefaultSynchronizedGateway instead.

Author:
Barthelemy Dagenais
See Also:
DefaultSynchronizedGateway

Field Summary
 
Fields inherited from interface py4j.Gateway
GATEWAY_OBJECT_ID
 
Constructor Summary
DefaultGateway()
           
 
Method Summary
protected  AtomicInteger getArgCounter()
           
protected  Bindings getBindings()
           
 List<String> getMethodNames(Object obj)
           
 String getMethodNamesAsString(Object obj)
           
protected  String getNextObjectId()
           
protected  AtomicInteger getObjCounter()
           
 Object getObject(String objectId)
           
 ReturnObject getReturnObject(Object object)
           
 ReturnObject invoke(String methodName, String targetObjectId, List<Argument> args)
           
protected  boolean isList(Object object)
           
protected  boolean isPrimitiveObject(Object object)
           
 boolean isStarted()
           
protected  String putNewObject(Object object)
           
 void setStarted(boolean isStarted)
           
 void shutdown()
           
 void startup()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGateway

public DefaultGateway()
Method Detail

getMethodNames

public List<String> getMethodNames(Object obj)
Specified by:
getMethodNames in interface Gateway

getMethodNamesAsString

public String getMethodNamesAsString(Object obj)
Specified by:
getMethodNamesAsString in interface Gateway

shutdown

public void shutdown()
Specified by:
shutdown in interface Gateway

startup

public void startup()
Specified by:
startup in interface Gateway

getObject

public Object getObject(String objectId)
Specified by:
getObject in interface Gateway

isStarted

public boolean isStarted()

setStarted

public void setStarted(boolean isStarted)

getNextObjectId

protected String getNextObjectId()

getObjCounter

protected AtomicInteger getObjCounter()

getArgCounter

protected AtomicInteger getArgCounter()

putNewObject

protected String putNewObject(Object object)

getBindings

protected Bindings getBindings()

invoke

public ReturnObject invoke(String methodName,
                           String targetObjectId,
                           List<Argument> args)
Specified by:
invoke in interface Gateway

getReturnObject

public ReturnObject getReturnObject(Object object)
Specified by:
getReturnObject in interface Gateway

isPrimitiveObject

protected boolean isPrimitiveObject(Object object)

isList

protected boolean isList(Object object)