List of usage examples for org.springframework.aop.framework Advised addAdvisor
void addAdvisor(Advisor advisor) throws AopConfigException;
From source file:org.openmrs.api.context.ServiceContext.java
/** * @param cls//from www .j av a 2 s . co m * @param advisor */ @SuppressWarnings("unchecked") public void addAdvisor(Class cls, Advisor advisor) { Advised advisedService = (Advised) services.get(cls); if (advisedService.indexOf(advisor) < 0) { advisedService.addAdvisor(advisor); } if (addedAdvisors.get(cls) == null) { addedAdvisors.put(cls, new HashSet<Advisor>()); } getAddedAdvisors(cls).add(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/*from ww w . ja v a2 s .c o m*/ * @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); } }