WSO2 Carbon User Stores provide the ability to customize user store operations by registering an event listener for these operations. The listeners are executed at a fixed point in the user store operation, and the users are free to create a listener which implements their desired logic to be executed at these fixed points.
The following diagram demonstrates a typical flow of execution of the user store operation, along with the listener's methods. The 'operation' method (here, representative of any user store operation) first calls the
listener.doPreOperation which is implemented in the listener, then calls the
doOperation, which is implemented in the subclass extending the
org.wso2.carbon.user.core.common.AbstractUserStoreManager (the abstract class which implements the
UserStoreManager interface). After this, the
listener.doPostOperation method is called. However, this flow will change depending on the implementation (for instance in the carbon authorization flow, there is only one listener method that is being called ).
In WSO2 Carbon products that use the standard user manager kernel, we have multiple interfaces with which we can implement User Store Listeners.
It is recommended to extend the existing abstract implementation of these interfaces rather than implementing from scratch. For example,
org.wso2.carbon.user.core.listener.UserOperationEventListener is implemented in the
org.wso2.carbon.user.core.common.AbstractUserOperationEventListener abstract class.