Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

468
Views
AOP para métodos internos y privados Java

Estoy tratando de registrar el tiempo de ejecución de los métodos anotados con una interfaz personalizada.

Estoy usando Spring AOP.

Pero esto no parece funcionar para los métodos internos.

Creo que es la limitación en Spring AOP.

 @Aspect public class BusinessProfiler { private static Log log = LogFactory.getLog(BusinessProfiler.class); @Around("execution(* *(..)) && @annotation(TimeLog)") public Object profile(ProceedingJoinPoint point) throws Throwable { long start = System.currentTimeMillis(); Object result = point.proceed(); String format = String.format("%s#%s: took [%s msec]", point.getTarget().getClass().getSimpleName(), MethodSignature.class.cast(point.getSignature()).getMethod().getName(), System.currentTimeMillis() - start); log.info(format); return result; } }

¿Hay alguna alternativa a Spring AOP?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si piensa en la forma en que Spring trata las anotaciones AOP, esto será claro:

Spring toma su clase y la envuelve en un proxy con el código adicional generado sobre la marcha por la anotación AOP agregada. Por lo tanto, solo se incluirá el código llamado a través del proxy (es decir, desde fuera de su clase).

Ejemplo

 @Service public class Foo { public void doSomething() { doSomethingInternal(); } public void doSomethingInternal() { } }

Si de otro Spring bean hago esto:

 @Service public class Bar { @Autowired private Foo foo; public void execute() { foo.doSomething(); } }

Solo se llamará a doSomething a través del proxy que envuelve su clase, no a doSomethingInternal, que será llamado por su clase.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!