Search in sources :

Example 1 with ActionSpec

use of org.opendaylight.mdsal.binding.api.ActionSpec in project mdsal by opendaylight.

the class ActionProviderServiceAdapter method registerImplementation.

@Override
public <P extends DataObject, A extends Action<? extends InstanceIdentifier<P>, ?, ?>, S extends A> ObjectRegistration<S> registerImplementation(final ActionSpec<A, P> spec, final S implementation, final LogicalDatastoreType datastore, final Set<? extends InstanceIdentifier<P>> validNodes) {
    final CurrentAdapterSerializer serializer = currentSerializer();
    final Absolute actionPath = serializer.getActionPath(spec);
    final Impl impl = new Impl(adapterContext(), actionPath, spec.type(), implementation);
    final DOMActionInstance instance = validNodes.isEmpty() ? // Register on the entire datastore
    DOMActionInstance.of(actionPath, new DOMDataTreeIdentifier(datastore, YangInstanceIdentifier.empty())) : // Register on specific instances
    DOMActionInstance.of(actionPath, validNodes.stream().map(node -> serializer.toDOMDataTreeIdentifier(DataTreeIdentifier.create(datastore, node))).collect(Collectors.toUnmodifiableSet()));
    final ObjectRegistration<?> reg = getDelegate().registerActionImplementation(impl, instance);
    return new AbstractObjectRegistration<>(implementation) {

        @Override
        protected void removeRegistration() {
            reg.close();
        }
    };
}
Also used : DOMActionResult(org.opendaylight.mdsal.dom.api.DOMActionResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ActionProviderService(org.opendaylight.mdsal.binding.api.ActionProviderService) LoggerFactory(org.slf4j.LoggerFactory) DOMActionInstance(org.opendaylight.mdsal.dom.api.DOMActionInstance) DataTreeIdentifier(org.opendaylight.mdsal.binding.api.DataTreeIdentifier) Factory(org.opendaylight.mdsal.binding.dom.adapter.BindingDOMAdapterBuilder.Factory) ErrorType(org.opendaylight.yangtools.yang.common.ErrorType) ClassToInstanceMap(com.google.common.collect.ClassToInstanceMap) Absolute(org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute) ObjectRegistration(org.opendaylight.yangtools.concepts.ObjectRegistration) Objects.requireNonNull(java.util.Objects.requireNonNull) DOMActionProviderService(org.opendaylight.mdsal.dom.api.DOMActionProviderService) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) ImmutableSet(com.google.common.collect.ImmutableSet) NonNullByDefault(org.eclipse.jdt.annotation.NonNullByDefault) Logger(org.slf4j.Logger) ErrorTag(org.opendaylight.yangtools.yang.common.ErrorTag) Set(java.util.Set) ActionSpec(org.opendaylight.mdsal.binding.api.ActionSpec) Collectors(java.util.stream.Collectors) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) AbstractObjectRegistration(org.opendaylight.yangtools.concepts.AbstractObjectRegistration) Action(org.opendaylight.yangtools.yang.binding.Action) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) YangConstants(org.opendaylight.yangtools.yang.common.YangConstants) DOMActionImplementation(org.opendaylight.mdsal.dom.api.DOMActionImplementation) DOMService(org.opendaylight.mdsal.dom.api.DOMService) SimpleDOMActionResult(org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult) AbstractObjectRegistration(org.opendaylight.yangtools.concepts.AbstractObjectRegistration) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) DOMActionInstance(org.opendaylight.mdsal.dom.api.DOMActionInstance) Absolute(org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute)

Aggregations

ClassToInstanceMap (com.google.common.collect.ClassToInstanceMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 List (java.util.List)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 NonNullByDefault (org.eclipse.jdt.annotation.NonNullByDefault)1 ActionProviderService (org.opendaylight.mdsal.binding.api.ActionProviderService)1 ActionSpec (org.opendaylight.mdsal.binding.api.ActionSpec)1 DataTreeIdentifier (org.opendaylight.mdsal.binding.api.DataTreeIdentifier)1 Factory (org.opendaylight.mdsal.binding.dom.adapter.BindingDOMAdapterBuilder.Factory)1 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)1 DOMActionImplementation (org.opendaylight.mdsal.dom.api.DOMActionImplementation)1 DOMActionInstance (org.opendaylight.mdsal.dom.api.DOMActionInstance)1 DOMActionProviderService (org.opendaylight.mdsal.dom.api.DOMActionProviderService)1 DOMActionResult (org.opendaylight.mdsal.dom.api.DOMActionResult)1 DOMDataTreeIdentifier (org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier)1 DOMService (org.opendaylight.mdsal.dom.api.DOMService)1