[libvirt] libvirt-java storage support and refactoring

Tóth István stoty at tvnet.hu
Sat Aug 2 15:42:36 UTC 2008


Hello!

This patch contains the following:

- The complete storage handling API
- Fixing memory leaks in the VirConnect JNI implementation

I've written the new classes using a new approach.

I've found that libvirt for the most part has a very perdicitble and 
repetitive API (great design!), and  as a result I've found myself  
copying the same code over and over again.
I've decided to make generic JNI functions, that can handle multiple 
libvirt functions  with function pointers.
The generic functions are in generic.c and they are used extensively in 
the new Storage JNI implementation.

I'd like to have your input on this architecture, my current plan is to 
refactor all trivial JNI functions to use these generics, unless there 
are objections.

The positive aspects of the new architecture:

- No code duplication, one generic function fix affects all similar 
functions
- Less code

The negative aspects:

- Ugly syntax (but JNI is ugly enough already)
- Easier to make errors in JNI code due to function type casts.

I think that the benefits outweigh the negatives, esepecialy when we 
start cleaning up memory allocation, 64/32 bit cleannes stuff, 
threading, it will have to be done in one function, instead of 3 or 30 
cut'n'pasted ones, scattered in 5 files.

best regards
István

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: storage+refactor.patch
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20080802/33908263/attachment-0001.ksh>


More information about the libvir-list mailing list