[ 
https://issues.apache.org/jira/browse/CXF-2778?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Kulp resolved CXF-2778.
------------------------------

       Resolution: Won't Fix
    Fix Version/s: Invalid

 This improvement request has been open for over a year and no-one has stepped 
up to implement it. As such, it does not seems to be a priority for the 
existing CXF community. If, in the future, someone would like to tackle this, 
feel free to open is and attach a patch.


> No easy way to set JAXBDataBinding.contextProperties
> ----------------------------------------------------
>
>                 Key: CXF-2778
>                 URL: https://issues.apache.org/jira/browse/CXF-2778
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAXB Databinding
>    Affects Versions: 2.2.7
>            Reporter: Grzegorz Oledzki
>             Fix For: Invalid
>
>
> 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}}, e.g.:
> {code}
> properties.put(JAXBRIContext.ANNOTATION_READER, new OurAnnotationReader());
> dataBinding.setContextProperties(properties);
> {code}
> 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:
> {code}
> JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
> factory.setServiceClass(serviceInterface);
> factory.setServiceBean(serviceBean);
> factory.setAddress(url);
> Map<String, Object> serverProperties = new HashMap<String, Object>();
> serverProperties.put("jaxb.additionalContextClasses", contextClassesArr);
> factory.setProperties(serverProperties);
> // here comes the trick to set the context properties for JAXBBinding
> factory.getServiceFactory().setProperties(serverProperties);
> JAXBDataBinding dataBinding = (JAXBDataBinding) 
> serviceFactory.getDataBinding();
> contextProperties.put(JAXBRIContext.ANNOTATION_READER, new 
> OurAnnotationReader());
> dataBinding.setContextProperties(contextProperties);
> factory.getServiceFactory().setDataBinding(dataBinding);                      
> // without it doesn't work, because of reset() method
> Server ret = factory.create();
> {code}
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to