2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.api;
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableSet;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
15 import org.opendaylight.yangtools.concepts.ObjectRegistration;
16 import org.opendaylight.yangtools.yang.binding.Action;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 * Registration interface used by {@code action} implementations. Each action is defined in a YANG model,
22 * and implementations can be invoked dynamically at runtime, via {@link ActionService}. Implementations registered
23 * with this interface may throw {@link IllegalArgumentException}s when they encounter inconsistent input data and
24 * {@link IllegalStateException} in they are unable to service the request.
26 * @author Robert Varga
30 public interface ActionProviderService extends BindingService {
32 * Register an implementation of an action, potentially constrained to a set of nodes.
34 * @param actionInterface Generated Action interface
35 * @param implementation Implementation of {@code actionInterface}
36 * @param datastore {@link LogicalDatastoreType} on which the implementation operates
37 * @param validNodes Set of nodes this implementation is constrained to, empty if this implementation can handle
39 * @return An {@link ObjectRegistration}
40 * @throws NullPointerException if any of the arguments is null
41 * @throws IllegalArgumentException if any of the {@code validNodes} does not match {@code datastore}
42 * @throws UnsupportedOperationException if this service cannot handle requested datastore
44 <O extends DataObject, P extends InstanceIdentifier<O>, T extends Action<P, ?, ?>, S extends T>
45 ObjectRegistration<S> registerImplementation(Class<T> actionInterface, S implementation,
46 LogicalDatastoreType datastore, Set<DataTreeIdentifier<O>> validNodes);
48 default <O extends DataObject, P extends InstanceIdentifier<O>, T extends Action<P, ?, ?>, S extends T>
49 ObjectRegistration<S> registerImplementation(final Class<T> actionInterface, final S implementation,
50 final LogicalDatastoreType datastore) {
51 return registerImplementation(actionInterface, implementation, datastore, ImmutableSet.of());
54 default <O extends DataObject, P extends InstanceIdentifier<O>, T extends Action<P, ?, ?>, S extends T>
55 ObjectRegistration<S> registerImplementation(final Class<T> actionInterface, final S implementation) {
56 return registerImplementation(actionInterface, implementation, LogicalDatastoreType.OPERATIONAL);