Return-Path: Delivered-To: apmail-incubator-wink-dev-archive@minotaur.apache.org Received: (qmail 97905 invoked from network); 3 Nov 2009 10:27:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Nov 2009 10:27:36 -0000 Received: (qmail 93066 invoked by uid 500); 3 Nov 2009 10:27:36 -0000 Delivered-To: apmail-incubator-wink-dev-archive@incubator.apache.org Received: (qmail 93008 invoked by uid 500); 3 Nov 2009 10:27:36 -0000 Mailing-List: contact wink-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: wink-dev@incubator.apache.org Delivered-To: mailing list wink-dev@incubator.apache.org Received: (qmail 92998 invoked by uid 99); 3 Nov 2009 10:27:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 10:27:36 +0000 X-ASF-Spam-Status: No, hits=2.8 required=10.0 tests=HTML_FONT_FACE_BAD,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ajiyos@gmail.com designates 209.85.216.188 as permitted sender) Received: from [209.85.216.188] (HELO mail-px0-f188.google.com) (209.85.216.188) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Nov 2009 10:27:27 +0000 Received: by pxi26 with SMTP id 26so3989598pxi.22 for ; Tue, 03 Nov 2009 02:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=EJpxqKhOCsAFBMFW9/Jvs3UyOUHv1YOITvPns4MmNdM=; b=hE8Q7M2R8Gqh+eTqvMNWY/TJnAENSE1nG2MUNzMC01H4wye8TYftgHUtWT7O32x5xk QspSTf0EqGBqWF8BStR02JN8CKcqs4zEqksYfogB4FxU499ZgOfdO4Z7lk/w6JlXgnCZ I4mtIFUTwsZifBA0VbYCatGj6yaCLp3fAXv/o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=rQcMPGEP3kx5389eczQv8gChR3lWGxlcqEB1x2GLoCc2ll9LkT+jf9rcAFS/EH2RvC 6m3aFchoM/ctGKQOvr3Wv8EiqCfALPQ9X6Qs4yvIVuirOouqfvwdeYraUQNExdz8x0Dj lycFnLN0n0CIEiimtG/TKG8RsMVlLegag27Dc= MIME-Version: 1.0 Received: by 10.140.132.1 with SMTP id f1mr399556rvd.89.1257244026259; Tue, 03 Nov 2009 02:27:06 -0800 (PST) In-Reply-To: References: Date: Tue, 3 Nov 2009 15:57:06 +0530 Message-ID: Subject: Re: Question on JAXB ID resolver From: =?UTF-8?B?4LSF4LSc4LS/4LSv4LWL4LS44LWN4oCMIOC0r+C1i+C0ueC0qOC1jeC0qOC0vuC0qOC1jeKAjQ==?= =?UTF-8?B?KEFqaXlvcyk=?= To: wink-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=000e0cd2be4e94c937047774ef54 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd2be4e94c937047774ef54 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Bryant, Thanks for the solution. I have opened a JIRA WINK-224. On the meantime I will try to create a provider. Thanks, Ajiyos On Tue, Nov 3, 2009 at 1:53 AM, Bryant Luk wrote: > Hi Ajiyos, > > You will need to write your own entity provider in this case (although > you can set properties on the marshalling side, the unmarshalling does > not currently). If you want this feature, please open a JIRA against > Apache Wink (https://issues.apache.org/jira/browse/WINK) for future > consideration as time permits. > > If you want a solution immediately, you can look at the source for our > JAXB XML providers here and base your solution on them: > > http://svn.apache.org/repos/asf/incubator/wink/trunk/wink-common/src/main= /java/org/apache/wink/common/internal/providers/entity/xml/ > > For instance, you could write something like: > > @Provider > public MyXmlProvider implements MessageBodyReader { > > public boolean isReadable(Class type, > Type genericType, > Annotation[] annotations, > MediaType mediaType) { > return isJAXBObject(type, genericType) && > isSupportedMediaType(mediaType); > } > > public Object readFrom(Class type, > Type genericType, > Annotation[] annotations, > MediaType mediaType, > MultivaluedMap httpHeaders, > InputStream entityStream) throws > IOException, WebApplicationException { > Unmarshaller unmarshaller =3D null; > Object unmarshaledResource =3D null; > try { > JAXBContext context =3D getContext(type, mediaType); > unmarshaller =3D context.createUnmarshaller(); > // set something here > unmarshaller.setProperty(..., ...); > if (type.isAnnotationPresent(XmlRootElement.class)) > unmarshaledResource =3D unmarshaller.unmarshal(entityStrea= m); > else > unmarshaledResource =3D > unmarshaller.unmarshal(new > StreamSource(entityStream), type).getValue(); > } catch (JAXBException e) { > logger.error(Messages.getMessage("jaxbFailToUnmarshal"), > type.getName()); > throw new WebApplicationException(e, > Response.Status.BAD_REQUEST); > } > return unmarshaledResource; > } > > protected boolean isSupportedMediaType(MediaType mediaType) { > return MediaTypeUtils.isXmlType(mediaType); > } > > public static boolean isJAXBObject(Class type, Type genericType) { > return isXMLRootElement(type) || isXMLType(type); > } > } > > Add MyXmlProvider to your JAX-RS Application subclass in the > getClasses() method (or your wink-application config file). > > I would copy whatever you want out of the Wink source (i.e. don't > extend from the internal code) to make sure your code works in future. > > 2009/11/2 =E0=B4=85=E0=B4=9C=E0=B4=BF=E0=B4=AF=E0=B5=8B=E0=B4=B8=E0=B5=8D= =E2=80=8C =E0=B4=AF=E0=B5=8B=E0=B4=B9=E0=B4=A8=E0=B5=8D=E0=B4=A8=E0=B4=BE= =E0=B4=A8=E0=B5=8D=E2=80=8D(Ajiyos) : > > I didnt get any response in user group. Trying my luck here. > > > > ---------- Forwarded message ---------- > > From: =E0=B4=85=E0=B4=9C=E0=B4=BF=E0=B4=AF=E0=B5=8B=E0=B4=B8=E0=B5=8D= =E2=80=8C =E0=B4=AF=E0=B5=8B=E0=B4=B9=E0=B4=A8=E0=B5=8D=E0=B4=A8=E0=B4=BE= =E0=B4=A8=E0=B5=8D=E2=80=8D(Ajiyos) > > Date: 2009/11/2 > > Subject: Question on JAXB ID resolver > > To: wink-user@incubator.apache.org > > > > > > Hi, > > > > Can any one tell me how to hookup my custom IDResolver to wink framewor= k. > > > > The IDResolver need to be configured as a property to my jaxb > unmarshaller. > > However I coudnt find out how to get handle to unmarshaller. > > > > Thanks, > > Ajiyos > > > > -- > > "Attitude not the Aptitude determines the Altitude" > > > > > > > > -- > > "Attitude not the Aptitude determines the Altitude" > > > --=20 "Attitude not the Aptitude determines the Altitude" --000e0cd2be4e94c937047774ef54--