0

In package com.repository I have :

  1. Standalone interfaces extending spring data Repository
  2. Interfaces extending spring data Repository with my own implementation in the same package
  3. Repository classes implementing my repository interfaces

I would like to measure execution time of all methods from com.repository package (communication with database). But I would like to avoid duplications

now with

@Pointcut("execution(public * com.repository..(..))")

I have some methods logged twice - from interface and from class implementing this interface. I would like either not to log methods from interfaces which have implementing class in the same package, or not to log methods from classes which implement interface from the same package.

How can I express it with pointcut and advice?

My question is a bit related to AspectJ : Issue when combining multiple pointcuts in @Around advice, but it doesn't solve my problem.

bastiat
  • 1,799
  • 2
  • 19
  • 38
  • 1
    The explanation would be a helpful illustration of your code. Unfortunately that code is missing. Where is your [MCVE](https://stackoverflow.com/help/mcve)? From your explanation it is impossible to exactly tell your situation even though you might think it is possible. But even if it was, I cannot compile your prose, run it and fix your aspect(s) and pointcut(s). Be a developer: let code speak! – kriegaex Oct 01 '19 at 08:12

1 Answers1

1

If the objects you're monitoring are located to a specific package, why you don't bound the pointcut only to that package.

So use

@Pointcut("execution(* com.repository.*.*(..))")

instead of

@Pointcut("execution(public * com.repository..*.*(..))")

which include "com.repository" package and all its sub packages.