Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
@Component
public static class MyListener implements PrivilegeListener {

    @Override
    public void privilegeChecked(User user, String privilege, boolean hasPrivilege) {
       //...do something}
    }
}

2. From the application context file

...

Code Block
public static class MyListener implements PrivilegeListener {

    @Override
    public void privilegeChecked(User user, String privilege, boolean hasPrivilege) {
       //...do something}
    }
}

Registering the listener in the application context file (this could be from a module):

Code Block
<bean id="myListener" class="org.openmrs.mymodule.listeners.MyPrivilegeListener" />

Now our listeners are ready to receive notifications as privileges checks are made.

The Privilege Helper Module is a good example usage of PrivilegeListeners.