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

net.sf.eBus.client.CancelRequestCallback Maven / Gradle / Ivy

The newest version!
//
// Copyright 2016 Charles W. Rapp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package net.sf.eBus.client;

/**
 * A class implementing {@code EReplier} is not required to
 * override {@link EReplier#cancelRequest(EReplyFeed.ERequest, boolean)}.
 * Instead, a Java lambda expression for
 * {@code CancelRequestCallback} may be passed to
 * {@link EReplyFeed.Builder#cancelRequestCallback(CancelRequestCallback)}
 * and the lambda expression code will be executed when a
 * request is canceled.
 *
 * @see EReplyFeed.Builder#cancelRequestCallback(CancelRequestCallback)
 *
 * @author Charles W. Rapp
 */

@FunctionalInterface
public interface CancelRequestCallback
{
//---------------------------------------------------------------
// Member methods.
//

    /**
     * With eBus release 5.6.0 a second, parameter is added:
     * {@code mayRespond}. If {@code true} the replier accepts
     * the cancel request, the replier should respond with an
     * appropriate
     * {@link net.sf.eBus.messages.EReplyMessage reply message}
     * (note that a new
     * {@link net.sf.eBus.messages.EReplyMessage.ReplyStatus}
     * has been added: {@code CANCELED}). If the replier rejects
     * this cancel request then it may respond with
     * a {@code EReplyMessage} with a status of
     * {@code CANCEL_REJECT} and a reason for the reject.
     * does nothing and continues to
     * work the request.
     * 

* if {@code mayRespond} is {@code false} then this is a * unilateral request cancellation. The request is shut down * and no further replies will be accepted. However, * in-flight replies posted prior to cancellation * may still be delivered. *

*

* {@link EReplyFeed.ERequest request} matches the * replier's open and advertised {@link EReplyFeed feed}. The * associated {@code EReplyFeed} may be retrieved by calling * {@link EReplyFeed.ERequest#replier()}. *

* @param request cancel this request. * @param mayRespond set to {@code true} if replier is * allowed to respond to the cancel request. This allows the * replier to accept or reject the request cancellation. */ void call(EReplyFeed.ERequest request, boolean mayRespond); } // end of interface CancelRequestCallback




© 2015 - 2025 Weber Informatics LLC | Privacy Policy