Class SetupJVMWrapper<T>
Main entry point for JVM languages setup and execution.
Extend this class to use external threading
public class SetupJVMWrapper<T> : SetupJVMWrapper, IJVMWrapperManagement, IJVMBridgeCore where T : SetupJVMWrapper
Type Parameters
T
The class extending SetupJVMWrapper
- Inheritance
-
SetupJVMWrapper<T>
- Implements
- Inherited Members
- Extension Methods
Examples
This is a basic example showing SetupJVMWrapper class usage
class JVMWrapperApp : SetupJVMWrapper<JVMWrapperApp<
{
public void UnwrappedExecute(object args)
{
// put here the code to execute in a different JVM thread
}
public void Execute()
{
// use the following to execute the thread in JVM as deamon
// the function returns a reference to the instance of the class allocated in the new thread
// var jvmwrapperRefFromNewThread = UnwrapAndDemonizeOn(UnwrappedExecute);
// use the following to execute the thread in JVM
// the function returns a reference to the instance of the class allocated in the new thread
// var jvmwrapperRefFromNewThread = UnwrapOn(UnwrappedExecute);
// ... continue here with normal code; it will execute in parallel with unwrapped code
}
}
To run use:
applicationName --JVMPath:[ABSOLUTE PATH TO JRE LIBRARY (jvm.dll/libjvm.so)]
Other command line switch are available on https://www.jcobridge.com/command-line-options/
Properties
GlobalInstance
Create and return a singleton global instance of T
public static T GlobalInstance { get; }
Property Value
- T
HasGlobalInstance
public static bool HasGlobalInstance { get; }
Property Value
Methods
CreateGlobalInstance()
Create a singleton global instance of T
public static string[] CreateGlobalInstance()
Returns
- string[]
The FilteredArgs content
Remarks
Multiple calls to this method does not produce any effect
UnwrapAndDemonizeOn(ParameterizedThreadStart, object, ApartmentState)
Creates and unwrap the JVM instance as daemon
public T UnwrapAndDemonizeOn(ParameterizedThreadStart handler, object arg = null, ApartmentState apartment = ApartmentState.STA)
Parameters
handler
ParameterizedThreadStartAn handler to the function to be invoked
arg
objectThe argument for
handler
. Default is null.apartment
ApartmentStateThe ApartmentState to be used when the thread is started
Returns
- T
An instance of
T
Remarks
apartment
is valid only on Windows
UnwrapOn(ParameterizedThreadStart, object, ApartmentState)
Creates and unwrap the JVM instance
public T UnwrapOn(ParameterizedThreadStart handler, object arg = null, ApartmentState apartment = ApartmentState.STA)
Parameters
handler
ParameterizedThreadStartAn handler to the function to be invoked
arg
objectThe argument for
handler
. Default is null.apartment
ApartmentStateThe ApartmentState to use to start the thread
Returns
- T
An instance of
T