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.

  • why don't you use annotations? - Mikhail Vaysman
  • Because no one asked me about this before and I finished reading the 4th chapter of the book Spring in Action this weekend. Can be more? - Kirill_Ja
  • instead of xml, you can use annotations, java-classes or groovy. or you can mix it all up. but I do not recommend. Discussion in the comments on the CO is not recommended. Ask a question and you will be answered. - Mikhail Vaysman
  • I read about the annotations. Interesting. I understand this is done to reduce the size of the configuration file. While I'm satisfied with the size. Now I plan to figure out how it all works. And I repeat the question. How to automatically create for each automatically detected bin a class "Arhitecture.Sort.Sort_SolutionWrapper", how I’ve figured out the constructor to transfer a new ClockWork (bean id = timer) - Kirill_Ja
  • CO is not a forum. - Mikhail Vaysman

0