Add NotificationListenerInvoker bridge class 31/74331/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 23 Jul 2018 12:13:16 +0000 (14:13 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 23 Jul 2018 12:18:25 +0000 (14:18 +0200)
This adds a migration bridge for controller, so we can safely
move NotificationListenerInvoker from yang-binding.

Change-Id: I0ec360a324fb9cb44a886efb99b85916554b437e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/NotificationListenerInvoker.java [new file with mode: 0644]
binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/util/NotificationListenerInvoker.java

diff --git a/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/NotificationListenerInvoker.java b/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/NotificationListenerInvoker.java
new file mode 100644 (file)
index 0000000..40b1084
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018 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.dom.adapter.invoke;
+
+import static java.util.Objects.requireNonNull;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.QName;
+
+public final class NotificationListenerInvoker {
+    private final org.opendaylight.yangtools.yang.binding.util.NotificationListenerInvoker delegate;
+
+    private NotificationListenerInvoker(
+            final org.opendaylight.yangtools.yang.binding.util.NotificationListenerInvoker delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    /**
+     * Creates RPCServiceInvoker for specified RpcService type.
+     *
+     * @param type
+     *            RpcService interface, which was generated from model.
+     * @return Cached instance of {@link NotificationListenerInvoker} for
+     *         supplied RPC type.
+     */
+    public static NotificationListenerInvoker from(final Class<? extends NotificationListener> type) {
+        return new NotificationListenerInvoker(
+            org.opendaylight.yangtools.yang.binding.util.NotificationListenerInvoker.from(type));
+    }
+
+    /**
+     * Invokes supplied RPC on provided implementation of RPC Service.
+     *
+     * @param impl
+     *            Imlementation on which notifiaction callback should be
+     *            invoked.
+     * @param rpcName
+     *            Name of RPC to be invoked.
+     * @param input
+     *            Input data for RPC.
+     */
+    @SuppressWarnings("checkstyle:illegalCatch")
+    public void invokeNotification(@Nonnull final NotificationListener impl, @Nonnull final QName rpcName,
+            @Nullable final DataContainer input) {
+        delegate.invokeNotification(impl, rpcName, input);
+    }
+}
index 471b4b50eb929acf3686b56372a1a1713e43178f..92b57ff64784b9369e2e1b7a4a00afa04535a8ee 100644 (file)
@@ -38,11 +38,10 @@ public final class NotificationListenerInvoker {
     private static final Lookup LOOKUP = MethodHandles.publicLookup();
 
     private static final LoadingCache<Class<? extends NotificationListener>, NotificationListenerInvoker> INVOKERS =
-            CacheBuilder .newBuilder().weakKeys()
+            CacheBuilder.newBuilder().weakKeys()
             .build(new CacheLoader<Class<? extends NotificationListener>, NotificationListenerInvoker>() {
-
-                private NotificationListenerInvoker createInvoker(
-                        final Class<? extends NotificationListener> key) {
+                @Override
+                public NotificationListenerInvoker load(final Class<? extends NotificationListener> key) {
                     return new NotificationListenerInvoker(createInvokerMap(key));
                 }
 
@@ -66,17 +65,11 @@ public final class NotificationListenerInvoker {
                     }
                     return ret.build();
                 }
-
-                @Override
-                public NotificationListenerInvoker load(final Class<? extends NotificationListener> key) {
-                    return createInvoker(key);
-                }
-
             });
 
     private final Map<QName, MethodHandle> methodInvokers;
 
-    public NotificationListenerInvoker(final Map<QName, MethodHandle> map) {
+    NotificationListenerInvoker(final Map<QName, MethodHandle> map) {
         this.methodInvokers = map;
     }
 
@@ -97,13 +90,9 @@ public final class NotificationListenerInvoker {
     /**
      * Invokes supplied RPC on provided implementation of RPC Service.
      *
-     * @param impl
-     *            Imlementation on which notifiaction callback should be
-     *            invoked.
-     * @param rpcName
-     *            Name of RPC to be invoked.
-     * @param input
-     *            Input data for RPC.
+     * @param impl Implementation on which notification callback should be invoked.
+     * @param rpcName Name of RPC to be invoked.
+     * @param input Input data for RPC.
      */
     @SuppressWarnings("checkstyle:illegalCatch")
     public void invokeNotification(@Nonnull final NotificationListener impl, @Nonnull final QName rpcName,