Could you consider in make available in the Spring API a way to report/list all the beans that have been wrapped by a Spring proxy? It should show all the @Transactional
classes for example ... I think AOP could be mentioned here, I mean about how the advice types methods were applied into the target beans.
Thanks for your understanding
Comment From: snicoll
Thanks for the suggestion. Said API kind of already exists by casting the bean to Advised
and get the Advisor
instances. However the advisor is likely to not be public as it is an implementation detail. What kind of report do you have in mind? Sharing an example report would be useful.
Comment From: manueljordan
Hello @snicoll
What kind of report do you have in mind?
Only for stats purposes. To know what beans were proxy and by whom, one or many (it if many advices are involved)
Now, in the same way that exists the isSingleton
, isPrototype
and isLazy
methods at the BeanDefinition
type
I think would be valuable add the following methods (where be appropriate):
isProxied
to return either true or falseproxiedBy
to return either null if not proxied andSet<E>
of proxies, the common scenario is one and many if many advices are involved.
Does the idea have sense?
Comment From: snicoll
Thanks. I am still not sure I get how you would use that practically. Can you give a few examples (class names) of what E
would be in practice?
Comment From: linuxmin
I can, like mentioned in https://github.com/spring-projects/spring-framework/issues/30667, some beans are not proxied in our application. I cannot give a reproducable example because i do not know how to reproduce this on a smaller scale, but even debugging or configuring a parameter which leads to an exception on startup would be helpful to avoid unexpected runtime behaviours. Would that be a possible solution?
Comment From: manueljordan
Thanks. I am still not sure I get how you would use that practically.
As reports and stats at real time. And It to research and know if a specific bean was wrapped and by whom.
- it indicated directly by
@Transactional
- or indirectly by AOP
Can you give a few examples (class names) of what E would be in practice?
Well E
is the proxy type that wraps the target type. The type of the proxy is unknown so far. So the request is know if a Bean is wrapped or not and if yes by whom. Therefore later can be expanded the research about what extra code was added in the proxy once detected the Proxy type.
Comment From: snicoll
Thanks. This is very close to getting the bean instance and checking if it implements Advised
. You could write that little utility quite easily. AOP is a concept that is external to both BeanDefinition
and BeanFactory
so adding an API at that level would be misplaced anyway.
I also believe that exposing the advisor with no added value isn't really interesting so please go ahead with checking for Advisor
for your own purposes there.