Example usage for org.springframework.aop.framework Advised removeAdvisor

List of usage examples for org.springframework.aop.framework Advised removeAdvisor

Introduction

In this page you can find the example usage for org.springframework.aop.framework Advised removeAdvisor.

Prototype

void removeAdvisor(int index) throws AopConfigException;

Source Link

Document

Remove the advisor at the given index.

Usage

From source file:org.openmrs.api.context.ServiceContext.java

/**
 * @param cls// w w w  .j ava  2  s. c  o m
 * @param advisor
 */
@SuppressWarnings("unchecked")
public void removeAdvisor(Class cls, Advisor advisor) {
    Advised advisedService = (Advised) services.get(cls);
    advisedService.removeAdvisor(advisor);
    getAddedAdvisors(cls).remove(advisor);
}

From source file:org.openmrs.api.context.ServiceContext.java

/**
 * Moves advisors and advice added by ServiceContext from the source service to the target one.
 *
 * @param source the existing service//  w  w w . ja  v a  2 s. com
 * @param target the new service
 */
@SuppressWarnings("unchecked")
private void moveAddedAOP(Advised source, Advised target) {
    Class serviceClass = source.getClass();
    Set<Advisor> existingAdvisors = getAddedAdvisors(serviceClass);
    for (Advisor advisor : existingAdvisors) {
        target.addAdvisor(advisor);
        source.removeAdvisor(advisor);
    }

    Set<Advice> existingAdvice = getAddedAdvice(serviceClass);
    for (Advice advice : existingAdvice) {
        target.addAdvice(advice);
        source.removeAdvice(advice);
    }
}