Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12303

Custom topiclistener not working on richfaces push component of verion 4.2.2-Final and older

    Details

      Description

      See description here:
      https://community.jboss.org/message/736651#736651

      Copy it again:

      I use it like following lines:

       TopicsContext topicsContext = TopicsContext.lookup();
              Topic topic = topicsContext.getOrCreateTopic(new TopicKey("test"));
              topic.setMessageDataSerializer(DefaultMessageDataSerializer.instance());
              topic.addTopicListener(new SessionTopicListener2() {
                  @Override
                  public void processPreSubscriptionEvent(SessionPreSubscriptionEvent event) throws SubscriptionFailureException {
                     //TODO
                  }
                  @Override
                  public void processSubscriptionEvent(SessionSubscriptionEvent event) {
                       //TODO
                  }
                  @Override
                  public void processUnsubscriptionEvent(SessionUnsubscriptionEvent event) {
                       //TODO
                  }
              });
      

      I noted that listeners in TopicImpl are all the SessionTopicListener2 type, because add method is:

       
          public void addTopicListener(TopicListener topicListener) {
              TopicListener listener = topicListener;
              if (listener instanceof SessionTopicListener) {
                  listener = new SessionTopicListenerWrapper((SessionTopicListener) listener);
              }
              listeners.add(listener);
          }
      

      All SessionTopicListeners are wrapped to type SessionTopicListener2, and when event publish in TopicImpl, it check it if it is appropriate listener like this:

          public void publishEvent(TopicEvent event) {
              for (TopicListener listener : listeners) {
                  if (event.isAppropriateListener(listener)) {
                      try {
                          event.invokeListener(listener);
                      } catch (Exception e) {
                          logError(e);
                      }
                  }
              }
          }
      

      But event type SessionPreSubscriptionEvent, SessionSubscriptionEvent or SessionUnsubscriptionEvent does not override the mothed isAppropriateListener, so when checking, it use the method of its parent SessionTopicEvent, its parent method is like this:

       
          @Override
          public boolean isAppropriateListener(EventListener listener) {
              return (listener instanceof SessionTopicListener);
          }
      

      Then it always returns false for above three SessionTopicEvent , and the custom listeners will never be called. I think it may be changed from " return (listener instanceof SessionTopicListener);" to return (listener instanceof SessionTopicListener2); or override it in seperator implementation of type SessionTopicEvent.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                lfryc Lukáš Fryč
                Reporter:
                yyq2009 Daniel Yang
              • Votes:
                2 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 15 minutes
                  15m
                  Remaining:
                  Remaining Estimate - 15 minutes
                  15m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified