What specifically do you need an actual request for? This strikes me
as coupling your design to the servlet spec, and there's rarely a
strong reason to do that past the web layer itself. The idea on
injecting a request just seems wrong.

Is that a Struts 2 interceptor you're trying to inject it in to?

Dave

On Friday, May 27, 2011, Miguel <mig...@almeida.at> wrote:
> 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
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to