Receiving Cluster Topology Change Notifications
First, you'd have to create an implementation of this HAMembershipListener implementing its membershipChanged method where you'd inspect the vectors that see whether a new member has joined, left...etc
Secondly, you'd need to register this listener that you implemented. To do so, you'd first have to get a proxy instance to the MBean controlling this partition, which for cluster-service.xml, this is by default called jboss:service=DefaultPartition. For example:
MBeanServer server = MBeanServerLocator.locateJBoss();
cluster = (ClusterPartitionMBean) MBeanProxyExt.create(ClusterPartitionMBean.class, "jboss:service=DefaultPartition", server);
Let's say that your implementation of HAMembershipListener is called MyHAMembershipListener, then you'd do something like this to register it:
HAMembershipListener myMembershipListener = new MyHAMembershipListener();
Your listener is now registered so that i receives notifications of any changes in the cluster membership.