package com.vanilla.daoService;
@Repository("daoService")
public class DaoServiceImpl implements DaoService {
@Override
public String addStudent(Student student) {
//saving new user
}
@Override
public String updateStudent(Student student) {
//update new user
}
@Override
public String getStudent(String id) {
//update new user
}
}
我的業務邏輯類:Spring AOP的
package com.vanilla.blService;
@Service("blService")
public class BlServiceImpl implements BlService {
@Autowired
DaoService daoService;
@Override
public void updateStudent(String id){
Student s = daoService.getStudent(id);
set.setAddress(address);
daoService.updateStudent(s);
}
}
現在我想衡量每一個業務邏輯函數中執行的所有方法的執行
我創建(daoservice。*)我的外觀類
@Aspect
public class BlServiceProfiler {
@Pointcut("within(com.vanilla.blService.BlService.*)")
public void businessLogicMethods(){}
@Around("businessLogicMethods()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
long start = System.currentTimeMillis();
System.out.println("Going to call the method " + pjp.toShortString());
Object output = pjp.proceed();
System.out.println("Method execution completed.");
long elapsedTime = System.currentTimeMillis() - start;
System.out.println(pjp.toShortString()+" execution time: " + elapsedTime + " milliseconds.");
return output;
}
}
不幸的是,什麼也沒有發生。我認爲我的@PointCut
定義不正確,我怎麼才能正確地做到這一點?
你已經註冊使用Spring的方面? (只是檢查...) –
@肖恩,是的,我做了:) –