我正在使用 Guice 在我的 Web 应用程序中路由请求,并且我想模块化我将要处理的一些 URL 模式的路由。理想情况下,我希望能够在我的ServletModule
:
delegate("/foo/bar/*").to(SomeOtherServletModule.class);
// in SomeOtherServletModule.configureServlets:
serve("/foo/bar/quux").with(Quux.class);
甚至更好:
delegatePrefix("/foo/bar/").to(SomeOtherServletModule.class);
// in SomeOtherServletModule.configureServlets:
serve("/quux").with(Quux.class); // prefix removed
这在 Guice 中可行吗?似乎 Guice 非常努力地使 ServletModules 安装的绑定成为单例,而后者又存储了谁知道在哪里GuiceServletContextListener
被使用GuiceFilter
,但我想取消单例,这样我就可以像这样委托,而不是将所有内容紧密绑定在一个函数中。