You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Puro, Jeff (HBO-NS)" <Je...@hbo.com> on 2010/09/22 21:22:10 UTC
HttpServletRequest Access in a JAX-RS Provider
I am attempting to create a Provider that implements the MessageBodyWriter interface. I would like my provider to use XStream to convert the passed in object to XML and then perform an XSLT transformation on the xml before writing the results to the OutputStream. This is easy enough to do, but I would also like to be able to pass in additional parameters relating to the request and perhaps anything else as it relates to the CXF message exchange. Is there any way to do this? It seems that the method signature for the writeTo method does not provide a way to access the request etc...
Regards,
Jeff
---------------------------------------------------------------------
This e-mail is intended only for the use of the addressees. Any copying, forwarding, printing or other use of this e-mail by persons other than the addressees is not authorized. This e-mail may contain information that is privileged, confidential and exempt from disclosure. If you are not the intended recipient, please notify us immediately by return e-mail (including the original message in your reply) and then delete and discard all copies of the e-mail.
Thank you.
---------------------------------------------------------------------
Re: HttpServletRequest Access in a JAX-RS Provider
Posted by Sergey Beryozkin <sb...@gmail.com>.
Yes - if it's a singleton then a thread-safe proxy is injected
cheers, Sergey
On Wed, Sep 22, 2010 at 9:29 PM, Puro, Jeff (HBO-NS) <Je...@hbo.com>wrote:
> Isn't there an issue of thread safety here? When I initially set up my
> provider it's just a singleton in my spring config. Is there something
> going on behind the scenes that makes each provider call thread safe?
>
> Thanks,
>
> Jeff
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Wednesday, September 22, 2010 4:27 PM
> To: users@cxf.apache.org
> Subject: Re: HttpServletRequest Access in a JAX-RS Provider
>
> Hi
>
> On Wed, Sep 22, 2010 at 8:22 PM, Puro, Jeff (HBO-NS) <Jeff.Puro@hbo.com
> >wrote:
>
> > I am attempting to create a Provider that implements the
> > MessageBodyWriter interface. I would like my provider to use XStream
> > to convert the passed in object to XML and then perform an XSLT
> > transformation on the xml before writing the results to the
> > OutputStream. This is easy enough to do, but I would also like to be
> > able to pass in additional parameters relating to the request and perhaps
> anything else as it relates to the CXF message exchange.
> > Is there any way to do this? It seems that the method signature for
> > the writeTo method does not provide a way to access the request etc...
> >
> >
> You can have
>
> @Context HttpServletRequest request;
> @Context UriInfo info;
> @Context HttpHeaders headers;
>
> injected into the provider. You might want to have CXF specific
> MessageContext injected - which will let you get to all of the above
> contexts
>
> cheers, Sergey
>
>
> > Regards,
> >
> > Jeff
> >
> > ---------------------------------------------------------------------
> > This e-mail is intended only for the use of the addressees. Any
> > copying, forwarding, printing or other use of this e-mail by persons
> > other than the addressees is not authorized. This e-mail may contain
> > information that is privileged, confidential and exempt from
> > disclosure. If you are not the intended recipient, please notify us
> > immediately by return e-mail (including the original message in your
> > reply) and then delete and discard all copies of the e-mail.
> >
> > Thank you.
> >
> > ---------------------------------------------------------------------
> >
> >
>
> Please consider the environment before printing this e-mail
>
> ---------------------------------------------------------------------
> This e-mail is intended only for the use of the addressees. Any copying,
> forwarding, printing or other use of this e-mail by persons other than the
> addressees is not authorized. This e-mail may contain information that is
> privileged, confidential and exempt from disclosure. If you are not the
> intended recipient, please notify us immediately by return e-mail (including
> the original message in your reply) and then delete and discard all copies
> of the e-mail.
>
> Thank you.
>
> ---------------------------------------------------------------------
>
>
RE: HttpServletRequest Access in a JAX-RS Provider
Posted by "Puro, Jeff (HBO-NS)" <Je...@hbo.com>.
Isn't there an issue of thread safety here? When I initially set up my provider it's just a singleton in my spring config. Is there something going on behind the scenes that makes each provider call thread safe?
Thanks,
Jeff
-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
Sent: Wednesday, September 22, 2010 4:27 PM
To: users@cxf.apache.org
Subject: Re: HttpServletRequest Access in a JAX-RS Provider
Hi
On Wed, Sep 22, 2010 at 8:22 PM, Puro, Jeff (HBO-NS) <Je...@hbo.com>wrote:
> I am attempting to create a Provider that implements the
> MessageBodyWriter interface. I would like my provider to use XStream
> to convert the passed in object to XML and then perform an XSLT
> transformation on the xml before writing the results to the
> OutputStream. This is easy enough to do, but I would also like to be
> able to pass in additional parameters relating to the request and perhaps anything else as it relates to the CXF message exchange.
> Is there any way to do this? It seems that the method signature for
> the writeTo method does not provide a way to access the request etc...
>
>
You can have
@Context HttpServletRequest request;
@Context UriInfo info;
@Context HttpHeaders headers;
injected into the provider. You might want to have CXF specific MessageContext injected - which will let you get to all of the above contexts
cheers, Sergey
> Regards,
>
> Jeff
>
> ---------------------------------------------------------------------
> This e-mail is intended only for the use of the addressees. Any
> copying, forwarding, printing or other use of this e-mail by persons
> other than the addressees is not authorized. This e-mail may contain
> information that is privileged, confidential and exempt from
> disclosure. If you are not the intended recipient, please notify us
> immediately by return e-mail (including the original message in your
> reply) and then delete and discard all copies of the e-mail.
>
> Thank you.
>
> ---------------------------------------------------------------------
>
>
Please consider the environment before printing this e-mail
---------------------------------------------------------------------
This e-mail is intended only for the use of the addressees. Any copying, forwarding, printing or other use of this e-mail by persons other than the addressees is not authorized. This e-mail may contain information that is privileged, confidential and exempt from disclosure. If you are not the intended recipient, please notify us immediately by return e-mail (including the original message in your reply) and then delete and discard all copies of the e-mail.
Thank you.
---------------------------------------------------------------------
Re: HttpServletRequest Access in a JAX-RS Provider
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On Wed, Sep 22, 2010 at 8:22 PM, Puro, Jeff (HBO-NS) <Je...@hbo.com>wrote:
> I am attempting to create a Provider that implements the MessageBodyWriter
> interface. I would like my provider to use XStream to convert the passed in
> object to XML and then perform an XSLT transformation on the xml before
> writing the results to the OutputStream. This is easy enough to do, but I
> would also like to be able to pass in additional parameters relating to the
> request and perhaps anything else as it relates to the CXF message exchange.
> Is there any way to do this? It seems that the method signature for the
> writeTo method does not provide a way to access the request etc...
>
>
You can have
@Context HttpServletRequest request;
@Context UriInfo info;
@Context HttpHeaders headers;
injected into the provider. You might want to have CXF specific
MessageContext injected - which will let you get to all of the above
contexts
cheers, Sergey
> Regards,
>
> Jeff
>
> ---------------------------------------------------------------------
> This e-mail is intended only for the use of the addressees. Any copying,
> forwarding, printing or other use of this e-mail by persons other than the
> addressees is not authorized. This e-mail may contain information that is
> privileged, confidential and exempt from disclosure. If you are not the
> intended recipient, please notify us immediately by return e-mail (including
> the original message in your reply) and then delete and discard all copies
> of the e-mail.
>
> Thank you.
>
> ---------------------------------------------------------------------
>
>