Search in sources :

Example 1 with EventBusAware

use of org.apache.shiro.event.EventBusAware in project shiro by apache.

the class RealmSecurityManager method applyEventBusToRealms.

/**
 * Sets the internal {@link #getEventBus  EventBus} on any internal configured
 * {@link #getRealms Realms} that implement the {@link EventBusAware} interface.
 * <p/>
 * This method is called after setting an eventBus on this securityManager via the
 * {@link #setEventBus(org.apache.shiro.event.EventBus) setEventBus} method to allow it to be propagated
 * down to all the internal Realms that would need to use it.
 * <p/>
 * It is also called after setting one or more realms via the {@link #setRealm setRealm} or
 * {@link #setRealms setRealms} methods to allow these newly available realms to be given the EventBus
 * already in use.
 *
 * @since 1.3
 */
protected void applyEventBusToRealms() {
    EventBus eventBus = getEventBus();
    Collection<Realm> realms = getRealms();
    if (eventBus != null && realms != null && !realms.isEmpty()) {
        for (Realm realm : realms) {
            if (realm instanceof EventBusAware) {
                ((EventBusAware) realm).setEventBus(eventBus);
            }
        }
    }
}
Also used : EventBusAware(org.apache.shiro.event.EventBusAware) EventBus(org.apache.shiro.event.EventBus) Realm(org.apache.shiro.realm.Realm)

Aggregations

EventBus (org.apache.shiro.event.EventBus)1 EventBusAware (org.apache.shiro.event.EventBusAware)1 Realm (org.apache.shiro.realm.Realm)1