Hi Darin,

I'd say this is definitely a bug. I've fixed a couple of problems in 
this area, but the whole area of handling pre-get/post-get/post-set 
methods is not nearly as clean as I'd like. You might try a recent 
version of the 1.2.2 code from 
http://www.jibx.org/jibx_1_2_2-SNAPSHOT.zip to see if the particular bug 
you're encountering has been fixed.

Part of the problem is that object creation and reuse is just not 
well-structured in the current code, and when there are multiple layers 
of class hierarchies involved the code loses track of the methods that 
should be applied to the "current" type of the object. I'm once again 
trying to push forward with the JiBX 2.0 code (as soon as 1.2.2 is 
out!). As part of that I'm revising the binding structure and clarifying 
exactly how these options will work, including for cases of multiple 
levels of mapping.

  - Dennis

Dennis M. Sosnoski
XML and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Darin Clark wrote:
> I'm seeing some rather strange behavior in JiBX with regards to abstract
> mappings, post-set and its ilk, and the '<structure map-as="foo"/>'
> construct.  The oddness isn't described in the docs, so I figure I'll check
> on the list to see if it's a bug or just a surprise.  In short, post-set is
> sometimes called, and sometimes not..  An example:
>
> Class: 
>
> public class TestClass
> {
>     public String one;
>     public String two;
>     public String three;
>     
>     public void postSet()
>     {
>         three="three";
>     }
>     
>     public static void main(String args[]) throws Exception
>     {
>         String testString = "<TestClass></TestClass>";
>         IBindingFactory factory = 
> BindingDirectory.getFactory(TestClass.class);
>         IUnmarshallingContext c = factory.createUnmarshallingContext();
>         TestClass tc = (TestClass) c.unmarshalDocument(new 
> StringReader(testString));
>         System.out.println(tc.three);
>     }
> }
>
> Binding:
>
> <binding >
>     <mapping class="TestClass" abstract="true" type-name="level-one" >
>         <value name="one" field="one" usage="optional"/>
>     </mapping>
>     
>     <mapping class="TestClass" abstract="false" post-set="postSet" 
> name="TestClass">
>         <structure map-as="level-one"/>
>         <value name="two" field="two" usage="optional"/>
>     </mapping>
> </binding>
>
> In this case, the post-set method is called - the output will be "three".
>
> That's good, I suppose... but...  let's mix it up a little.
>
> Remove the 'two' value element from the second mapping and run the example
> again.  Result?  The postSet method is _not_ called, and 'three' remains
> null.
>
> Of course, we can always just move the post-set attribute up to the abstract
> mapping, and it gets called, once again.  Not that this helps, if my entire
> reason for creating a concrete base mapping is to use a post-set that wouldn't
> be used against the abstract class.  Joy?
>
> So.. it appears that the concrete mapping only calls its own post-set if
> there's something other than a 'map-as' present for mapping?
>
> I admit I'm not entirely sure just what's going on here.  I can recognize
> it, and I can see a(n ugly) way to work around it, but...Is this a bug, or
> just something I should know to watch for?
>
>   

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to