Well, I will immediately say that I am just starting to study Spring, so do not judge very harshly. I caught myself writing the same thing in the configuration file.
<bean id="sorttask" class="Arhitecture.Sort.Sort_Task" factory-method="getTaskInstance" /> <bean id="timer" class="Arhitecture.ClockWork" scope="prototype"/> <bean id="bubblesort" class="Solutions.Bubble_Sort"> <constructor-arg ref="sorttask"/> </bean> <bean id="bubbleclock" class="Arhitecture.ClockWork"/> <bean id="bubblesortwrapper" class="Arhitecture.Sort.Sort_SolutionWrapper"> <constructor-arg index="0" ref="bubblesort"/> <constructor-arg index="1" ref="bubbleclock"/> </bean> <!--Feel like doing the same thing--> <!--Need to find a way like <context:component-scan> and for each solution bean do new wrapper (solution, timer) --> <bean id="mergesort" class="Solutions.Sort_by_Merge">> <constructor-arg ref="sorttask"/> </bean> <bean id="mergeclock" class="Arhitecture.ClockWork"/> <bean id="mergesortwrapper" class="Arhitecture.Sort.Sort_SolutionWrapper"> <constructor-arg index="0" ref="mergesort"/> <constructor-arg index="1" ref="mergeclock"/> </bean> <aop:config> <aop:pointcut id="runBubble" expression="execution(* Solutions.Bubble_Sort.run(..))"/> <aop:aspect ref="bubbleclock"> <aop:before pointcut-ref="runBubble" method="clockStart"/> <aop:after pointcut-ref="runBubble" method="clockEnd"/> </aop:aspect> <aop:aspect ref="bubblesortwrapper"> <aop:after pointcut-ref="runBubble" method="setCorrectness"/> </aop:aspect> </aop:config> In the aspect configuration, you will have to add the same lines for other id. In order not to repeat, it comes to mind to use <context:component-scan base-package="Solutions"/> , but I didn’t figure out how to create a new wrapper for each scanned bean. Please tell me where to find a solution. Then you can get links to all the components of the SolutionWrapper class from the context object, which I figured out how to do.