All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zeroc.Ice.BlobjectAsync Maven / Gradle / Ivy

//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

package com.zeroc.Ice;

import java.util.concurrent.CompletionStage;
import java.util.concurrent.CompletableFuture;

/**
 * BlobjectAsync is the base class for asynchronous dynamic
 * dispatch servants. A server application derives a concrete servant
 * class that implements the {@link BlobjectAsync#ice_invokeAsync} method,
 * which is called by the Ice run time to deliver every request on this
 * object.
 **/
public interface BlobjectAsync extends com.zeroc.Ice.Object
{
    /**
     * Dispatch an incoming request.
     *
     * @param inEncaps The encoded input parameters.
     * @param current The Current object, which provides important information
     * about the request, such as the identity of the target object and the
     * name of the operation.
     * @return A completion stage that eventually completes with the result of
     * the invocation, an instance of Ice_invokeResult.
     * If the operation completed successfully, set the returnValue
     * member to true and the outParams member to
     * the encoded results. If the operation raises a user exception, you can
     * throw it directly from ice_invokeAsync, or complete the
     * future by setting the returnValue member to
     * false and the outParams member to the encoded
     * user exception.
     * @throws UserException A user exception raised by this method will be marshaled
     * as the result of the invocation.
     **/
    CompletionStage ice_invokeAsync(byte[] inEncaps, Current current)
        throws UserException;

    /** @hidden */
    @Override
    default CompletionStage _iceDispatch(com.zeroc.IceInternal.Incoming in, Current current)
        throws UserException
    {
        byte[] inEncaps = in.readParamEncaps();
        CompletableFuture f = new CompletableFuture<>();
        ice_invokeAsync(inEncaps, current).whenComplete((result, ex) ->
            {
                if(ex != null)
                {
                    f.completeExceptionally(ex);
                }
                else
                {
                    f.complete(in.writeParamEncaps(result.outParams, result.returnValue));
                }
            });
        return f;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy