[ 
https://issues.apache.org/jira/browse/CXF-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13578503#comment-13578503
 ] 

Sambit Dikshit commented on CXF-4799:
-------------------------------------

Thanks Sergey, Yes for proxy, it will figure out by scanning the proxy class ( 
service interface ).  Yes instead of replacing the jaxb context with new one, 
we can have a check if the type is parameterized type, then need to look for it 
from somewhere. I was thinking of sending the parameterized type in response 
header and in client layer while doing reading from xml stream to java pojo 
using jaxb provider, we can check for this header and add to parameterized type 
check so that it can be added to jaxb context first time and next time onwards 
it will be read from jaxb context. But i'm not very much comfortable exposing 
the type info in header as well ( does it make sense ). Java should make this 
generics to be available at runtime as well (dont understand the logic why its 
only compile time - its a big limitation in generics). 

Can you please share what tweaks you have made to AbstractJAXBProvider.  
                
> 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

Reply via email to