Hi Jon,

Just to clarify, the normal way of using JiBX would be to have a single
binding which includes <mapping> definitions for all the classes you're
going to be marshalling/unmarshalling as root objects.

If you really need to use a separate binding for each class you can make
that work, too, but it'll be more work to keep track of the various
bindings (which seemed to be what you were asking in your original
email). Is there a reason you want to do it this way?

  - Dennis

Dennis M. Sosnoski
SOA 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



Varghese C V wrote:
> What i meant was to keep the binding factory as an instance variable in 
> the xml handler, that is looked up during the initialization of the xml 
> handler.
> Does this clear things?
>
> Jon Little wrote:
>   
>> Hi
>>
>> Thanks for your reply but I must admit the I do not comprehend what 
>> you mean.
>>
>> Jon
>>
>> Varghese C V wrote:
>>     
>>> The BindingFactory need not be looked up every time.
>>> During the Xml Handler initialization look the binding factory once 
>>> with a class that is part of the binding.
>>> Looking up a binding factory from any class that is part of the 
>>> binding definition would return the same binding factory.
>>> The binding factory is threadsafe.
>>>
>>> Personally, I use spring to inject a binding factory lookup class to 
>>> a xml handler.
>>>
>>> Hope this helps
>>> Varghese C V
>>>
>>> Jon Little wrote:
>>>       
>>>> Hi
>>>>
>>>> I'm new to jibx but i love the concept.
>>>>
>>>> I'm planning on using jibx for the xml translator on struts.
>>>>
>>>> Each class will have a binding,
>>>>
>>>> The xml handler has two pre-defined methods - fromObject and toObject.
>>>>
>>>> The fromObject method is pretty straightforward (and I hope the 
>>>> toObject will be too):
>>>> public String fromObject(Object obj, String resultCode, Writer out)
>>>>   throws IOException
>>>>   {
>>>>     if (obj != null)
>>>>     {
>>>>       try
>>>>       {
>>>>         IBindingFactory bf = 
>>>> BindingDirectory.getFactory(obj.getClass());
>>>>         IMarshallingContext mc = bf.createMarshallingContext();
>>>>         mc.marshalDocument(obj, null, null, out);
>>>>       }
>>>>       catch (JiBXException e)
>>>>       {
>>>>         // TODO Auto-generated catch block
>>>>         e.printStackTrace();
>>>>       }
>>>>     }
>>>>     return null;
>>>>   }
>>>>
>>>> The toObject method has the following signature:
>>>>
>>>> public void toObject(Reader in, Object target)
>>>>
>>>> My question is given that each class will have it's own binding and 
>>>> I don't know the class of the object that is about to be 
>>>> unmarshalled how do I call BindingDirectory.getFactory to get the 
>>>> correct binding?
>>>>
>>>> Thinking you in advance.
>>>>
>>>> Jon
>>>>
>>>> ------------------------------------------------------------------------- 
>>>>
>>>> Check out the new SourceForge.net Marketplace.
>>>> It's the best place to buy or sell services for
>>>> just about anything Open Source.
>>>> http://sourceforge.net/services/buy/index.php
>>>> _______________________________________________
>>>> jibx-users mailing list
>>>> jibx-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/jibx-users
>>>>
>>>>   
>>>>         
>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>   

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to