0

In my GWTP application I need to Inject HttpServletRequest, HttpSession as instance variable of ActionHandler.

My ActionHandler is initialized through Spring.

I can't get current Request object through Spring as it instantiates just POJO.

I am thinking about mixing GIN and Spring.

Would I be able inject HttpServletRequest using GIN in my ActionHandler which is instantiated through Spring?????

Is it possible to do following way??

@Configuration
@Import(DefaultModule.class)
public class ServerModule extends HandlerModule
{ 
    @Bean
    public UserVerficationActionHandler getUserVerificationActionActionHandler()
    {
        return new UserVerficationActionHandler();
    }
}
public class UserVerficationActionHandler implements ActionHandler<UserVerficationAction, UserVerficationActionResult>
{
@Autowired
private UserService userService;

private Provider<HttpServletRequest> requestProvider;

@Inject
public UserVerficationActionHandler()
{
}

public UserVerficationActionResult execute(UserVerficationAction action, ExecutionContext context) throws ActionException
{
           ....
}
@Inject
public Provider<HttpServletRequest> setRequestProvider()
{
    return requestProvider;
}
}

-------ActionHandler Ends--------

Can somebody let me know Is it possible to do SetterInjection this way?

Second thing, if above is possible then will I be getting current request object using this method?

Thanks in advance.

Bhavesh.

Bhavesh
  • 511
  • 6
  • 26
  • I think that you should try adding the 'Spring' tag to this question... – oberger Feb 16 '12 at 06:20
  • Owen, I already tried with Spring DI through annotation but it doesn't give current Request object instead it provides proxy object. – Bhavesh Feb 16 '12 at 09:05
  • I don't think you can 'Provide' a HttpRequest, because Guice isn't creating it, the servlet container is... This is the only answer I found that is close [...spring-how-do-i-inject-an-httpservletrequest-into-a-request-scoped-bean](http://stackoverflow.com/questions/3320674/spring-how-do-i-inject-an-httpservletrequest-into-a-request-scoped-bean), Good Luck – oberger Feb 16 '12 at 16:19
  • Finally, I have to get rid of Spring configuration from my application framework and have to live with raw GWT-Presenter. – Bhavesh Feb 20 '12 at 12:45

0 Answers0