How to get Spring beans linked using @Autowired or set setter

I would like to separate one context of the Spring application (java application), which uses <context:annotation-config />several <context:component-scan ../>, but does not know exactly how the beans are connected there.

The application context (BeanFactory) provides a list of available beans and for each bean I would like to get a list of related beans - so those that are:

  • marked as "dependsOn" - the ones I can get from BeanDefinition
  • used as a reference to the constructor
  • used to execute @Autowired
  • used as property / setter reference
  • ... is there any other relationship?

Having such a relationship (matrix), I can determine where to cut - which beans can be transferred to the new (smaller) application context (java application), which should be exported / accessible via WS / RMI, etc.

Is there a way to extract such a relationship from an application context object? How to get such a matrix / graph ratio?

+4
source share
1 answer

In a Spring application, connection verification is performed at boot time. You can create your own “extractor” with two separate Junit tests. Separate the application slowly and test the application often.

0
source