mobilecloud-14 icon indicating copy to clipboard operation
mobilecloud-14 copied to clipboard

Defining a service the Spring way.

Open vdumitrescu opened this issue 11 years ago • 2 comments

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:

@Autowired private VideoFileManager videoFileManager;

No need to implement a Singleton pattern, as Spring IoC will do it for us.

vdumitrescu avatar Jul 28 '14 10:07 vdumitrescu

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.

juleswhite avatar Jul 28 '14 13:07 juleswhite

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.

juleswhite avatar Jul 28 '14 16:07 juleswhite