use of org.jowidgets.cap.remoting.common.RemoteInvocationParameter in project jo-client-platform by jo-source.
the class RemoteMethodInvocationHandler method invokeRemoteMethod.
private Object invokeRemoteMethod(final Object proxy, final Method method, final Object[] args) {
final Class<?>[] parameterTypes = method.getParameterTypes();
final IResultCallback<Object> resultCallback = getResultCallback(parameterTypes, args);
final IExecutionCallback executionCallback = getExecutionCallback(parameterTypes, args);
final ArrayList<InputStream> inputStreams = getInputStreams(parameterTypes, args);
final IInterimResponseCallback<Progress> interimResponseCallback;
final IInterimRequestCallback<UserQuestionRequest, UserQuestionResult> userQuestionRequestCallback;
if (executionCallback != null) {
interimResponseCallback = new ProgressResponseCallback(executionCallback);
userQuestionRequestCallback = new UserQuestionRequestCallback(executionCallback);
} else {
interimResponseCallback = new DummyProgressResponseCallback();
userQuestionRequestCallback = new DummyUserQuestionRequestCallback(resultCallback);
}
final InputStreamRequestCallback inputStreamRequestCallback;
if (!EmptyCheck.isEmpty(inputStreams)) {
inputStreamRequestCallback = new InputStreamRequestCallback(inputStreams);
} else {
inputStreamRequestCallback = null;
}
final GenericInterimRequestCallback interimRequestCallback = new GenericInterimRequestCallback(userQuestionRequestCallback, inputStreamRequestCallback);
final RemoteInvocationParameter parameter = new RemoteInvocationParameter(serviceId, method.getName(), parameterTypes, getFilteredArgs(args, parameterTypes));
if (resultCallback != null) {
invokeAsync(resultCallback, interimResponseCallback, interimRequestCallback, parameter, executionCallback, inputStreams);
return null;
} else {
return invokeSync(interimResponseCallback, interimRequestCallback, parameter, executionCallback, inputStreams);
}
}
Aggregations