* <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
* <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 {
}
""")
* <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
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);
+ }
}
""")
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);
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();
}
""")
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)
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,
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):
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,
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,