/* * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.mdsal.dom.api; import com.google.common.annotations.Beta; import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute; /** * A {@link DOMActionService.Extension} exposed by {@link DOMActionService}s which allow their users to listen * for actions are becoming available. */ @Beta @NonNullByDefault public interface DOMActionAvailabilityExtension extends DOMActionService.Extension { /** * Register a {@link AvailabilityListener} with this service to receive notifications about operation * implementations becoming (un)available. The listener will be invoked with the current implementations reported * and will be kept uptodate as implementations come and go. * *
* Users should note that using a listener does not necessarily mean that * {@link DOMActionService#invokeAction(Absolute, DOMDataTreeIdentifier, ContainerNode)} will not report * a failure due to {@link DOMActionNotAvailableException} and need to be ready to handle it. * *
* Implementations are encouraged to take reasonable precautions to prevent this scenario from occurring.
*
* @param listener {@link AvailabilityListener} instance to register
* @return A {@link Registration} representing this registration. Performing a {@link Registration#close()} will
* cancel it.
* @throws NullPointerException if {@code listener} is null
*/
Registration registerAvailabilityListener(AvailabilityListener listener);
/**
* A listener used to track Operation implementations becoming (un)available to a {@link DOMActionService}.
*/
interface AvailabilityListener {
/**
* Method invoked whenever an action type becomes available or unavailable. There are two sets reported,
* removed and added. To reconstruct the state, first apply removed and then added operations, like this:
*
*
* Set<DOMActionInstancelt;?>> operations;
* operations.removeAll(removed);
* operations.addAll(added);
*
*
* @param removed operations which disappeared
* @param added operations which became available
*/
void onActionsChanged(Set