Search:
eXo Development Tools : (Includes eXo JCR, eXo IDE, and other eXo technologies) Installation, configuration, development and administration questions.
Search this topic
User
Join Date:08/26/2010
Posts:3
Last post: 12/02/2010, 10:22 AM
Last Login:10/06/2010, 11:34 AM
[Resolved] Custom listener
Posted:Thu,Sep 02,2010, 02:40 PM

Hi

How could we create a Custom listener that will be executed once the user login or logout ?

Br

Last edited by romain.denarie on Tue,Nov 02,2010, 04:53 PM
Reason: Mark as resolved and change icon
User
Join Date:08/27/2010
Posts:6
Last post: 01/25/2011, 11:13 AM
Last Login:03/14/2011, 04:28 PM
Re: Custom listener
Posted:Fri,Sep 03,2010, 08:52 AM

Hi sanat,

To create a login or a logout listener under ALLINONE 1.6.6, you could follow these steps :

0)Install Maven build tool. We will use it in this example to package the listener project. Otherwise, it is optional and you could use another build tool.

1)Create a folder named signinListenerAIO1.6.6 in your personal workspace.

2)Write a listener java class which extends the "org.exoplatform.services.listener.Listener<ConversationRegistry, ConversationState>" and override this method:
public void onEvent(Event<ConversationRegistry, ConversationState> event) throws Exception;


The body of this method will contain the treatment to be executed once the user login or logout.
Place this class under signinListenerAIO1.6.6\src\main\java\org\exoplatform\samples\listener.

3)Write a configuration file named configuration.xml like this :


<?xml version="1.0" encoding="ISO-8859-1"?>
<configuration>
<external-component-plugins>
<target-component>org.exoplatform.services.listener.ListenerService</target-component>
<component-plugin>
<!-- The name of the the target event for the login listener, it must be exo.core.security.ConversationRegistry.unregister for the logout listener -->
<name>exo.core.security.ConversationRegistry.register</name>
<set-method>addListener</set-method>
<!-- The full qualified name of your custom login or logout Listener -->
<type>org.exoplatform.samples.listener.SignInListener</type>
</component-plugin>

</external-component-plugins>

</configuration>

Place this file under signinListenerAIO1.6.6\src\main\java\conf\portal.

4)Write a maven pom.xml to package the listener as a jar (see attached files) and place it under signinListenerAIO1.6.6 folder.

5)Open a dos console, change your working directory to signinListenerAIO1.6.6 and type "mvn clean install".

6)Copy the jar file exo.samples.signinlistener-1.0-SNAPSHOT.jar from the signinListenerAIO1.6.6\target to tomcatAIO1.6.6\lib.

7)Now run the server and login successfully. You must see a message in your console indicating the execution of your listener.

The attached file signinListenerAIO1.6.6.rar contains the example folder.

To run this example in another version of ALLINONE, WCM 2.X you have only to change your pom.xml.

The following links can be useful:

http://wiki.exoplatform.org/xwiki/bin/view/Kernel/Understanding%20the%20ListenerService
http://wiki.exoplatform.org/xwiki/bin/view/Products%20Tech%20Overview/org%20exoplatform%20services%20listener%20ListenerService
http://svn.exoplatform.org/projects/ks/trunk/eXoApplication/forum/service/src/main/java/org/exoplatform/forum/service/AuthenticationLogoutListener.java
http://svn.exoplatform.org/projects/ks/trunk/eXoApplication/forum/service/src/main/java/org/exoplatform/forum/service/AuthenticationLoginListener.java


Best regards.

Attachments:
Last edited by medamine_bz_exo on Tue,Sep 14,2010, 09:32 AM
Reason: add url links
User
Join Date:08/26/2010
Posts:3
Last post: 12/02/2010, 10:22 AM
Last Login:10/06/2010, 11:34 AM
Re: Custom listener
Posted:Wed,Oct 06,2010, 11:34 AM
Thank you very much for your reply medamine-bz-exo
BR
Rules
You can not create topics
You can not post replies
You can not post attachments
You can not edit your posts
Copyright © 2012. All rights reserved,eXo Platform SAS