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.collect.ImmutableSet;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.yangtools.concepts.Registration;
15 import org.opendaylight.yangtools.yang.binding.Action;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 * Registration interface used by {@code action} implementations. Each action is defined in a YANG model,
21 * and implementations can be invoked dynamically at runtime, via {@link ActionService}. Implementations registered
22 * with this interface may throw {@link IllegalArgumentException}s when they encounter inconsistent input data and
23 * {@link IllegalStateException} in they are unable to service the request.
25 public interface ActionProviderService extends BindingService {
27 * Register an implementation of an action, potentially constrained to a set of nodes.
29 * @param spec Action instance specification
30 * @param implementation Implementation of {@code actionInterface}
31 * @param datastore {@link LogicalDatastoreType} on which the implementation operates
32 * @param validNodes Set of nodes this implementation is constrained to, empty if this implementation can handle
34 * @return A {@link Registration}
35 * @throws NullPointerException if any of the arguments is null
36 * @throws IllegalArgumentException if any of the {@code validNodes} does not match {@code datastore}
37 * @throws UnsupportedOperationException if this service cannot handle requested datastore
39 <P extends DataObject, A extends Action<? extends InstanceIdentifier<P>, ?, ?>>
40 @NonNull Registration registerImplementation(@NonNull ActionSpec<A, P> spec, @NonNull A implementation,
41 @NonNull LogicalDatastoreType datastore, @NonNull Set<? extends InstanceIdentifier<P>> validNodes);
43 default <P extends DataObject, A extends Action<? extends InstanceIdentifier<P>, ?, ?>>
44 @NonNull Registration registerImplementation(final @NonNull ActionSpec<A, P> spec,
45 final @NonNull A implementation, final @NonNull LogicalDatastoreType datastore) {
46 return registerImplementation(spec, implementation, datastore, ImmutableSet.of());
49 default <P extends DataObject, A extends Action<? extends InstanceIdentifier<P>, ?, ?>>
50 @NonNull Registration registerImplementation(final @NonNull ActionSpec<A, P> spec,
51 final @NonNull A implementation) {
52 return registerImplementation(spec, implementation, LogicalDatastoreType.OPERATIONAL);