summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py
diff options
context:
space:
mode:
authorMatej Perina <mperina@cisco.com>2017-09-11 10:11:51 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2017-10-10 16:44:03 +0000
commitac1a7286500c18ac51beb66e4a2b99ea26c8c966 (patch)
tree62a4a0430bd0d5623c5e9945ca5bf671745351f9 /src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py
parentd91c1dbdb31f80db7d967f2f57c43d0a81d65297 (diff)
jvpp: adding callbacks for all messages (VPP-914)
1) In the previous version callbacks were generated based on request-replay naming conventions. It turned out they were too strict in case of events (e.g. BFD sends Details messages as notifications). So now we generate callback for all messages, allowing to receive any message as notification.(callback_gen.py) 2) "notification" suffix is no longer added because all messages are treated same (dto_gen.py, jvpp_c_gen_.py) 3) name of property that holds notification/events changed in callback facade and future apis 4) JVppNotification.java is no longer used since all events are treated equally Change-Id: I13f6438affc3473040d63cd4acb3984d03e97482 Signed-off-by: Matej <matej.perina@pantheon.tech>
Diffstat (limited to 'src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py')
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py
index 66de7a56ed1..96111193f07 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py
@@ -27,7 +27,7 @@ package $plugin_package.$notification_package;
* <br>It was generated by notification_gen.py based on $inputfile
* <br>(python representation of api file generated by vppapigen).
*/
-public interface ${plugin_name}NotificationRegistry extends $base_package.$notification_package.NotificationRegistry {
+public interface ${plugin_name}EventRegistry extends $base_package.$notification_package.EventRegistry {
$register_callback_methods
@@ -44,7 +44,7 @@ package $plugin_package.$notification_package;
* <br>It was generated by notification_gen.py based on $inputfile
* <br>(python representation of api file generated by vppapigen).
*/
-public interface Global${plugin_name}NotificationCallback$callbacks {
+public interface Global${plugin_name}EventCallback$callbacks {
}
""")
@@ -57,12 +57,12 @@ package $plugin_package.$notification_package;
* <br>It was generated by notification_gen.py based on $inputfile
* <br>(python representation of api file generated by vppapigen).
*/
-public final class ${plugin_name}NotificationRegistryImpl implements ${plugin_name}NotificationRegistry, Global${plugin_name}NotificationCallback {
+public final class ${plugin_name}EventRegistryImpl implements ${plugin_name}EventRegistry, Global${plugin_name}EventCallback {
// TODO add a special NotificationCallback interface and only allow those to be registered
- private final java.util.concurrent.ConcurrentMap<Class<? extends $base_package.$dto_package.JVppNotification>, $base_package.$callback_package.JVppNotificationCallback> registeredCallbacks =
+ private final java.util.concurrent.ConcurrentMap<Class<?>, $base_package.$callback_package.JVppCallback> registeredCallbacks =
new java.util.concurrent.ConcurrentHashMap<>();
- private static java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(${plugin_name}NotificationRegistryImpl.class.getName());
+ private static java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(${plugin_name}EventRegistryImpl.class.getName());
$register_callback_methods
$handler_methods
@@ -71,6 +71,13 @@ public final class ${plugin_name}NotificationRegistryImpl implements ${plugin_na
public void close() {
registeredCallbacks.clear();
}
+
+ @Override
+ public void onError(io.fd.vpp.jvpp.VppCallbackException ex) {
+ java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(${plugin_name}EventRegistryImpl.class.getName());
+ LOG.log(java.util.logging.Level.WARNING, String.format("Received onError exception: call=%s, context=%d, retval=%d%n", ex.getMethodName(),
+ ex.getCtxId(), ex.getErrorCode()), ex);
+ }
}
""")
@@ -87,12 +94,12 @@ register_callback_impl_template = Template("""
handler_impl_template = Template("""
@Override
public void on$notification(
- final $plugin_package.$dto_package.$notification notification) {
+ final $plugin_package.$dto_package.$notification_reply notification) {
if (LOG.isLoggable(java.util.logging.Level.FINE)) {
LOG.fine(String.format("Received $notification event message: %s", notification));
}
- final $base_package.$callback_package.JVppNotificationCallback jVppNotificationCallback = registeredCallbacks.get($plugin_package.$dto_package.$notification.class);
- if (null != jVppNotificationCallback) {
+ final $base_package.$callback_package.JVppCallback jVppCallback = registeredCallbacks.get($plugin_package.$dto_package.$notification.class);
+ if (null != jVppCallback) {
(($plugin_package.$callback_package.$callback) registeredCallbacks
.get($plugin_package.$dto_package.$notification.class))
.on$notification(notification);
@@ -104,14 +111,14 @@ notification_provider_template = Template("""
package $plugin_package.$notification_package;
/**
- * Provides ${plugin_name}NotificationRegistry.
+ * Provides ${plugin_name}EventRegistry.
* <br>The file was generated by notification_gen.py based on $inputfile
* <br>(python representation of api file generated by vppapigen).
*/
-public interface ${plugin_name}NotificationRegistryProvider extends $base_package.$notification_package.NotificationRegistryProvider {
+public interface ${plugin_name}EventRegistryProvider extends $base_package.$notification_package.EventRegistryProvider {
@Override
- public ${plugin_name}NotificationRegistry getNotificationRegistry();
+ public ${plugin_name}EventRegistry getEventRegistry();
}
""")
@@ -129,12 +136,14 @@ def generate_notification_registry(func_list, base_package, plugin_package, plug
handler_methods = []
for func in func_list:
- if not util.is_notification(func['name']):
+ if not util.is_reply(func['name']) and not util.is_notification(func['name']):
continue
camel_case_name_with_suffix = util.underscore_to_camelcase_upper(func['name'])
- notification_dto = util.add_notification_suffix(camel_case_name_with_suffix)
- callback_ifc = notification_dto + callback_gen.callback_suffix
+ if util.is_control_ping(camel_case_name_with_suffix):
+ continue
+ notification_dto = camel_case_name_with_suffix
+ callback_ifc = camel_case_name_with_suffix + callback_gen.callback_suffix
fully_qualified_callback_ifc = "{0}.{1}.{2}".format(plugin_package, callback_package, callback_ifc)
callbacks.append(fully_qualified_callback_ifc)
@@ -145,17 +154,18 @@ def generate_notification_registry(func_list, base_package, plugin_package, plug
register_callback_methods_impl.append(register_callback_impl_template.substitute(plugin_package=plugin_package,
callback_package=callback_package,
dto_package=dto_package,
- notification=notification_dto,
+ notification=camel_case_name_with_suffix,
callback=callback_ifc))
handler_methods.append(handler_impl_template.substitute(base_package=base_package,
plugin_package=plugin_package,
callback_package=callback_package,
dto_package=dto_package,
notification=notification_dto,
+ notification_reply=camel_case_name_with_suffix,
callback=callback_ifc))
- callback_file = open(os.path.join(notification_package, "%sNotificationRegistry.java" % plugin_name), 'w')
+ callback_file = open(os.path.join(notification_package, "%sEventRegistry.java" % plugin_name), 'w')
callback_file.write(notification_registry_template.substitute(inputfile=inputfile,
register_callback_methods="\n ".join(register_callback_methods),
base_package=base_package,
@@ -165,7 +175,7 @@ def generate_notification_registry(func_list, base_package, plugin_package, plug
callback_file.flush()
callback_file.close()
- callback_file = open(os.path.join(notification_package, "Global%sNotificationCallback.java" % plugin_name), 'w')
+ callback_file = open(os.path.join(notification_package, "Global%sEventCallback.java" % plugin_name), 'w')
global_notification_callback_callbacks = ""
if (callbacks):
@@ -179,7 +189,7 @@ def generate_notification_registry(func_list, base_package, plugin_package, plug
callback_file.flush()
callback_file.close()
- callback_file = open(os.path.join(notification_package, "%sNotificationRegistryImpl.java" % plugin_name), 'w')
+ callback_file = open(os.path.join(notification_package, "%sEventRegistryImpl.java" % plugin_name), 'w')
callback_file.write(notification_registry_impl_template.substitute(inputfile=inputfile,
callback_package=callback_package,
dto_package=dto_package,
@@ -192,7 +202,7 @@ def generate_notification_registry(func_list, base_package, plugin_package, plug
callback_file.flush()
callback_file.close()
- callback_file = open(os.path.join(notification_package, "%sNotificationRegistryProvider.java" % plugin_name), 'w')
+ callback_file = open(os.path.join(notification_package, "%sEventRegistryProvider.java" % plugin_name), 'w')
callback_file.write(notification_provider_template.substitute(inputfile=inputfile,
base_package=base_package,
plugin_package=plugin_package,