Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 44BBAE618 for ; Fri, 8 Feb 2013 01:51:13 +0000 (UTC) Received: (qmail 12551 invoked by uid 500); 8 Feb 2013 01:51:13 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 12495 invoked by uid 500); 8 Feb 2013 01:51:13 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 12307 invoked by uid 99); 8 Feb 2013 01:51:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2013 01:51:13 +0000 Date: Fri, 8 Feb 2013 01:51:12 +0000 (UTC) From: "Sambit Dikshit (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CXF-4799) Parameterized Classes should be automatically added to JAXBContext MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-4799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13573829#comment-13573829 ] Sambit Dikshit edited comment on CXF-4799 at 2/8/13 1:50 AM: ------------------------------------------------------------- Comments this out and try in the testCase - testGenericsAndSingleContext2 // provider.init(Collections.singletonList(cri)); Also try a full blown client / server model. Where the client is hitting jaxrs service using WebClient. How this provider.init method get called in client side WebClient. It gets called in server side. So when writeTo method is called, it writes correctly in server side. Now in client side when WebClient is used, the readFrom method of povider tries to read but could not find the class in jaxb context since the provider.init method is not called in client side. In client side try - WebClient wc = WebClient.create(...); XmlList xmlList = wc.get(XmlList.class); // How do we pass the parameter type info here. was (Author: sambitd): Comments this out and try in the testCase - testGenericsAndSingleContext2 // provider.init(Collections.singletonList(cri)); Also try a full blown client / server model. Where the client is hitting jaxrs service using WebClient. How this provider.init method get called in client side WebClient. It gets called in server side. So when writeTo method is called, it writes correctly in server side. Now in client side when WebClient is used, the readFrom method of povider tries to read but could not find the class in jaxb context since the provider.init method is not called in client side. > 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: JAXB Databinding > Affects Versions: 2.7.2 > Reporter: Sambit Dikshit > > We are using a payload type which is a parameterized generic. For example, ServiceResponse { > 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