On Wed April 29 2009 3:16:11 pm jmdev wrote:
> I am looking to be able to add behaviors to some of my JAXB generated
> classes.  The JAXB documentation seems to suggest that I need to set a
> property on the (un)marshaller class
>
> (i.e.
>
> Unmarshaller u = context.createUnmarshaller();
> u.setProperty("com.sun.xml.bind.ObjectFactory",new ObjectFactoryEx());
> PersonEx p = (PersonEx)u.unmarshal(new StringReader("<person />"));
>
> )
>
> Is it possible to get access to the (un)marshaller classes in the course of
> CXF web service call so that I can set properties?  If so, could you
> provide a quick example of the method call(s)?
>
> Thanks!

I don't think there is access to the actual unmarshaller/marshallers.   
However, the JAXBDataBinding object itself has maps for properties that are 
then copied over into any marshaller/unmarshaller that it creates.    If you 
look on the page at:
http://cwiki.apache.org/CXF20DOC/jaxb.html
it shows some starting points for how to configure the JAXB databinding.   
Looking into the JAXBDataBinding class, there are fields for:
    private Map<String, Object> contextProperties;
    private Map<String, Object> marshallerProperties;
    private Map<String, Object> unmarshallerProperties;
    private Unmarshaller.Listener unmarshallerListener;
    private Marshaller.Listener marshallerListener;
    private ValidationEventHandler validationEventHandler;

so those would be some of the properties that you could configure to do 
whatever customization that you may need.


-- 
Daniel Kulp
[email protected]
http://www.dankulp.com/blog

Reply via email to