David,

I have a JAX-RS service implemented in CXF. I can launch it from jetty:run.
I can launch it with the embedded CXF Jetty transport. I do not want to have
to be editing a web.xml to configure a filter. I want to tweak the headers
of all of the functions in it.

So this the response filter looks good, though I'd like it even better if an
@nnotation on the entire class could be used to configure it.

<beans>
<jaxrs:server id="customerService" address="/">
    <jaxrs:serviceBeans>
      <bean class="org.CustomerService" />
    </jaxrs:serviceBeans>

    <jaxrs:providers>
      <ref bean="authorizationFilter" />
    </jaxrs:providers>
    <bean id="authorizationFilter"
class="com.bar.providers.AuthorizationRequestHandler">
        <!-- authorization bean properties -->
    </bean>
</jaxrs:server>
</beans>



On Wed, Nov 18, 2009 at 2:48 PM, KARR, DAVID (ATTCINW) <[email protected]>wrote:

> > -----Original Message-----
> > From: Benson Margulies [mailto:[email protected]]
> > Sent: Wednesday, November 18, 2009 10:42 AM
> > To: [email protected]
> > Cc: [email protected]
> > Subject: Re: JAX-RS and cache-control
> >
> > I really don't want to do this at the servlet level, I want it to work
> > in
> > embedded jetty.
> >
> > Can you point me at an example of registering a ResponseHandler for my
> > entire service?
>
> Your first statement makes me think you think the servlet level is too
> "low" in the scope for your comfort, and you want it controlled at a higher
> scope, at the container level itself.  Your next statement refers to the
> ResponseHandler in CXF, which is at an even lower scope than the servlet
> level.
>
> If you want it controlled at the container level, then you should examine
> the configuration details of Jetty.  It's entirely possible this can be
> done.
>
> I wouldn't think it would make sense to do this at the CXF level.  Your
> requirement has nothing to do with what CXF is doing, so why use CXF to do
> it?
>
> > On Wed, Nov 18, 2009 at 12:25 PM, Sergey Beryozkin
> > <[email protected]>wrote:
> >
> > > Sure, it should actually work for JAXWS services too...Or doing the
> > same in
> > > the CXF custom out interceptor (MARSHAL phase for ex)
> > > That said, few more options are available at the (CXF) JAX-RS level :
> > > - register a custom ResponseHandler filer and override the JAXRS
> > Response
> > > by adding a Cache-Control header to the original Response, using a
> > JAXRS
> > > CacheControl utility
> > > - return JAXRS Response directly from all your methods and set that
> > header
> > > there, but it might be more intrusive
> > >
> > > Sergey
> > >
> > >
> > > ----- Original Message ----- From: "KARR, DAVID (ATTCINW)"
> > <[email protected]
> > > >
> > > To: <[email protected]>; <[email protected]>
> > > Sent: Wednesday, November 18, 2009 5:17 PM
> > > Subject: RE: JAX-RS and cache-control
> > >
> > >
> > >
> > >
> > >>  -----Original Message-----
> > >>> From: Benson Margulies [mailto:[email protected]]
> > >>> Sent: Wednesday, November 18, 2009 9:10 AM
> > >>> To: [email protected]
> > >>> Subject: JAX-RS and cache-control
> > >>>
> > >>> Can someone give me a recipe to add cache control headers to ALL
> > >>> responses
> > >>> from my JAX-RS service?
> > >>>
> > >>
> > >> You should be able to implement a servlet filter that adds response
> > >> headers for cache control.  In fact, several people on the internet
> > have
> > >> done exactly that.  Here's an example:
> > >> <
> > >> http://www.digitalsanctuary.com/tech-blog/java/jboss/setting-cache-
> > headers-from-jboss.html
> > >> >.
> > >>
> > >>
> > >
>

Reply via email to