Defining a service the Spring way.#11
Conversation
|
This is a nice enhancement. I don't cover @service in the course (although this would be nice to add), so I don't want to add this to the assignment and potentially confuse people. Also, we want to freeze the assignment and only apply bug fixes or README clarifications at this point. I do like this change, so I will merge it in for the next version of the course and update the lectures to cover dependency injection and @service before the first assignment. |
|
I went ahead and updated one of the lectures to mention @service. I am still going to wait to merge this pull request until the end of the class. Not including this in the assignment will allow people to discover on their own that they can either add @service or incorporate it into the Application as an @bean method. |
If we define the VideoFileManager as a @service, Spring will instantiate an instance during the application startup, and this can easily be referred from other classes using @Autowired:
No need to implement a Singleton pattern, as Spring IoC will do it for us.