2013-07-29 48 views
0

我相信這是非常簡單的事情,但我不記得有一個圖書館的文檔,API和版本之間有更多的差異。 (雖然平心而論,我敢肯定他們存在!)據我所看到的資源,我可以說,我認爲這是非常接近「目前」,但我得到一個錯誤(沒有AtmosphereHandler地圖請求/路徑/到/服務/點),並且需要一些關於我應該接下來嘗試的指導。集成Atmosphere(版本1.0.13)所需的java/scala配置是什麼?

我可以重新發布詳細的版本,但在短...

1)web.xml中有這個servlet條目(從最新的git聊天樣品):

<servlet> 
    <description>AtmosphereServlet</description> 
    <servlet-name>AtmosphereServlet</servlet-name> 
    <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class> 
    <async-supported>true</async-supported> 
    <init-param> 
     <param-name>org.atmosphere.cpr.Broadcaster.supportOutOfOrderBroadcast</param-name> 
     <param-value>false</param-value> 
    </init-param> 
    <!--<init-param>--> 
    <!--<param-name>org.atmosphere.cpr.broadcasterClass</param-name>--> 
    <!--<param-value>org.atmosphere.util.SimpleBroadcaster</param-value>--> 
    <!--</init-param>--> 
    <load-on-startup>0</load-on-startup> 
</servlet> 
<servlet-mapping> 
    <servlet-name>AtmosphereServlet</servlet-name> 
    <url-pattern>/path/to/service/point</url-pattern> 
</servlet-mapping> 

2 )在web-app有這個類的定義(Scala中):

@AtmosphereHandlerService(path = "/path/to/service/point") 
class MyCustomAtmoHandler extends AtmosphereHandler with Logging with OtherStuff { 
    override def onRequest {...} 
    override def onStateChange {...} 
    override def destroy {...} 

注:我用的是作爲指導文件不包含註釋參數「路徑」 - 我不得不爲了得到補充它來編譯。

編輯: 這是使用碼頭版本9.0.4.v20130625

回答

1

在回答我自己的問題(在某些情況下,其他流浪唯一發現自己在同一位置),我不得不做兩件事情解決問題:

1)刪除AtmosphereHandlerService註釋,或至少「路徑」參數。 (可能可以使用參數的其餘操作註釋;不知道。)

2)添加一個名爲atmosphere.xml到META-INF文件夾中的文件,其中包含類似:

<atmosphere-handlers> 
    <atmosphere-handler support-session="false" 
        context-root="/websocket/path/to/processorA" 
        class-name="com.some.className"> 
    </atmosphere-handler> 

    <atmosphere-handler support-session="true" 
        context-root="/websocket/optional/path/to/processorB" 
        class-name="com.some.other.className"> 
    </atmosphere-handler> 
</atmosphere-handlers> 

因此... web.xml(或者您的servlet容器使用的任何部署文件/體系結構)將爲所有處理程序創建「全局」上下文路徑,而使用atmosphere.xml標記將特定路由綁定到每個單獨的處理程序。 (像「/的WebSocket/*」應該允許路由到這兩個假設的處理程序的。

有指出,從技術角度來看,這種解決方案的可能是更好的辦法,但希望這外行的總結點,你在正確的方向。

相關問題