Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requireExplicitBindings do not work for Servlet Module #1533

Open
anuragagarwal561994 opened this issue Sep 3, 2021 · 0 comments
Open

requireExplicitBindings do not work for Servlet Module #1533

anuragagarwal561994 opened this issue Sep 3, 2021 · 0 comments

Comments

@anuragagarwal561994
Copy link

Note: Every servlet (or filter) is required to be a @singleton. If you cannot annotate the class directly, you must bind it using bind(..).in(Singleton.class), separate to the filter() or servlet() rules. Mapping under any other scope is an error. This is to maintain consistency with the Servlet specification. Guice Servlet does not support the deprecated SingleThreadModel.

We use binder().requireExplicitBindings() in order to avoid missing any bindings. This ensures we explicitly add their scope.

However, when the module is a ServletModule, this restriction doesn't seem to work.

One possible reason I could think of is that internally in Guice Servlet, ServletDefinition is the main entity and HttpServlet is mostly used as a proxy, so no injections are actually taking place for it to be explicitly bound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant