0

I want to implement a generic proxy for spring services (let's assume it does simple logging at the end and beginning of method + execution time of a method).

I'm using spring dependency injection and I want spring to create dynamic proxy mentioned above when injecting services. Is there any way to define 'global' bean factory that is used when spring creates objects?

I'm using @Autowired annotation and I don't want to include each bean definition in xml, just trying to find generic solution.

Mohammad Ashfaq
  • 1,333
  • 2
  • 14
  • 38
czajek
  • 714
  • 1
  • 9
  • 23
  • 2
    I know this is not a direct response to the question, but have you considered using aspects for this job? http://stackoverflow.com/questions/7302090/spring-standard-logging-aspect-interceptor – Morfic Apr 08 '14 at 13:02
  • Unfortunately it's about something much more complicated than logging. I have to call some methods on decorated object. – czajek Apr 08 '14 at 13:13
  • Do you have a common interface on those objects? – ElderMael Apr 08 '14 at 13:17
  • yes I have common interface – czajek Apr 08 '14 at 13:18
  • That's doable as well with AOP, as you can access method parameters or the proxied objects themselves. Take a look here http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html – Morfic Apr 08 '14 at 13:29
  • I will use AOP then, looks like something I can use. Thanks – czajek Apr 08 '14 at 14:06

0 Answers0