If the other service or a third party want to customize their code to handle a membership event, the event can be new or remove. They should create a class that extends this class and register the listener to the organization service. There are 2 ways to register a listener to the service. a) To do it programatically: [..] import org.exoplatform.container.PortalContainer ; import org.exoplatform.services.organization.OrganizationService ; [..] MembershipEventListener listener = new MyMembershipEventListener(..) ; PortalContainer pcontainer = PortalContainer.getInstance() ; OrganizationService service = (OrganizationService) pcontainer.getInstanceOfType(OrganizationService.class) ; service.getMembershipHandler().addMembershipEventListener(listener) ; b) Register by the xml configuration: You need to create a my.package.MyMembershipEventListener that extends this class and add a conf/portal/configuration.xml to the classpath. The configuration.xml can be in a jar file. The file should contain the following configuraiton:
<configuration> [..] <external-component-plugins> <target-component>org.exoplatform.services.organization.OrganizationService</target-component> <component-plugin> <name>my.membership.listener</name> <set-method>addListenerPlugin</set-method> <type>my.package.MyMembershipEventListener</type> <description>your listener description</description> </component-plugin> </external-component-plugins> [...] /configuration>
@author
Tuan Nguyen
@LevelAPI Platform