use of org.eclipse.milo.opcua.sdk.server.api.methods.MethodInvocationHandler in project milo by eclipse.
the class ManagedAddressSpace method call.
/**
* Invoke one or more methods belonging to this {@link MethodServices}.
*
* @param context the {@link CallContext}.
* @param requests The {@link CallMethodRequest}s for the methods to invoke.
*/
@Override
public void call(CallContext context, List<CallMethodRequest> requests) {
List<CallMethodResult> results = Lists.newArrayListWithCapacity(requests.size());
for (CallMethodRequest request : requests) {
MethodInvocationHandler handler = getInvocationHandler(request.getObjectId(), request.getMethodId()).orElse(MethodInvocationHandler.NODE_ID_UNKNOWN);
try {
results.add(handler.invoke(context, request));
} catch (Throwable t) {
LoggerFactory.getLogger(getClass()).error("Uncaught Throwable invoking method handler for methodId={}.", request.getMethodId(), t);
results.add(new CallMethodResult(new StatusCode(StatusCodes.Bad_InternalError), new StatusCode[0], new DiagnosticInfo[0], new Variant[0]));
}
}
context.success(results);
}
Aggregations