#!/usr/bin/env python # # Copyright (c) 2016 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os, util from string import Template jvpp_ifc_template = Template(""" package $plugin_package; /** *
Java representation of plugin's api file.
*
It was generated by jvpp_impl_gen.py based on $inputfile
*
(python representation of api file generated by vppapigen).
*/
public interface JVpp${plugin_name} extends $base_package.JVpp {
/**
* Generic dispatch method for sending requests to VPP
*
* @throws io.fd.vpp.jvpp.VppInvocationException if send request had failed
*/
int send($base_package.$dto_package.JVppRequest request) throws io.fd.vpp.jvpp.VppInvocationException;
$methods
}
""")
jvpp_impl_template = Template("""
package $plugin_package;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Set;
import java.util.logging.Logger;
import $base_package.callback.JVppCallback;
import $base_package.VppConnection;
import $base_package.JVppRegistry;
/**
*
Default implementation of JVpp interface.
*
It was generated by jvpp_impl_gen.py based on $inputfile
*
(python representation of api file generated by vppapigen).
*/
public final class JVpp${plugin_name}Impl implements $plugin_package.JVpp${plugin_name} {
private final static Logger LOG = Logger.getLogger(JVpp${plugin_name}Impl.class.getName());
private static final String LIBNAME = "libjvpp_${plugin_name_underscore}.so.0.0.0";
// FIXME using NativeLibraryLoader makes load fail could not find (WantInterfaceEventsReply).
static {
try {
loadLibrary();
} catch (Exception e) {
LOG.severe("Can't find jvpp jni library: " + LIBNAME);
throw new ExceptionInInitializerError(e);
}
}
private static void loadStream(final InputStream is) throws IOException {
final Set