Hi

this should work, there's a couple of options, assuming you have an abstract 
class which all other resource classes extend

1. just have a private field :

@Context
private HttpHeaders headers;

2. Alternatively, have a setter :

// note, no @Context
private HttpHeaders headers;

public void setHttpHeaders(HttpHeaders headers) {this.headers = headers;}

this 2nd option may work better if you have Spring proxifying your resource classes; for ex, you could have a dedicated interface like Injectable (the name of the interface is up to a user to choose) which this abstract class will implement and thus will help Spring to inject if Spring proxies are pure JDK proxies as opposed to CGLIB ones...

cheers, Sergey

----- Original Message ----- From: "KARR, DAVID (ATTCINW)" <[email protected]>
To: <[email protected]>
Sent: Monday, January 11, 2010 4:41 PM
Subject: How to have a super class of the resource class use CXF annotations?


That subject isn't worded quite right, but hopefully I can clear that
up.

I started out with a small handful of resource classes, each of which
points to a separate portion of my domain classes.  I realized that
there are some HTTP headers that I'd like to get automatically, without
specifying them explicitly in each method.  I realized I could just
define an instance variable in the resource class and then put the
"@HeaderParam annotation on the field.  That works fine.  However, what
I'd really like to do is have a base class that all the resource classes
extend, which has the annotated instance variable.  All I did was "pull
up" the instance variable and the getter/setter to a base class and
retested that, and I found that the instance variable was not set.

Is there something I have to do to get CXF to look at the base class for
CXF annotations, or is this a scenario that isn't possible yet?

Reply via email to