Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Dependency injection java

import java.util.List;
            // Controller
            public class NewsController {
                // Internal reference to the service used by this client
                private NewsServices newsServices;

                public NewsController(NewsServices newsServices){
                    // Constructor injection
                    this.newsServices = newsServices;
                }
                // Injected Methods
                public List getAll() {
                    return newsServices.findAll();
                }
                public News getOne(int id){
                    return newsServices.findOne(id);
                }

            }
Source by stickynotepickles.herokuapp.com #
 
PREVIOUS NEXT
Tagged: #Dependency #injection #java
ADD COMMENT
Topic
Name
8+3 =