I have setup a Filter for a specific set of requests i.e. */dispatch through my Guice Listener.
In this filter I want to change the binding for type BaseService (an interface containing one method ) in each request based on the Request URI. i.e. if the URI is /hello/dispatch I want BaseService to bind to HelloServiceImpl else if the URI is /bye/dispatch I want to bind to ByeServiceImpl . Both implement the BaseService .
Now somewhere in one my random class that participates in the servlet request handling I want to inject the appropriate implementation of BaseService specific to current request.
Is this possible ? How ? Thank you in advance.
Consider using a factory pattern for providing different types of BaseService.
Then the factory in your module.
and inject this into the Request.