开发者

How to receive Google ChannelPresence in an ActionBean?

I am trying to receive the disconnect google ChannelPresence in a Stripes ActionBean. I am currently using DynamicMappingFilter to dynamically map my ActionBean URLs. The disconnect presence was working perfectly when I was using a servlet that was mapped to "/_ah/channel/disconnected/".

The custom mapping is working with my other ActionBean that uses UrlBinding("/testing/"). However, the ChannelPresence does not seem to be sent to my ActionBean that handles a ChannelPresence disconnect :

@UrlBinding("/_ah/channel/disconnected/")
public class LogoutActionBean implements ActionBean {

    private ActionBeanContext context;
    public void setContext(ActionBeanContext abc) {
        context = abc;
    }

    public ActionBeanContext getContext() {
        return context;
    }

    @DefaultHandler
    public Resolution logout() {
        UserStore userStore = UserStore.getInstance();
        ChannelService channelService = ChannelServiceFactory.getChannelService();
        ChannelPresence presence = null;
        String clientID = null;
        try {
            presence = channelService.parsePresence(context.getRequest());
        } catch (IOException e) {
        }
        if (presence != null) {
            clientID = presence.clientId();
            userStore.removeUser(clientID);
        }
        UserStoreUtility.updateAllUserList();
        return new ForwardResolution("UserList.jsp");
    }
}

This is my web.xml:

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <filter>
        <display-name>Stripes Filter&l开发者_如何学JAVAt;/display-name>
        <filter-name>StripesFilter</filter-name>
        <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
        <init-param>
            <param-name>ActionResolver.Packages</param-name>
            <param-value>net.sourceforge.stripes.examples, com.channel</param-value>
        </init-param>
    </filter>
    <filter>
        <description>Dynamically maps URLs to ActionBeans.</description>
        <display-name>Stripes Dynamic Mapping Filter</display-name>
        <filter-name>DynamicMappingFilter</filter-name>
        <filter-class>
            net.sourceforge.stripes.controller.DynamicMappingFilter
        </filter-class>
    </filter>
    <filter-mapping>
        <filter-name>DynamicMappingFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜