= JVpp JVpp is JNI based Java API for VPP. == Features It is: * Asynchronous * Fully generated * Lightweight == Architecture === Plugin support /-------------\ /--------------\ /---------------\ | JvppPlugin1 +<-------+ JVppRegistry +--------->+ VppConnection | \-------------/ inits \--+-----------/ uses \---------------/ | /-------------\ | | JvppPlugin2 +<----------+ inits \-------------/ | | ... | | /----------\ | | JVppCore +<-------------+ \----------/ VppRegistry opens connection to vpp (VppConnection) and manages jvpp plugins. Each plugin needs to be registered in the VppRegistry. Registration involves plugin initialization (providing JNI implementation with JVppCallback reference, vpp client identifier and vpp shared memory queue address). API user sends message by calling a method of appropriate plugin interface. The call is delegated to JNI implementation provided by the particular plugin. When JNI code receives reply, it invokes callback method of JVppCallback that corresponds to the received message reply. === JVppCore as an example of JVpp plugin architecture JVpp Java /--------------\ /----------\ /------------\ /------\ | JVppRegistry | | JVppCore | | Callbacks | | DTOs | \----+---------/ \----+-----/ \------+-----/ \------/ ^ ^ ^ | implements | implements | implements /----+--------------\ /---+----------\ /-----+---------\ | JVppRegistryImpl* +-------->+ JVppCoreImpl | | JVppCallback | \-------+-----------/ inits \---+----------/ \-------+-------/ | | ^ | | uses | calls back | | | ----------|--------------------------|-----------------------|--------------------- | | | C JNI | +-------------------+ | /-----------------\ v | | +-->+ jvpp_core_gen.h | /--------+--------\ | | | \-----------------/ | jpp_registry.c* +---+ /--------+----+----\ | | | \-----------------/ | | << shared lib >> | /-+--+---+------\ + ->+ jvpp_common* <--------+ jvpp_core.c* | uses \------------------/ uses \---------------/ * Components marked with an asterisk contain manually crafted code, which in addition to generated classes form jvpp. Exception applies to Callbacks and DTOs, since there are manually crafted marker interfaces in callback and dto package (dto/JVppRequest, dto/JVppReply, dto/JVppDump, dto/JVppReplyDump, callback/JVppCallback) Note: jvpp_core.c calls back the JVppCallback instance with every response. An instance of the JVppCallback is provided to jvpp_core.c by JVppRegistryImpl on JVppCoreImpl initialization. Part of the JVpp is also Future facade. It is asynchronous API returning Future objects on top of low level JVpp. It wraps dump reply messages in one DTO using control_ping message (provided by JVppRegistry). Future facade /----------------\ /---------------\ | FutureJVppCore | +-->+ JVppRegistry* | \-----+----------/ | \---------------/ ^ | | implements | uses | | /--------+-------------\ | /------------------------------\ | FutureJVppCoreFacade +---+--->+ FutureJVppCoreFacadeCallback | \---------+------------/ uses \-------+----------------------/ | | ---------------|-----------------------------|------------------------------- | uses | implements JVpp Java | | | | /----------\ | | | JVppCore +<-+ | \----+-----/ | ^ | | implements v /----+---------\ /--------+---------------\ | JVppCoreImpl | | JVppCoreGlobalCallback | \--------------/ \------------------------/ Another useful utility of the JVpp is Callback facade. It is asynchronous API capable of calling specific callback instance (provided when performing a call) per call. Callback facade /------------------\ /---------------\ | CallbackJVppCore | +-->+ JVppRegistry* | \-----+------------/ | \---------------/ ^ | | implements | uses | | /--------+---------------\ | /--------------------------\ | CallbackJVppCoreFacade +---+--->+ CallbackJVppCoreCallback | \---------+--------------/ uses \-----+--------------------/ | | ---------------|-----------------------------|------------------------------- | uses | implements JVpp Java | | | | /----------\ | | | JVppCore +<-+ | \----+-----/ | ^ | | implements