Java Services Execution
Call Java services from a GridGain.NET application, including service interface mapping and method resolution.
Overview
GridGain.NET can work with Java services the same way as with .NET services. To call a Java service from a .NET application, you need to know the interface of the service.
Example
Let's review how to use this capability by taking a usage example.
Create Java Service
public class MyJavaService implements Service {
// Service method to be called from .NET
public String testToUpper(String x) {
return x.toUpperCase();
}
// Service interface implementation
@Override public void cancel(ServiceContext context) { // No-op. }
@Override public void init(ServiceContext context) throws Exception { // No-op. }
@Override public void execute(ServiceContext context) throws Exception { // No-op. }
}This Java service can be deployed on any nodes (.NET, C++, Java-only), so there are no restrictions on deployment options:
Call Java Service From .NET
Create a version of the service interface for .NET:
Get the service proxy and invoke the method:
Interface Methods Mapping
The .NET service interface is mapped to its Java counterpart dynamically. This happens at the time of the method invocation:
It is not necessary to specify all Java service methods in the .NET interface.
The .NET interface can have members that are not present in Java service. You won't get any exception until you call these missing methods.
The Java methods are resolved the following way:
Ignite looks for a method with the specified name and parameter count. If there is only one exist, Ignite will use it.
Among the matched methods Ignite looks for a method with compatible arguments (via
Class.isAssignableFrom). Ignite invoke the matched method or throws an exception in case of ambiguity.The method return type is ignored, since .NET and Java do not allow identical methods with different return types.
The return type is ignored when resolving the Java method, but it does determine how the .NET side invokes it. If you declare the method with a Task, Task<TResult>, ValueTask, or ValueTask<TResult> return type, the proxy returns a task that you can await. With the thin client, the invocation is asynchronous and the calling thread is not blocked; with the thick client shown above, the invocation is synchronous and the result is returned as an already-completed task. The Java service itself stays synchronous in both cases. See Calling Services for an example.
See Platform Interoperability, Type Compatibility section for details on method arguments and result mapping. Note, that the params/varargs are also supported, since in .NET and Java these are syntactic sugar for object arrays.
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

