2 * Copyright (c) 2015 Cisco Systems, Inc. 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.controller.md.sal.binding.impl;
10 import org.opendaylight.controller.md.sal.binding.api.MountPointService.MountPointListener;
11 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
12 import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
13 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
19 final class BindingDOMMountPointListenerAdapter<T extends MountPointListener> implements ListenerRegistration<T>, MountProvisionListener {
21 private final T listener;
22 private final ListenerRegistration<MountProvisionListener> registration;
23 private final BindingToNormalizedNodeCodec codec;
25 public BindingDOMMountPointListenerAdapter(final T listener, final BindingToNormalizedNodeCodec codec, final DOMMountPointService mountService) {
26 this.listener = listener;
28 this.registration = mountService.registerProvisionListener(this);
32 public T getInstance() {
42 public void onMountPointCreated(final YangInstanceIdentifier path) {
44 final InstanceIdentifier<? extends DataObject> bindingPath = codec.toBinding(path).get();
45 listener.onMountPointCreated(bindingPath);
46 } catch (final DeserializationException e) {
47 BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Ommiting event.",path,e);
53 public void onMountPointRemoved(final YangInstanceIdentifier path) {
55 final InstanceIdentifier<? extends DataObject> bindingPath = codec.toBinding(path).get();
56 listener.onMountPointRemoved(bindingPath);
57 } catch (final DeserializationException e) {
58 BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Ommiting event.",path,e);