aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_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/jvpp_callback_facade_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/jvpp_callback_facade_gen.py')
-rw-r--r--src/vpp-api/java/jvpp/gen/jvppgen/jvpp_callback_facade_gen.py35
1 files changed, 20 insertions, 15 deletions
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,