我使用吉斯連接一個碼頭服務器,我想與阿帕奇四郎增加一些安全性。配置四郎與吉斯沒有一個ServletContext
看來四郎需要 ServletContext的進行配置,但問題是我不; t有在配置時間一個ServletContext(例如在 servlet模塊如文檔狀態)。 ServletContext可用於 GuiceServletContextListener,但此時,我的注射器已經創建,因此要安裝 Shiro模塊的模塊已晚。
我試圖提供 ServletContext的到四郎通過吉斯提供商(提供商<的ServletContext >),但仍然沒有成功。我認爲這個提供者將在創建後提供ServletContext。這也給出了一個警告:
"com.google.inject.servlet.InternalServletModule$BackwardsCompatibleServletContextProvider get
WARNING: You are attempting to use a deprecated API (specifically, attempting to @Inject ServletContext inside an eagerly created singleton. While we allow this for backwards compatibility, be warned that this MAY have unexpected behavior if you have more than one injector (with ServletModule) running in the same JVM."
在注入器創建後,如何安裝Shiro Web模塊?
在我的情況下,注射器已經被ServletContext中在GuiceServletContextListener初始化時創建的。 – Mircea
在Guice中,WebGuiceEnvironment需要ServletContext。我試圖修改WebGuiceEnvironment並在創建注入器後設置ServletContext,但它似乎也不能像這樣工作。請求被阻止,但是我的域名不會被要求授權(這意味着每次都會阻止) – Mircea
您可以將模塊添加到現有的注入器嗎?你如何創建它? –