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();
}
};
}
Aggregations