17 May 2012 11:29
Re: Re: Testing Java Annotations - is this unit test or integration?
Miguel Almeida <miguel <at> almeida.at>
2012-05-17 09:29:43 GMT
2012-05-17 09:29:43 GMT
Hi Avi,
On a follow up from long ago, I'm having a hard time implementing this
on a Struts project (in the actions, more specifically).
Struts has IoC and a set of xAware interfaces - each providing a setter
for x and thus injecting it on the object seamlessly. So
ServletRequestAware provides a setRequest, so your object gets access to
the request object.
The problem arises when you have superclasses for Common information
(eg, for common services, common methods) (and maybe also when you
implement interfaces). I exemplify with both.
Imagine this:
RealAction extends CommonAction implements IAction(){
...}
CommonAction implements ServletRequestAware(){
public void setRequest(HttpRequest request){
_request = request;
}
AuthorizingDecorator implements IAction(){
//injected decorated IAction, see Avi's code
...
}
Now, when the application starts a http request-response with a regular
RealAction implementation, the request object exists:
RealAction extends CommonAction, so the request is injected through its
(Continue reading)
RSS Feed