IntelliJ Java IDE
The moose likes Spring and the fly likes Strange dependency injection goings on Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Spring
Reply Bookmark "Strange dependency injection goings on" Watch "Strange dependency injection goings on" New topic
Author

Strange dependency injection goings on

james frain
Ranch Hand

Joined: Apr 06, 2011
Posts: 34
Looking at this example in more detail and trying tofigure out how this works.
see http://static.springsource.org/docs/Spring-MVC-step-by-step/part5.html

My question is ... in the class JdbcProductDaoTests, how is the method


actually called?
I can see in the test-context that the bean definition is declared as

However, here's the puzzler, if I rename the method to setProductDaoXXX it still works, but if I call it xxsetProductDao it can't resolve which method to call when building the context.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 23635

James,
By convention, setters begin with setXXX. When you renamed the method to xxsetProductDao(), it becomes just a random method and not a setter. This makes sense. Spring shouldn't have to look at every single method for dependency injection. Only the constructors and setters.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Certs: SCEA Part 1, Part 2 & 3 & Core Spring 3, OCAJP
 
 
subject: Strange dependency injection goings on
 
Threads others viewed
DataSource
Spring: Configuring bean property
Spring AOP, How does this example do it?
returning an int
Spring Unit test help
MyEclipse, The Clear Choice