1.8.3. Concrete example

The org.exoplatform.services.security.ConversationRegistry uses the ListenerService to notify that a user has just signed in or just left the application. For example, when a new user signs in, the following code is called:

listenerService.broadcast("exo.core.security.ConversationRegistry.register", this, state);

This code will in fact create a new Event of which name is "exo.core.security.ConversationRegistry.register", source is the current instance of ConversationRegistry and data is the given state. The ListenerService will call the method onEvent(Event<ConversationRegistry, ConversationState> event) on all the listeners which name is "exo.core.security.ConversationRegistry.register".

In the example below, we define a Listener that will listen to the event "exo.core.security.ConversationRegistry.register".

<?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- The full qualified name of the ListenerService --> 

      <!-- The name of the listener that is also the name of the target event -->
      <!-- The name of the method to call on the ListenerService in order to register the Listener -->
      <!-- The full qualified name of the Listener -->

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus