You are looking at documentation for an older release. Not what you want? See the current release documentation.
In eXo Platform, whenever an action occurs (for example, login/logout, content creation/modification), a corresponding event is sent to the Listener Service that dispatches the notification to its listeners. Listeners then can perform whatever action they want when receiving an event.
For example, to manage events related to profile updates, the ProfileLifecyle
that extends AbstractLifeCycle<ProfileListener, ProfileLifeCycleEvent>
will be implemented.
To listen to these event types, the ProfileLifecyle extends LifeCycleListener<ProfileLifeCycleEvent>
.
This listener is registered to ProfileLifecyle as below:
<external-component-plugins>
<target-component>org.exoplatform.social.core.manager.IdentityManager</target-component>
<component-plugin>
<name>ProfileUpdatesPublisher</name>
<set-method>addProfileListener</set-method>
<type>org.exoplatform.social.core.application.ProfileUpdatesPublisher</type>
</component-plugin>
</external-component-plugins>
For simplification, it is assumed that the user changes his avatar, then this activity is posted on his stream. The process of these actions are illustrated as below:
The ProfileUpdatesPublisher listener (that extends ProfileListenerPlugin) is registered into ProfileLifecyle in the IdentityManager
class.
When his profile is updated, the below event will be broadcasted.
/**
* {@inheritDoc}
*/
public void updateProfile(Profile existingProfile) throws MessageException {
....
broadcastUpdateProfileEvent(existingProfile);
}
Based on event type of avatar update, the ProfileLifecycle will dispatch that event to the avatarUpdated listener.
/**
* Broadcasts update profile event depending on type of update.
*
* @param profile
* @since 1.2.0-GA
*/
protected void broadcastUpdateProfileEvent(Profile profile) {
if (..) {
....
} else if (profile.getUpdateType().equals(Profile.UpdateType.AVATAR)) { // updateAvatar
profileLifeCycle.avatarUpdated(profile.getIdentity().getRemoteId(), profile);
} else if (...) {
}
}
The fired event is listened by ProfileListener.
@Override
protected void dispatchEvent(ProfileListener listener, ProfileLifeCycleEvent event) {
switch(event.getType()) {
case AVATAR_UPDATED :
listener.avatarUpdated(event);
break;
case BASIC_UPDATED:
...
}
}
Information included in the event is extracted and processed.
@Override
public void avatarUpdated(ProfileLifeCycleEvent event) {
.....
publishActivity(event, activityMessage, "avatar_updated");
}
private void publishActivity(ProfileLifeCycleEvent event, String activityMessage, String titleId) {
.....
publish(event, activity, activityId, titleId);
}
See Understanding the Listener Service for more details.
Events and event listeners in eXo Platform have to follow the org.exoplatform.services.listener.Event
and org.exoplatform.services.listener.Listener
classes respectively.
To make easy for you to learn about events in eXo Platform, this section will list events and their brief description that are classified to each module, including: