2
爲了實現自定義會話存儲,我實現了自定義會話管理器(通過擴展NoSqlSessionManager
)和sessionIdManager。我的代碼(與它需要的罐子一起)進入${jetty.home}/lib/ext
(版本8.1.4順便說一句)。隨着start.ini
我包含以下內容的另一個配置文件:Jetty和自定義會話IdManager
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Set name="sessionIdManager">
<New id="customIdMgr" class="com.me.customSessionIdManager">
<Arg>...</Arg>
</New>
</Set>
</Configure>
碼頭開始和sessionIdManager似乎是工作。正在調用至少scavenge()
方法。到現在爲止還挺好。下一步是將我的自定義會話管理器與我選擇的WebAppContext
相關聯。我有以下內容做到了覆蓋模板(overlay.xml
)內:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Get name="server">
<Get id="customIdMgr" name="sessionIdManager"/>
</Get>
<Set name="sessionHandler">
<New class="org.eclipse.jetty.server.session.SessionHandler">
<Arg>
<New class="com.me.customSessionManager">
<Set name="sessionIdManager"><Ref id="customIdMgr"/></Set>
</New>
</Arg>
</New>
</Set>
</Configure>
但是開始的時候碼頭我得到這個:
WARN:oejx.XmlConfiguration:Config error at <Get id="customIdMgr" name="sessionIdManager"/> java.lang.NullPointerException
...這意味着這是在主註冊的對象當處理疊加層時,碼頭配置現在不見了。
任何想法我在這裏做錯了嗎?
如果它仍然正確,您應該接受。 – Gray