You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Grzegorz Oledzki (JIRA)" <ji...@apache.org> on 2010/04/22 11:39:50 UTC
[jira] Created: (CXF-2778) No easy way to set
JAXBDataBinding.contextProperties
No easy way to set JAXBDataBinding.contextProperties
----------------------------------------------------
Key: CXF-2778
URL: https://issues.apache.org/jira/browse/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}}, 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.
-
You can reply to this email to add a comment to the issue online.