Search in sources :

Example 1 with Progress

use of org.jowidgets.cap.remoting.common.Progress in project jo-client-platform by jo-source.

the class ProgressResponseCallback method setSubProgress.

private void setSubProgress(final Progress progress, final IExecutionCallback executionCallback) {
    for (final Progress subProgress : progress.getSubProgressList()) {
        // set the subProgress recursively
        setSubProgress(subProgress, executionCallback);
        // check if the task id is already registered
        Tuple<ValueHolder<Progress>, IExecutionCallback> subCallback = subCallbacks.get(subProgress.getTaskId());
        // if not, create a sub execution
        if (subCallback == null) {
            final ValueHolder<Progress> newProgress = new ValueHolder<Progress>(new Progress());
            subCallback = new Tuple<ValueHolder<Progress>, IExecutionCallback>(newProgress, executionCallback.createSubExecution(subProgress.getStepProportion()));
            subCallbacks.put(subProgress.getTaskId(), subCallback);
        }
        // set the progress on the execution callback and set the last progress to the current progress
        setProgress(subProgress, subCallback.getFirst().get(), subCallback.getSecond());
        subCallback.getFirst().set(subProgress);
    }
}
Also used : Progress(org.jowidgets.cap.remoting.common.Progress) IExecutionCallback(org.jowidgets.cap.common.api.execution.IExecutionCallback) ValueHolder(org.jowidgets.util.ValueHolder)

Example 2 with Progress

use of org.jowidgets.cap.remoting.common.Progress 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);
    }
}
Also used : Progress(org.jowidgets.cap.remoting.common.Progress) RemoteInvocationParameter(org.jowidgets.cap.remoting.common.RemoteInvocationParameter) InputStream(java.io.InputStream) IExecutionCallback(org.jowidgets.cap.common.api.execution.IExecutionCallback) UserQuestionRequest(org.jowidgets.cap.remoting.common.UserQuestionRequest) UserQuestionResult(org.jowidgets.cap.common.api.execution.UserQuestionResult)

Aggregations

IExecutionCallback (org.jowidgets.cap.common.api.execution.IExecutionCallback)2 Progress (org.jowidgets.cap.remoting.common.Progress)2 InputStream (java.io.InputStream)1 UserQuestionResult (org.jowidgets.cap.common.api.execution.UserQuestionResult)1 RemoteInvocationParameter (org.jowidgets.cap.remoting.common.RemoteInvocationParameter)1 UserQuestionRequest (org.jowidgets.cap.remoting.common.UserQuestionRequest)1 ValueHolder (org.jowidgets.util.ValueHolder)1