October 2017
Intermediate to advanced
396 pages
10h 2m
English
Let's see the use of the @Around annotation:
@Around(execution(* com.packt.patterninspring.chapter6. bankapp.service.TransferService.createCache(..)))
public Object cache(ProceedingJoinPoint point){
Object value = cacheStore.get(CacheUtils.toKey(point));
if (value == null) {
value = point.proceed();
cacheStore.put(CacheUtils.toKey(point), value);
}
return value;
}
Here I used @Around annotation and a ProceedingJoinPoint, it inherits from Join Point and adds the proceed() method. As you can see in this example, this advice proceeds to target only if value is not already in the cache.
You have seen how to implement the advice in the application using annotations and how to create aspect and how to define pointcuts by ...
Read now
Unlock full access