Hi,
I'm using spring to inject dependencies in my application.
I added a module I had previously developed that had the code in some
class (request is a HttpServletRequest):
private String getIpAddress() {
request = ServletActionContext.getRequest();
...
}
This now seems wrong on a few levels:
a) it creates a dependency in the containing project to struts that
shouldn't be there (the ServletActionConfiguration)
b) My database integration tests fail because on their context of
execution there is no ServletActionContext
I was thinking of a solution that involves injecting the request onto
the class. In the test environment I'll have no problems, I'll just
inject a mock HttpServletRequest.
However, in my application, I fail to see how I can inject the proper
request onto that class. Struts injects a request onto the actions. I'm
using spring-plugin. But @autowire-ing the request doesn't work, and in
my springcontext.xml, I fail to see how to fetch struts' request (whose
spring bean would be XXX in the following code):
<bean id="auditInterceptor" class="audit.AuditLogInterceptor"
scope="prototype">
<property name="request" ref="XXX"></property>
</bean>
Is what I am trying to achieve possible?
Regards,
Miguel Almeida