I am currently evaluating JiBX for the use of replacing our current 
serialization to a blob.  We have about 75 classes that form a 
complicated graph (with numerous circular references, and classes 
inheriting from other classes, some of which are abstract) and are 
currently using Java's default serialization to write out the entire 
graph to a blob, which can then be read back in at any later point in 
time.  The issue we are having is that Java's serialization writes out 
way too much meta-data, and so any small change we make to the blob 
makes us lose any existing data.  As we're in alpha stage right now, 
this is fine, but obviously once we start deploying to actual users we 
will want to be able to guarantee no data loss between patches, etc.

My question has a few parts:
1) I have attempted to use jibx-genbinding on a simple example with two 
classes:  AbstractNode and PrintNode.  AbstractNode contains a parent 
pointer to another AbstractNode and a collection of children 
AbstractNodes.  PrintNode inherits from AbstractNode and contains a 
String member variable that is printed out when a function is called.  I 
then form a tree of AbstractNodes and attempt to marshal the top level 
PrintNode of the tree.
First of all, jibx-genbinding couldn't seem to create the bindings 
properly.  It crashed with the following error:

C:\Documents and Settings\dclamage\workspace\TestJiBX>java -jar 
d:\jibx\lib\jibx
-genbinding.jar com.app2you.TestJiBX.classes.AbstractNode 
com.app2you.TestJiBX.c
lasses.PrintNode
Running binding generator version 0.2
Warning: mapping abstract class 
com.app2you.TestJiBX.classes.AbstractNode; make
sure actual subclasses are mapped as extending this abstract mapping
Warning: field children requires mapped implementation of item classes
org.jibx.runtime.JiBXException: Unknown namespace URI null
       at org.jibx.runtime.QName.serialize(Unknown Source)
       at 
org.jibx.binding.model.StructureElement.getQualifiedMapAs(StructureEl
ement.java:225)
-- cut the rest of stack trace --

So, I hand-crafted the binding as follows:

<?xml version="1.0" encoding="UTF-8"?>
<binding forwards="false" value-style="attribute">
 <mapping abstract="true" 
class="com.app2you.TestJiBX.classes.AbstractNode" 
type-name="abstract-node">
   <structure field="parent" usage="optional"/>
   <collection field="children" usage="optional" 
item-type="com.app2you.TestJiBX.classes.AbstractNode"/>
 </mapping>
 <mapping name="base-abstract-node" 
class="com.app2you.TestJiBX.classes.AbstractNode">
   <structure map-as="abstract-node"/>
 </mapping>
 <mapping class="TestJiBX.classes.PrintNode" name="print-node" 
extends="com.app2you.TestJiBX.classes.AbstractNode">
   <structure map-as="abstract-node" />
   <value style="element" name="to-print" field="toPrint" 
usage="optional"/>
 </mapping>
</binding>

When I attempt to write out the tree, I get a stack overflow.  What am I 
doing wrong in this case?

2) Is there any way to get the auto-bind generator to work even with the 
above case?  If it didn't work for that, it certainly will not work for 
the 75 class blob.  The thought of hand-crafting the bindings for all of 
these classes is not a happy one.

3) If I do get these bindings to automatically generate, what would be 
the best way of migrating between versions of class files, without loss 
of data.  One possibility is through a script that changes the XML data 
- is this viable?

Thanks for your time,
-David Clamage


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to