List of usage examples for org.springframework.aop.framework Advised addAdvice
void addAdvice(Advice advice) throws AopConfigException;
From source file:org.openmrs.api.context.ServiceContext.java
/** * @param cls/* www. j ava 2 s. c om*/ * @param advice */ @SuppressWarnings("unchecked") public void addAdvice(Class cls, Advice advice) { Advised advisedService = (Advised) services.get(cls); if (advisedService.indexOf(advice) < 0) { advisedService.addAdvice(advice); } if (addedAdvice.get(cls) == null) { addedAdvice.put(cls, new HashSet<Advice>()); } getAddedAdvice(cls).add(advice); }
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 w w w .j a 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); } }