java - How to instrument / advice a Spring Data (JPA) repository? -
I failed in trying to advise Spring Data JPP repository. The goal is to target all non- However, Is there a way to promote @Notfound Resources for implementation? - Update - The question has changed to reflect the fact that the advice (around) should apply only to the repository with custom annotations. If you want to stop the repository call at the repository level, then you actually want to present custom annotations Not necessarily for him. You should be able to get this work done with a plain type match: Execution of all non- can be found in a slightly related example. zero public methods in a particular repository annotated with target custom annotations (ResourceNotFound in this example) and when a return value is either
null. City, Long & gt;, JpaSpecificationExecutor & lt; City & gt or an empty archive
@Repository @ResourceNotFound @Transactional (read only = true) Public Interface CityRepository JpaRepository & lt Expand {
@ResourceNotFound . Public void beanAnnotatedWithResourceNotFound () {} @Pointcut ("execution (public * * (..))" public ("zero" (com.digitalmisfits.spring.aop.annotation.ResourceNotFound * ) "@Pointcut Public Law () {@ @ (" Bean Untotted With Resource Notfoud () & amp; Public Law () ") Public Object PublicMethodInsideAClass Marked Wise Resource Notfound (ProceedingJoinpointPJP) Throwshell { System.out.println ("publicMethodInsideAClassMarkedWithResourceNotFound" + pjp.getTarget (). ToString ()) ;; Object retVal = pjp.proceed (); If ((((("isObjectEmpty == true") () () () () () () () () () () (pad) Return rate; }
publicMethodInsideAClassMarkedWithResourceNotFound (รข ?? |) method works when pointcut forms isspecified:
@Pointcut ("execution (Public * package.ctrippositiary +. * (..)) ")
@ResourceNotFound annotation can not be raised due to this fact The underlying class of the store interface is a (proxy)
SimpleJpaRepository which is not particularly commented.
@Pointcut ("! Execution (Public Zero org.springframework.data.repository.Repository + * (. .)) ")
zero methods for all spring beams extending this Spring data
Repository interface Will stop. / P>
Comments
Post a Comment