Как получить Google ChannelPresence в ActionBean? - PullRequest
1 голос
/ 22 сентября 2011

Я пытаюсь получить отключение google ChannelPresence в ActionBean Stripes.В настоящее время я использую DynamicMappingFilter для динамического сопоставления моих URL-адресов ActionBean.Наличие разъединения работало отлично, когда я использовал сервлет, который был сопоставлен с "/_ah/channel/disconnected/".

Настраиваемое сопоставление работает с моим другим ActionBean, который использует UrlBinding (" / testing / ").Однако ChannelPresence, похоже, не отправляется моему ActionBean, который обрабатывает отключение ChannelPresence:

@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");
    }
}

Это мой 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</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>
...