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- 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 +. * (..)) ")   

However, @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.

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:

  @Pointcut ("! Execution (Public Zero org.springframework.data.repository.Repository + * (. .)) ")   

Execution of all non- zero methods for all spring beams extending this Spring data Repository interface Will stop. / P>

can be found in a slightly related example.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -