Class InvocationArg
java.lang.Object
org.astonbitecode.j4rs.api.dtos.InvocationArg
- All Implemented Interfaces:
Instance, JsonValue, ObjectValue
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInvocationArg(String className, Object object) InvocationArg(String className, String json) InvocationArg(String className, Instance instance) InvocationArg(Instance instance) -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the instance held under the Field fieldNamegetJson()Returns the json representationReturns the ObjectClass<?> Returns theClassof the ObjectThe type of this argument.voidinitializeCallbackChannel(long channelAddress) Initialize a callback channel for thisInstance.invoke(String methodName, InvocationArg... args) Invokes a method of the instance of the class that is set for thisInstancevoidinvokeAsyncToChannel(long channelAddress, String methodName, InvocationArg... args) Invokes asynchronously a method of the instance of the class that is set for thisInstance.invokeStatic(String methodName, InvocationArg... args) Invokes a static method of the class that is set for thisInstancevoidinvokeToChannel(long channelAddress, String methodName, InvocationArg... args) Invokes a method of the instance of the class that is set for thisInstance.booleanIf true, the argument is taken straight by the Java code as Object.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Instance
checkEquals, getOrDeserializeJavaObject
-
Field Details
-
CONTENTS_ARRAY
The array contents should map to a List. This is in order to allow calls of type Arrays.asList(arg1, arg2, arg3, ...)- See Also:
-
-
Constructor Details
-
InvocationArg
-
InvocationArg
-
InvocationArg
-
InvocationArg
- Throws:
ClassNotFoundException
-
-
Method Details
-
isSerialized
public boolean isSerialized()If true, the argument is taken straight by the Java code as Object. If false, the argument is a json document that need to be deserialized to an Object.- Returns:
- The The argFrom
-
getObjectClassName
The type of this argument. This is used when json objects come from Rust, in order to be mapped to proper Java Objects.- Specified by:
getObjectClassNamein interfaceObjectValue- Returns:
- The classname
-
getInstance
-
getJson
-
toString
-
getObject
Description copied from interface:ObjectValueReturns the Object- Specified by:
getObjectin interfaceObjectValue- Returns:
- An object instance
-
getObjectClass
Description copied from interface:ObjectValueReturns theClassof the Object- Specified by:
getObjectClassin interfaceObjectValue- Returns:
- A
Class
-
invoke
-
invokeStatic
Description copied from interface:InstanceInvokes a static method of the class that is set for thisInstance- Specified by:
invokeStaticin interfaceInstance- Parameters:
methodName- The static method nameargs- The arguments to use for invoking the static method- Returns:
- A
Instanceinstance containing the result of the invocation
-
invokeAsyncToChannel
Description copied from interface:InstanceInvokes asynchronously a method of the instance of the class that is set for thisInstance. The result of the invocation must be aFuture. When the Future returned from the invocation completes, j4rs will invoke native Rust code to either send a success value or a failure.Please note that it is best that this function returns a
CompletableFuture, as this improves performance. j4rs handles simpleFutures with polling using an internalScheduledExecutorServicewith one thread and this has apparent performance issues. You may have a look atJ4rsPolledFuturefor more details.- Specified by:
invokeAsyncToChannelin interfaceInstance- Parameters:
channelAddress- The address of the function pointer that will be used when theFuturecompletes, in the native side, in order to actually perform the callback and complete a Future that is created in Rust and awaits for the Java Future to complete.methodName- The method nameargs- The arguments to use when invoking the callback method (the functionPointer)
-
invokeToChannel
Description copied from interface:InstanceInvokes a method of the instance of the class that is set for thisInstance. The result of the invocation should be provided later using the doCallback method of aNativeCallbackToRustChannelSupportclass. Any possible returned objects from the actual synchronous invocation of the defined method will be dropped.- Specified by:
invokeToChannelin interfaceInstance- Parameters:
channelAddress- The memory address of the channelmethodName- The method nameargs- The arguments
-
initializeCallbackChannel
public void initializeCallbackChannel(long channelAddress) Description copied from interface:InstanceInitialize a callback channel for thisInstance. The channel can be used by Java to send values to Rust using the doCallback method of aNativeCallbackToRustChannelSupportclass.- Specified by:
initializeCallbackChannelin interfaceInstance- Parameters:
channelAddress- The memory address of the channel
-
field
-