cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Grzegorz Oledzki (JIRA)" <>
Subject [jira] Created: (CXF-2778) No easy way to set JAXBDataBinding.contextProperties
Date Thu, 22 Apr 2010 09:39:50 GMT
No easy way to set JAXBDataBinding.contextProperties

                 Key: CXF-2778
             Project: CXF
          Issue Type: Improvement
    Affects Versions: 2.2.7
            Reporter: Grzegorz Oledzki

Usually you provide context classes to the {[JAXBDataBinding}}, but it's not the only information
you might want to provide. In our case we need to provide our own {{AnnotationReader}}, which
can be set by providing a special parameter to the {{JAXBDataBinding.contextParameters}},
properties.put(JAXBRIContext.ANNOTATION_READER, new OurAnnotationReader());

There seems to be no easy way to provide these context parameters to the binding if you still
wanted the default binding to be created by {{ReflectionServiceFactoryBean}}. Currently in
our code we had to do the following which seems to be overcomplicated:
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
Map<String, Object> serverProperties = new HashMap<String, Object>();
serverProperties.put("jaxb.additionalContextClasses", contextClassesArr);

// here comes the trick to set the context properties for JAXBBinding
JAXBDataBinding dataBinding = (JAXBDataBinding) serviceFactory.getDataBinding();
contextProperties.put(JAXBRIContext.ANNOTATION_READER, new OurAnnotationReader());
factory.getServiceFactory().setDataBinding(dataBinding);                      // without it
doesn't work, because of reset() method

Server ret = factory.create();

The trick is quite complicated. It wasn't so complicated when CXF 2.2.3 was used. Since 2.2.3
a new method {{reset()}} has been added to {{ReflectionServiceFactoryBean}}, which resets
(sets to null) a data binding which was already configured. In CXF 2.2.3 one could skip setting
properties on service factory (setting them on {{JaxWsServerFactoryBean}} was enough) and
skip {{setDataBinding(dataBinding)}}, because data binding was not created many times.

I believe there should be a simple programmatic interface for providing contextProperties
to be used whenever a JAXBDataBinding is created by {{ReflectionServiceFactoryBean}}.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message