1.8.3. Concrete example

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

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"?>
<configuration>
...
  <external-component-plugins>
    <!-- The full qualified name of the ListenerService --> 
    <target-component>org.exoplatform.services.listener.ListenerService</target-component>

    <component-plugin>
      <!-- The name of the listener that is also the name of the target event -->
      <name>exo.core.security.ConversationRegistry.register</name>
      <!-- The name of the method to call on the ListenerService in order to register the Listener -->
      <set-method>addListener</set-method>
      <!-- The full qualified name of the Listener -->
      <type>org.exoplatform.forum.service.AuthenticationLoginListener</type>
    </component-plugin>

  </external-component-plugins>
</configuration>
...
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus