ColdSpring in five minutes

I am re-reading ColdSpring in 5 minutes. It says: "UserService needs UserGateway, and UserGateway needs ConfigBean". No! The custom service doesn't need anything. It doesn't call UserGateway.

All it does is set a variable that causes a match with the UserGateway user, but does not call the User Gateway component.

Help me understand this seemingly simple scenario!

0


a source to share


2 answers


You should remember that this starter app does not intentionally explain everything to prevent confusion. When fully configured, the sample application will initialize all three components. The UserService CFC user is responsible for configuring and receiving the User Gateway component, the User Gateway component is responsible for configuring and receiving the Config Bean, and the Config Bean is for setting and receiving application settings (in this case, only the data source information).



I wouldn't worry too much about this if you don't understand how it all works; The ColdSpring Reference will keep you focused.

+3


a source


The string "UserService needs UserGateway" means that one of the functions contains a variable or call that requires UserGateway, not necessarily that the UserService has an inherent need for this. This is at the heart of what ColdSpring does ... it manages dependencies. If the UserService has not been configured to enter UserGateway, then when a variable is created that "just happens" to call or is required by UserGateway, it will not be able to find the required UserGateway unless you manually create it.

Look in the "More Advanced" section of the Quickstart ColdSpring tutorial on "Factory Beans" for example.



Example 5 minutes was exactly like this, for example, you did not see calls in those functions that UserGateway needed, but when you have a need for this, you will be glad that it was introduced for you so you do not need to do it yourself.

0


a source







All Articles