2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.vpp.jvpp;
19 import io.fd.vpp.jvpp.callback.JVppCallback;
22 * Manages VPP connection and stores plugin callbacks.
24 public interface JVppRegistry extends AutoCloseable {
27 * Vpp connection managed by the registry.
29 * @return representation of vpp connection
31 VppConnection getConnection();
34 * Registers callback and initializes Java API for given plugin.
36 * @param jvpp plugin name
37 * @param callback callback provided by the plugin
38 * @throws NullPointerException if name or callback is null
39 * @throws IllegalArgumentException if plugin was already registered
41 void register(final JVpp jvpp, final JVppCallback callback);
44 * Unregisters callback for the given plugin.
46 * @param name plugin name
47 * @throws NullPointerException if name is null
48 * @throws IllegalArgumentException if plugin was not registered
50 void unregister(final String name);
53 * Returns callback registered for the plugin.
55 * @param name plugin name
56 * @return callback provided by the plugin
57 * @throws NullPointerException if name is null
58 * @throws IllegalArgumentException if plugin was not registered
60 JVppCallback get(final String name);
63 * Sends control ping. Reply handler calls callback registered for give plugin.
65 * Control ping is used for initial RX thread to Java thread attachment
66 * that takes place in the plugin's JNI lib
67 * and to wrap dump message replies in one list.
69 * VPP plugins don't have to provide special control ping, therefore
70 * it is necessary to providing control ping support in JVppRegistry.
72 * @param clazz identifies plugin that should receive ping callback
73 * @return unique identifier of message in message queue
75 int controlPing(final Class<? extends JVpp> clazz) throws VppInvocationException;