import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
import org.opendaylight.controller.md.sal.dom.api.DOMService;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.Notification;
public class BindingDOMNotificationPublishServiceAdapter implements NotificationPublishService, AutoCloseable {
};
- private final BindingNormalizedNodeSerializer codecRegistry;
+ private final BindingToNormalizedNodeCodec codecRegistry;
private final DOMNotificationPublishService domPublishService;
- public BindingDOMNotificationPublishServiceAdapter(final BindingNormalizedNodeSerializer codecRegistry, final DOMNotificationPublishService domPublishService) {
- this.codecRegistry = codecRegistry;
+ public BindingDOMNotificationPublishServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMNotificationPublishService domPublishService) {
+ this.codecRegistry = codec;
this.domPublishService = domPublishService;
}
+ public BindingToNormalizedNodeCodec getCodecRegistry() {
+ return codecRegistry;
+ }
+
+ public DOMNotificationPublishService getDomPublishService() {
+ return domPublishService;
+ }
+
@Override
public void putNotification(final Notification notification) throws InterruptedException {
domPublishService.putNotification(toDomNotification(notification));
}
@Override
- public boolean offerNotification(final Notification notification) {
- final ListenableFuture<?> listenableFuture = domPublishService.offerNotification(toDomNotification(notification));
- return !DOMNotificationPublishService.REJECTED.equals(listenableFuture);
+ public ListenableFuture<? extends Object> offerNotification(final Notification notification) {
+ ListenableFuture<?> offerResult = domPublishService.offerNotification(toDomNotification(notification));
+ return DOMNotificationPublishService.REJECTED.equals(offerResult)
+ ? NotificationPublishService.REJECTED
+ : offerResult;
}
@Override
- public boolean offerNotification(final Notification notification, final int timeout, final TimeUnit unit) throws InterruptedException {
- final ListenableFuture<?> listenableFuture =
- domPublishService.offerNotification(toDomNotification(notification), timeout, unit);
- return !DOMNotificationPublishService.REJECTED.equals(listenableFuture);
+ public ListenableFuture<? extends Object> offerNotification(final Notification notification, final int timeout, final TimeUnit unit) throws InterruptedException {
+ ListenableFuture<?> offerResult = domPublishService.offerNotification(toDomNotification(notification), timeout, unit);
+ return DOMNotificationPublishService.REJECTED.equals(offerResult)
+ ? NotificationPublishService.REJECTED
+ : offerResult;
}
private DOMNotification toDomNotification(final Notification notification) {
@Override
protected NotificationPublishService createInstance(final BindingToNormalizedNodeCodec codec,
final ClassToInstanceMap<DOMService> delegates) {
- final BindingNormalizedNodeSerializer codecReg = codec.getCodecRegistry();
final DOMNotificationPublishService domPublish = delegates.getInstance(DOMNotificationPublishService.class);
- return new BindingDOMNotificationPublishServiceAdapter(codecReg, domPublish);
+ return new BindingDOMNotificationPublishServiceAdapter(codec, domPublish);
}
}