aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp/gen
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
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')
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/callback_gen.py15
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py49
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py28
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py35
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/jvpp_future_facade_gen.py16
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/jvpp_impl_gen.py2
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/notification_gen.py48
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/util.py6
8 files changed, 112 insertions, 87 deletions
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/callback_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/callback_gen.py
index b3024b9c2ba..f0aee47b0f5 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/callback_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/callback_gen.py
@@ -68,16 +68,9 @@ def generate_callbacks(func_list, base_package, plugin_package, plugin_name, cal
if not util.is_reply(camel_case_name_with_suffix) and not util.is_notification(func['name']):
continue
- if util.is_reply(camel_case_name_with_suffix):
- camel_case_name = util.remove_reply_suffix(camel_case_name_with_suffix)
- callback_type = "JVppCallback"
- else:
- camel_case_name_with_suffix = util.add_notification_suffix(camel_case_name_with_suffix)
- camel_case_name = camel_case_name_with_suffix
- callback_type = "JVppNotificationCallback"
-
- callbacks.append("{0}.{1}.{2}".format(plugin_package, callback_package, camel_case_name + callback_suffix))
- callback_path = os.path.join(callback_package, camel_case_name + callback_suffix + ".java")
+ callback_type = "JVppCallback"
+ callbacks.append("{0}.{1}.{2}".format(plugin_package, callback_package, camel_case_name_with_suffix + callback_suffix))
+ callback_path = os.path.join(callback_package, camel_case_name_with_suffix + callback_suffix + ".java")
callback_file = open(callback_path, 'w')
reply_type = "%s.%s.%s" % (plugin_package, dto_package, camel_case_name_with_suffix)
@@ -85,7 +78,7 @@ def generate_callbacks(func_list, base_package, plugin_package, plugin_name, cal
callback_file.write(
callback_template.substitute(inputfile=inputfile,
docs=util.api_message_to_javadoc(func),
- cls_name=camel_case_name + callback_suffix,
+ cls_name=camel_case_name_with_suffix + callback_suffix,
callback_method=method,
base_package=base_package,
plugin_package=plugin_package,
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
index e831557c15a..e94bbc5cb28 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/dto_gen.py
@@ -35,6 +35,23 @@ $methods
}
""")
+dto_template_typeless = Template("""
+package $plugin_package.$dto_package;
+
+/**
+ * <p>This class represents $description.
+ * <br>It was generated by dto_gen.py based on $inputfile preparsed data:
+ * <pre>
+$docs
+ * </pre>
+ */
+public final class $cls_name {
+
+$fields
+$methods
+}
+""")
+
field_template = Template(""" public $type $name;\n""")
send_template = Template(""" @Override
@@ -93,9 +110,7 @@ def generate_dtos(func_list, base_package, plugin_package, plugin_name, dto_pack
# for structures that are also used as notifications, generate dedicated notification DTO
if util.is_notification(func["name"]):
- base_type = "JVppNotification"
description = "notification DTO"
- camel_case_dto_name = util.add_notification_suffix(camel_case_dto_name)
dto_path = os.path.join(dto_package, camel_case_dto_name + ".java")
methods = generate_dto_base_methods(camel_case_dto_name, func)
write_dto_file(base_package, plugin_package, base_type, camel_case_dto_name, description, dto_package,
@@ -229,16 +244,26 @@ def generate_dto_hash(func):
def write_dto_file(base_package, plugin_package, base_type, camel_case_dto_name, description, dto_package, dto_path,
fields, func, inputfile, methods):
dto_file = open(dto_path, 'w')
- dto_file.write(dto_template.substitute(inputfile=inputfile,
- description=description,
- docs=util.api_message_to_javadoc(func),
- cls_name=camel_case_dto_name,
- fields=fields,
- methods=methods,
- base_package=base_package,
- plugin_package=plugin_package,
- base_type=base_type,
- dto_package=dto_package))
+ if base_type != "":
+ dto_file.write(dto_template.substitute(inputfile=inputfile,
+ description=description,
+ docs=util.api_message_to_javadoc(func),
+ cls_name=camel_case_dto_name,
+ fields=fields,
+ methods=methods,
+ base_package=base_package,
+ plugin_package=plugin_package,
+ base_type=base_type,
+ dto_package=dto_package))
+ else:
+ dto_file.write(dto_template_typeless.substitute(inputfile=inputfile,
+ description=description,
+ docs=util.api_message_to_javadoc(func),
+ cls_name=camel_case_dto_name,
+ fields=fields,
+ methods=methods,
+ plugin_package=plugin_package,
+ dto_package=dto_package))
dto_file.flush()
dto_file.close()
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
index 4fe7ab53fb9..e2f6aa4d505 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_c_gen.py
@@ -70,23 +70,13 @@ def generate_class_cache(func_list, plugin_name):
if util.is_ignored(c_name) or util.is_control_ping(class_name):
continue
- if util.is_reply(class_name):
- class_references.append(class_reference_template.substitute(
- ref_name=ref_name))
- find_class_invocations.append(find_class_invocation_template.substitute(
- plugin_name=plugin_name,
- ref_name=ref_name,
- class_name=class_name))
- delete_class_invocations.append(delete_class_invocation_template.substitute(ref_name=ref_name))
- elif util.is_notification(c_name):
- class_references.append(class_reference_template.substitute(
- ref_name=util.add_notification_suffix(ref_name)))
- find_class_invocations.append(find_class_invocation_template.substitute(
- plugin_name=plugin_name,
- ref_name=util.add_notification_suffix(ref_name),
- class_name=util.add_notification_suffix(class_name)))
- delete_class_invocations.append(delete_class_invocation_template.substitute(
- ref_name=util.add_notification_suffix(ref_name)))
+ class_references.append(class_reference_template.substitute(
+ ref_name=ref_name))
+ find_class_invocations.append(find_class_invocation_template.substitute(
+ plugin_name=plugin_name,
+ ref_name=ref_name,
+ class_name=class_name))
+ delete_class_invocations.append(delete_class_invocation_template.substitute(ref_name=ref_name))
# add exception class to class cache
ref_name = 'callbackException'
@@ -270,10 +260,6 @@ def generate_msg_handlers(func_list, plugin_name, inputfile):
if not util.is_reply(dto_name) and not util.is_notification(handler_name):
continue
- if util.is_notification(handler_name):
- dto_name = util.add_notification_suffix(dto_name)
- ref_name = util.add_notification_suffix(ref_name)
-
dto_setters = ''
err_handler = ''
# dto setters
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py
index 3cfc633a55c..53e9f49e029 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py
@@ -27,7 +27,7 @@ package $plugin_package.$callback_facade_package;
* <br>It was generated by jvpp_callback_facade_gen.py based on $inputfile
* <br>(python representation of api file generated by vppapigen).
*/
-public interface CallbackJVpp${plugin_name} extends $base_package.$notification_package.NotificationRegistryProvider, java.lang.AutoCloseable {
+public interface CallbackJVpp${plugin_name} extends $base_package.$notification_package.EventRegistryProvider, java.lang.AutoCloseable {
// TODO add send
@@ -47,7 +47,7 @@ public final class CallbackJVpp${plugin_name}Facade implements CallbackJVpp${plu
private final $plugin_package.JVpp${plugin_name} jvpp;
private final java.util.Map<Integer, $base_package.$callback_package.JVppCallback> callbacks;
- private final $plugin_package.$notification_package.${plugin_name}NotificationRegistryImpl notificationRegistry = new $plugin_package.$notification_package.${plugin_name}NotificationRegistryImpl();
+ private final $plugin_package.$notification_package.${plugin_name}EventRegistryImpl eventRegistry = new $plugin_package.$notification_package.${plugin_name}EventRegistryImpl();
/**
* <p>Create CallbackJVpp${plugin_name}Facade object for provided JVpp instance.
* Constructor internally creates CallbackJVppFacadeCallback class for processing callbacks
@@ -61,12 +61,12 @@ public final class CallbackJVpp${plugin_name}Facade implements CallbackJVpp${plu
this.jvpp = java.util.Objects.requireNonNull(jvpp,"jvpp is null");
this.callbacks = new java.util.HashMap<>();
java.util.Objects.requireNonNull(registry, "JVppRegistry should not be null");
- registry.register(jvpp, new CallbackJVpp${plugin_name}FacadeCallback(this.callbacks, notificationRegistry));
+ registry.register(jvpp, new CallbackJVpp${plugin_name}FacadeCallback(this.callbacks, eventRegistry));
}
@Override
- public $plugin_package.$notification_package.${plugin_name}NotificationRegistry getNotificationRegistry() {
- return notificationRegistry;
+ public $plugin_package.$notification_package.${plugin_name}EventRegistry getEventRegistry() {
+ return eventRegistry;
}
@Override
@@ -121,7 +121,12 @@ def generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_pack
continue
# Strip suffix for dump calls
- callback_type = get_request_name(camel_case_name_upper, func['name']) + callback_gen.callback_suffix
+ callback_type = get_request_name(camel_case_name_upper, func['name'])
+ if (util.is_dump(camel_case_name_upper)):
+ callback_type += "Details"
+ elif (not util.is_notification(camel_case_name_upper)):
+ callback_type += "Reply"
+ callback_type += callback_gen.callback_suffix
if len(func['args']) == 0:
methods.append(no_arg_method_template.substitute(name=camel_case_name,
@@ -193,13 +198,13 @@ package $plugin_package.$callback_facade_package;
public final class CallbackJVpp${plugin_name}FacadeCallback implements $plugin_package.$callback_package.JVpp${plugin_name}GlobalCallback {
private final java.util.Map<Integer, $base_package.$callback_package.JVppCallback> requests;
- private final $plugin_package.$notification_package.Global${plugin_name}NotificationCallback notificationCallback;
+ private final $plugin_package.$notification_package.Global${plugin_name}EventCallback eventCallback;
private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(CallbackJVpp${plugin_name}FacadeCallback.class.getName());
public CallbackJVpp${plugin_name}FacadeCallback(final java.util.Map<Integer, $base_package.$callback_package.JVppCallback> requestMap,
- final $plugin_package.$notification_package.Global${plugin_name}NotificationCallback notificationCallback) {
+ final $plugin_package.$notification_package.Global${plugin_name}EventCallback eventCallback) {
this.requests = requestMap;
- this.notificationCallback = notificationCallback;
+ this.eventCallback = eventCallback;
}
@Override
@@ -266,7 +271,7 @@ jvpp_facade_callback_notification_method_template = Template("""
if (LOG.isLoggable(java.util.logging.Level.FINE)) {
LOG.fine(String.format("Received $callback_dto event message: %s", notification));
}
- notificationCallback.on$callback_dto(notification);
+ eventCallback.on$callback_dto(notification);
}
""")
@@ -281,19 +286,19 @@ def generate_callback(func_list, base_package, plugin_package, plugin_name, dto_
continue
if util.is_reply(camel_case_name_with_suffix):
+ request_method = camel_case_name_with_suffix
callbacks.append(jvpp_facade_callback_method_template.substitute(plugin_package=plugin_package,
dto_package=dto_package,
callback_package=callback_package,
- callback=util.remove_reply_suffix(camel_case_name_with_suffix) + callback_gen.callback_suffix,
- callback_dto=camel_case_name_with_suffix))
+ callback=camel_case_name_with_suffix + callback_gen.callback_suffix,
+ callback_dto=request_method))
if util.is_notification(func["name"]):
- with_notification_suffix = util.add_notification_suffix(camel_case_name_with_suffix)
callbacks.append(jvpp_facade_callback_notification_method_template.substitute(plugin_package=plugin_package,
dto_package=dto_package,
callback_package=callback_package,
- callback=with_notification_suffix + callback_gen.callback_suffix,
- callback_dto=with_notification_suffix))
+ callback=camel_case_name_with_suffix + callback_gen.callback_suffix,
+ callback_dto=camel_case_name_with_suffix))
jvpp_file = open(os.path.join(callback_facade_package, "CallbackJVpp%sFacadeCallback.java" % plugin_name), 'w')
jvpp_file.write(jvpp_facade_callback_template.substitute(inputfile=inputfile,
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_future_facade_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_future_facade_gen.py
index b2f8d376aca..a31287b3333 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_future_facade_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_future_facade_gen.py
@@ -30,12 +30,12 @@ package $plugin_package.$future_package;
public final class FutureJVpp${plugin_name}FacadeCallback implements $plugin_package.$callback_package.JVpp${plugin_name}GlobalCallback {
private final java.util.Map<java.lang.Integer, java.util.concurrent.CompletableFuture<? extends $base_package.$dto_package.JVppReply<?>>> requests;
- private final $plugin_package.$notification_package.Global${plugin_name}NotificationCallback notificationCallback;
+ private final $plugin_package.$notification_package.Global${plugin_name}EventCallback notificationCallback;
private static final java.util.logging.Logger LOG = java.util.logging.Logger.getLogger(FutureJVpp${plugin_name}FacadeCallback.class.getName());
public FutureJVpp${plugin_name}FacadeCallback(
final java.util.Map<java.lang.Integer, java.util.concurrent.CompletableFuture<? extends $base_package.$dto_package.JVppReply<?>>> requestMap,
- final $plugin_package.$notification_package.Global${plugin_name}NotificationCallback notificationCallback) {
+ final $plugin_package.$notification_package.Global${plugin_name}EventCallback notificationCallback) {
this.requests = requestMap;
this.notificationCallback = notificationCallback;
}
@@ -213,7 +213,7 @@ def generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_pack
if util.is_notification(func["name"]):
callbacks.append(jvpp_facade_callback_notification_method_template.substitute(plugin_package=plugin_package,
dto_package=dto_package,
- callback_dto=util.add_notification_suffix(camel_case_name_with_suffix)))
+ callback_dto=camel_case_name_with_suffix))
jvpp_file = open(os.path.join(future_facade_package, "FutureJVpp%sFacadeCallback.java" % plugin_name), 'w')
jvpp_file.write(jvpp_facade_callback_template.substitute(inputfile=inputfile,
@@ -264,7 +264,7 @@ public interface FutureJVpp${plugin_name} extends $base_package.$future_package.
$methods
@Override
- public $plugin_package.$notification_package.${plugin_name}NotificationRegistry getNotificationRegistry();
+ public $plugin_package.$notification_package.${plugin_name}EventRegistry getEventRegistry();
}
''')
@@ -284,7 +284,7 @@ package $plugin_package.$future_package;
*/
public class FutureJVpp${plugin_name}Facade extends $base_package.$future_package.AbstractFutureJVppInvoker implements FutureJVpp${plugin_name} {
- private final $plugin_package.$notification_package.${plugin_name}NotificationRegistryImpl notificationRegistry = new $plugin_package.$notification_package.${plugin_name}NotificationRegistryImpl();
+ private final $plugin_package.$notification_package.${plugin_name}EventRegistryImpl eventRegistry = new $plugin_package.$notification_package.${plugin_name}EventRegistryImpl();
/**
* <p>Create FutureJVpp${plugin_name}Facade object for provided JVpp instance.
@@ -298,12 +298,12 @@ public class FutureJVpp${plugin_name}Facade extends $base_package.$future_packag
public FutureJVpp${plugin_name}Facade(final $base_package.JVppRegistry registry, final $base_package.JVpp jvpp) throws java.io.IOException {
super(jvpp, registry, new java.util.HashMap<>());
java.util.Objects.requireNonNull(registry, "JVppRegistry should not be null");
- registry.register(jvpp, new FutureJVpp${plugin_name}FacadeCallback(getRequests(), notificationRegistry));
+ registry.register(jvpp, new FutureJVpp${plugin_name}FacadeCallback(getRequests(), eventRegistry));
}
@Override
- public $plugin_package.$notification_package.${plugin_name}NotificationRegistry getNotificationRegistry() {
- return notificationRegistry;
+ public $plugin_package.$notification_package.${plugin_name}EventRegistry getEventRegistry() {
+ return eventRegistry;
}
$methods
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_impl_gen.py b/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_impl_gen.py
index 7af70be0df9..f802ee27014 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_impl_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_impl_gen.py
@@ -175,7 +175,7 @@ def generate_jvpp(func_list, base_package, plugin_package, plugin_name_underscor
for func in func_list:
# Skip structures that are used only as notifications
- if util.is_just_notification(func['name']) or util.is_ignored(func['name']):
+ if util.is_ignored(func['name']):
continue
camel_case_name = util.underscore_to_camelcase(func['name'])
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,
diff --git a/src/vpp-api/java/jvpp/gen/jvppgen/util.py b/src/vpp-api/java/jvpp/gen/jvppgen/util.py
index 42394419737..48645246596 100644
--- a/src/vpp-api/java/jvpp/gen/jvppgen/util.py
+++ b/src/vpp-api/java/jvpp/gen/jvppgen/util.py
@@ -41,6 +41,7 @@ reply_suffixes = ("reply", "details", "l2fibtableentry")
def is_reply(name):
return name.lower().endswith(reply_suffixes)
+details_suffix = "details"
def is_details(name):
return name.lower().endswith(reply_suffixes[1]) or name.lower().endswith(reply_suffixes[2])
@@ -186,6 +187,8 @@ def remove_reply_suffix(camel_case_name_with_suffix):
def remove_suffix(camel_case_name_with_suffix, suffix):
+ if not suffix:
+ return camel_case_name_with_suffix
suffix_length = len(suffix)
return camel_case_name_with_suffix[:-suffix_length] if suffix_length != 0 else camel_case_name_with_suffix
@@ -210,3 +213,6 @@ def add_notification_suffix(camel_case_dto_name):
def is_array(java_type_as_string):
return java_type_as_string.endswith("[]")
+
+def is_want(name):
+ return name.startswith("want_") \ No newline at end of file