To receive notifications of what are happening in spaces, you need to extend SpaceListenerPlugin and register it. Every method takes a SpaceLifeCycleEvent object as a parameter that contains the information about the event and its context.
The available events are:
spaceCreated: This event is called right after a space is created successfully with its applications.
spaceRemoved: This event is called right after the space is removed. It means all the applications of the space are removed, its group and group navigation are removed.
applicationAdded: This event is called right after an application is added (installed) to the space.
applicationActivated: This event is called right after an application is activated in the space.
applicationDeactivated: This event is called right after an application is deactivated.
applicationRemoved: This event is called right after an application is removed from the space.
joined: This event is called right after a user joins the space.
left: This event is called right after a space member leaves its space.
grantedLead: This event is called right after a user is granted the space's manager role.
revokedLead: This event is called right after the space's manager is revoked his role to be a space member.
import org.exoplatform.social.space.lifecycle.SpaceListenerPlugin;
public class MySpaceListenerPlugin extends SpaceListenerPlugin {
...
}
As an example, see SpaceActivityPublisher that publishes an activity based on an event that happened in a space.
To register your listener, configure it as a plugin to the SpaceService like this:
<external-component-plugins>
<target-component>org.exoplatform.social.core.space.spi.SpaceService</target-component>
<component-plugin>
<name>SpaceActivityPublisher</name>
<set-method>addSpaceListener</set-method>
<type>org.mycompany.MySpaceListenerPlugin</type>
</component-plugin>
</external-component-plugins>