[
https://issues.apache.org/jira/browse/CXF-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13577537#comment-13577537
]
Sergey Beryozkin commented on CXF-4799:
---------------------------------------
Hi - yes, I've realized that WebClient path (read or write) where it will
happen as it does not uses resource classes to get initialized.
What I've done is I've updated AbstractJaxbProvider to make it simpler for
subclasses to customize the process, and specifically, when WebClient is used.
FYI, this is not the issue with the proxy-based client API or server endpoints,
though you do need to set "singleJaxbContext" property on the provider.
IMHO, replacing the context with the new one can be problematic in the general
case (for performance reasons, and also given we have no guarantee the
parameterized type will end up being added successfully to the context), so
given that it is not a mainstream case (where you have an object of type such
as MyClass<Var> passed around and only WebClient path is affected, IMHO
simplifying the customization is all we should do;
WebClient still has no way to submit Type representing MyClass<Var>, etc - I'll
think of adding a new method for this, but a new JIRA will be created for it
> Parameterized Classes should be automatically added to JAXBContext
> ------------------------------------------------------------------
>
> Key: CXF-4799
> URL: https://issues.apache.org/jira/browse/CXF-4799
> Project: CXF
> Issue Type: Improvement
> Components: JAX-RS
> Affects Versions: 2.7.2
> Reporter: Sambit Dikshit
>
> We are using a payload type which is a parameterized generic. For example,
> ServiceResponse<T> {
> T payload;
> public T getPayload() {
> return T
> }
> public void setPayload(T t){
> this.payload = t;
> }
> We are using this as a payload wrapper for JAXRS services. The payload can
> be any type at runtime. Unless we set the extraClass, the JAXBContext created
> in AbstractJAXBProvider is not picking up the actual parameter types. I was
> thinking of extending to add to existing jaxb context map, i could not since
> its a private scoped hashmap. This should be automatically handled in
> AbstractJAXBProvider class. Following check can be made and added for actual
> type.
> ParameterizedType paramType = (genericType instanceof ParameterizedType) ?
> (ParameterizedType) genericType: null;
> if (paramType.getActualTypeArguments().length > 0) {
> // Fetch the actual type at index 0
> actualWrapperParamType = InjectionUtils.getType(
> paramType.getActualTypeArguments(), 0);
> Class<?> actualWrapperClass =
> InjectionUtils.getActualType(actualWrapperParamType);
>
> This actual class type check can be done inside getJAXBContext. This will do
> automatic deep check and setting into JAXB context only for custom payload
> types.
> Or else expose the jaxb context map to be accessible when extend
> AbstractJAXBprovider or JAXBElementProvider.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira