Binding2 runtime - API #4 20/58320/3
authorMartin Ciglan <martin.ciglan@pantheon.tech>
Tue, 23 May 2017 08:11:25 +0000 (10:11 +0200)
committerMartin Ciglan <martin.ciglan@pantheon.tech>
Tue, 6 Jun 2017 12:52:38 +0000 (12:52 +0000)
- MountPointService & its relatives
- Javadocs provided

Change-Id: I15c55a34b0b4bb4df9aefd92749743c4a0cc2c3e
Signed-off-by: Martin Ciglan <martin.ciglan@pantheon.tech>
(cherry picked from commit 44c4876b84124f0104b539453d05ac6812f33db2)

binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPoint.java [new file with mode: 0644]
binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPointListener.java [new file with mode: 0644]
binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPointService.java [new file with mode: 0644]

diff --git a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPoint.java b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPoint.java
new file mode 100644 (file)
index 0000000..b79986b
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.mdsal.binding.javav2.api;
+
+import com.google.common.annotations.Beta;
+import java.util.Optional;
+import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
+import org.opendaylight.yangtools.concepts.Identifiable;
+
+/**
+ * A Node can be behind a mount point. In this case, the URI has to be in format
+ * identifier/yang-ext:mount/identifier. The first identifier is the path to
+ * a mount point and the second identifier is the path to a node behind the mount point.
+ * A URI can end in a mount point itself by using identifier/yang-ext:mount.
+ */
+@Beta
+public interface MountPoint extends Identifiable<InstanceIdentifier<?>> {
+
+    /**
+     * Based on given service class, it returns binding service (from cache).
+     * @param service service class
+     * @param <T> service type
+     * @return optional of binding service
+     */
+    <T extends BindingService> Optional<T> getService(Class<T> service);
+}
diff --git a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPointListener.java b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPointListener.java
new file mode 100644 (file)
index 0000000..5c694fa
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.mdsal.binding.javav2.api;
+
+import com.google.common.annotations.Beta;
+import java.util.EventListener;
+import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
+
+/**
+ * Interface implemented by classes interested in receiving notifications about
+ * mount point changes.
+ */
+@Beta
+public interface MountPointListener extends EventListener {
+
+    /**
+     * Invoked whenever mount point is created at given path represented by instance identifier.
+     * @param path given path
+     */
+    void onMountPointCreated(InstanceIdentifier<?> path);
+
+    /**
+     * Invoked whenever mount point is removed from given path represented by instance identifier.
+     * @param path given path
+     */
+    void onMountPointRemoved(InstanceIdentifier<?> path);
+}
diff --git a/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPointService.java b/binding2/mdsal-binding2-api/src/main/java/org/opendaylight/mdsal/binding/javav2/api/MountPointService.java
new file mode 100644 (file)
index 0000000..9056a51
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.mdsal.binding.javav2.api;
+
+import com.google.common.annotations.Beta;
+import java.util.Optional;
+import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+
+/**
+ *  A {@link BindingService} providing access to mount point.
+ */
+@Beta
+public interface MountPointService extends BindingService {
+
+    /**
+     * Returns optional of mount point at given path represented by instance identifier.
+     * @param mountPoint mount point instance identifier
+     * @return optional of mount point
+     */
+    Optional<MountPoint> getMountPoint(InstanceIdentifier<?> mountPoint);
+
+    /**
+     * Register a {@link MountPointListener} instance. Once registered, the listener will start
+     * receiving changes on the selected path.
+     *
+     * @param path given path to listen to changes
+     * @param listener {@link MountPointListener} that is being registered
+     * @param <T> listener type
+     * @return Listener registration object, which may be used to unregister
+     *         your listener using {@link ListenerRegistration#close()} to stop
+     *         delivery of mount point change events.
+     */
+    <T extends MountPointListener> ListenerRegistration<T> registerListener(InstanceIdentifier<?> path, T listener);
+}