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

com.pushtechnology.diffusion.client.callbacks.Callback Maven / Gradle / Ivy

There is a newer version: 6.11.2
Show newest version
/*******************************************************************************
 * Copyright (c) 2014, 2023 DiffusionData Ltd., All Rights Reserved.
 *
 * Use is subject to licence terms.
 *
 * NOTICE: All information contained herein is, and remains the
 * property of DiffusionData. The intellectual and technical
 * concepts contained herein are proprietary to DiffusionData and
 * may be covered by U.S. and Foreign Patents, patents in process, and
 * are protected by trade secret or copyright law.
 *******************************************************************************/
package com.pushtechnology.diffusion.client.callbacks;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Callback interface that provides responses from the server. Extensions of
 * this interface have callback methods that provide results for successful
 * calls.
 * 

* Direct extensions of this interface support a single callback each time the * callback is used in a call (the call context). If the call fails to * return a result, for example if the session is closed or the operation times * out, {@link #onError(ErrorReason) onError} will be called. Each call to the * server will result in invocation of either a single callback method or * {@code onError}. *

* The {@link Stream} extension supports multiple responses for each call. *

* If the server returns a response for an unknown call context (typically a * late response for a call context has timed out), an error will be reported to * the {@link com.pushtechnology.diffusion.client.session.Session.ErrorHandler * session error handler}. * * @author DiffusionData Limited * @since 5.1 * @see Stream * @see ContextStream * @see ContextCallback */ public interface Callback { /** * Notification of a contextual error related to this callback. This is * analogous to an exception being raised. Situations in which * {@code onError} is called include the session being closed, a * communication timeout, or a problem with the provided parameters. No * further calls will be made to this callback for the call context. * * @param errorReason a value representing the error; this can be one of * constants defined in {@link ErrorReason}, or a feature-specific * reason */ void onError(ErrorReason errorReason); /** * Abstract default callback. *

* This simply logs onError calls at debug level. This should be overridden * to perform more specific error handling. */ abstract class Default implements Callback { private static final Logger LOG = LoggerFactory.getLogger(Default.class); @Override public void onError(ErrorReason errorReason) { LOG.warn("{} error, reason={}", this, errorReason); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy