public class Protocol
extends java.lang.Object
This class defines the protocol used to communicate between two virtual machines (e.g., Python and Java).
Currently, the protocol requires type information (e.g., is this string an integer, an object reference or a boolean?) to be embedded with each command part. The rational is that the source virtual machine is usually better at determining the type of objects it sends.
An input command is usually composed of:
The various parts of a command are separated by \n characters. These characters are automatically escaped and unescaped in Strings on both sides (Java and Python).
An output command is usually composed of:
This class should be used only if the user creates new commands.
Modifier and Type | Field and Description |
---|---|
static char |
ARRAY_TYPE |
static java.lang.String |
AUTH_COMMAND_NAME |
static char |
BOOLEAN_TYPE |
static char |
BYTES_TYPE |
static char |
CLASS_TYPE |
static char |
DECIMAL_TYPE |
static java.lang.String |
DEFAULT_JVM_OBJECT_ID |
static char |
DOUBLE_TYPE |
static char |
END |
static char |
END_OUTPUT |
static java.lang.String |
ENTRY_POINT_OBJECT_ID |
static char |
ERROR |
static java.lang.String |
ERROR_COMMAND |
static char |
FATAL_ERROR |
static java.lang.String |
GATEWAY_SERVER_ID |
static char |
INTEGER_TYPE |
static char |
ITERATOR_TYPE |
static char |
LIST_TYPE |
static char |
LONG_TYPE |
static char |
MAP_TYPE |
static char |
METHOD_TYPE |
static char |
NO_MEMBER |
static java.lang.String |
NO_SUCH_FIELD |
static char |
NULL_TYPE |
static char |
PACKAGE_TYPE |
static java.lang.String |
PYTHON_INFINITY |
static java.lang.String |
PYTHON_NAN |
static java.lang.String |
PYTHON_NEGATIVE_INFINITY |
static char |
PYTHON_PROXY_TYPE |
static char |
REFERENCE_TYPE |
static char |
RETURN_MESSAGE |
static char |
SET_TYPE |
static java.lang.String |
STATIC_PREFIX |
static char |
STRING_TYPE |
static char |
SUCCESS |
static char |
VOID |
static java.lang.String |
VOID_COMMAND |
Constructor and Description |
---|
Protocol() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
encodeBytes(byte[] bytes)
Transform the byte array into Base64 characters.
|
static java.lang.String |
getAuthCommand(java.lang.String authToken) |
static boolean |
getBoolean(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static byte[] |
getBytes(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static java.math.BigDecimal |
getDecimal(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static double |
getDouble(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static int |
getInteger(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static long |
getLong(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static java.lang.String |
getMemberOutputCommand(char memberType) |
static java.lang.String |
getMemberOutputCommand(char memberType,
java.lang.String fqn) |
static java.lang.String |
getNoSuchFieldOutputCommand() |
static java.lang.Object |
getNull(java.lang.String commandPart)
Method provided for consistency.
|
static java.lang.Object |
getObject(java.lang.String commandPart,
Gateway gateway) |
static java.lang.String |
getOutputCommand(ReturnObject rObject) |
static java.lang.String |
getOutputErrorCommand() |
static java.lang.String |
getOutputErrorCommand(java.lang.String errorMessage) |
static java.lang.String |
getOutputErrorCommand(java.lang.Throwable throwable) |
static java.lang.String |
getOutputFatalErrorCommand(java.lang.Throwable throwable) |
static java.lang.String |
getOutputVoidCommand() |
static char |
getPrimitiveType(java.lang.Object primitiveObject) |
static java.lang.Object |
getPythonProxy(java.lang.String commandPart,
Gateway gateway)
Assumes that commandPart is not empty.
|
static java.lang.Object |
getPythonProxyHandler(java.lang.ClassLoader classLoader,
java.lang.Class[] interfacesToImplement,
java.lang.String objectId,
Gateway gateway)
Deprecated.
|
static java.lang.Object |
getReference(java.lang.String commandPart,
Gateway gateway)
Assumes that commandPart is not empty.
|
static java.lang.Object |
getReturnValue(java.lang.String returnMessage,
Gateway gateway) |
static java.lang.Throwable |
getRootThrowable(java.lang.Throwable throwable,
boolean skipInvocation) |
static java.lang.String |
getString(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static java.lang.String |
getThrowableAsString(java.lang.Throwable throwable) |
static boolean |
isBoolean(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isBytes(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isDecimal(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isDouble(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isEmpty(java.lang.String commandPart) |
static boolean |
isEnd(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isError(java.lang.String returnMessage)
Assumes that commandPart is not null.
|
static boolean |
isInteger(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isLong(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isNull(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isPythonProxy(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isReference(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
static boolean |
isReturnMessage(java.lang.String commandPart) |
static boolean |
isString(java.lang.String commandPart)
Assumes that commandPart is not empty.
|
public static final char BYTES_TYPE
public static final char INTEGER_TYPE
public static final char LONG_TYPE
public static final char BOOLEAN_TYPE
public static final char DOUBLE_TYPE
public static final char DECIMAL_TYPE
public static final char STRING_TYPE
public static final char REFERENCE_TYPE
public static final char LIST_TYPE
public static final char SET_TYPE
public static final char ARRAY_TYPE
public static final char MAP_TYPE
public static final char ITERATOR_TYPE
public static final char NULL_TYPE
public static final char PYTHON_PROXY_TYPE
public static final char PACKAGE_TYPE
public static final char CLASS_TYPE
public static final char METHOD_TYPE
public static final char NO_MEMBER
public static final char VOID
public static final char RETURN_MESSAGE
public static final char END
public static final char END_OUTPUT
public static final char ERROR
public static final char FATAL_ERROR
public static final char SUCCESS
public static final java.lang.String AUTH_COMMAND_NAME
public static final java.lang.String ERROR_COMMAND
public static final java.lang.String VOID_COMMAND
public static final java.lang.String NO_SUCH_FIELD
public static final java.lang.String ENTRY_POINT_OBJECT_ID
public static final java.lang.String DEFAULT_JVM_OBJECT_ID
public static final java.lang.String GATEWAY_SERVER_ID
public static final java.lang.String STATIC_PREFIX
public static final java.lang.String PYTHON_NAN
public static final java.lang.String PYTHON_INFINITY
public static final java.lang.String PYTHON_NEGATIVE_INFINITY
public static java.lang.String encodeBytes(byte[] bytes)
Transform the byte array into Base64 characters.
bytes
- public static final boolean getBoolean(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final byte[] getBytes(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final java.math.BigDecimal getDecimal(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final double getDouble(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final int getInteger(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final long getLong(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final java.lang.String getMemberOutputCommand(char memberType)
public static final java.lang.String getMemberOutputCommand(char memberType, java.lang.String fqn)
public static java.lang.String getNoSuchFieldOutputCommand()
public static final java.lang.Object getNull(java.lang.String commandPart)
Method provided for consistency. Just returns null.
commandPart
- public static final java.lang.Object getObject(java.lang.String commandPart, Gateway gateway)
public static final java.lang.String getOutputCommand(ReturnObject rObject)
public static final java.lang.String getOutputErrorCommand()
public static final java.lang.String getOutputErrorCommand(java.lang.String errorMessage)
public static final java.lang.String getOutputErrorCommand(java.lang.Throwable throwable)
public static final java.lang.String getOutputFatalErrorCommand(java.lang.Throwable throwable)
public static final java.lang.String getOutputVoidCommand()
public static final java.lang.String getAuthCommand(java.lang.String authToken)
public static char getPrimitiveType(java.lang.Object primitiveObject)
public static java.lang.Object getPythonProxy(java.lang.String commandPart, Gateway gateway)
Assumes that commandPart is not empty.
commandPart
- public static java.lang.Object getPythonProxyHandler(java.lang.ClassLoader classLoader, java.lang.Class[] interfacesToImplement, java.lang.String objectId, Gateway gateway)
Legacy method. Please use Gateway.createProxy.
classLoader
- interfacesToImplement
- objectId
- gateway
- public static final java.lang.Object getReference(java.lang.String commandPart, Gateway gateway)
Assumes that commandPart is not empty.
commandPart
- public static final java.lang.Object getReturnValue(java.lang.String returnMessage, Gateway gateway) throws java.lang.Throwable
java.lang.Throwable
public static final java.lang.Throwable getRootThrowable(java.lang.Throwable throwable, boolean skipInvocation)
public static final java.lang.String getString(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final java.lang.String getThrowableAsString(java.lang.Throwable throwable)
public static final boolean isBoolean(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isReturnMessage(java.lang.String commandPart)
commandPart
- public static final boolean isBytes(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isDecimal(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isDouble(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isEmpty(java.lang.String commandPart)
public static final boolean isEnd(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isError(java.lang.String returnMessage)
Assumes that commandPart is not null.
returnMessage
- public static final boolean isInteger(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isLong(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isNull(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isPythonProxy(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isReference(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
- public static final boolean isString(java.lang.String commandPart)
Assumes that commandPart is not empty.
commandPart
-