Move java,lua api and remaining plugins to src/
[vpp.git] / src / vpp-api / java / jvpp-registry / io / fd / vpp / jvpp / JVppRegistry.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package io.fd.vpp.jvpp;
18
19 import io.fd.vpp.jvpp.callback.JVppCallback;
20
21 /**
22  * Manages VPP connection and stores plugin callbacks.
23  */
24 public interface JVppRegistry extends AutoCloseable {
25
26     /**
27      * Vpp connection managed by the registry.
28      *
29      * @return representation of vpp connection
30      */
31     VppConnection getConnection();
32
33     /**
34      * Registers callback and initializes Java API for given plugin.
35      *
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
40      */
41     void register(final JVpp jvpp, final JVppCallback callback);
42
43     /**
44      * Unregisters callback for the given plugin.
45      *
46      * @param name plugin name
47      * @throws NullPointerException     if name is null
48      * @throws IllegalArgumentException if plugin was not registered
49      */
50     void unregister(final String name);
51
52     /**
53      * Returns callback registered for the plugin.
54      *
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
59      */
60     JVppCallback get(final String name);
61
62     /**
63      * Sends control ping. Reply handler calls callback registered for give plugin.
64      *
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.
68      *
69      * VPP plugins don't have to provide special control ping, therefore
70      * it is necessary to providing control ping support in JVppRegistry.
71
72      * @param clazz identifies plugin that should receive ping callback
73      * @return unique identifier of message in message queue
74      */
75     int controlPing(final Class<? extends JVpp> clazz) throws VppInvocationException;
76 }