mardi 31 mai 2016

Code architecture of service interface and service impl classes spring

I found out that in an MVC pattern, there are mainly 4 classes; the controller, the service, the service impl and repo.

Service is an interface and service impl implements service class and contains all the logical codes. The structure would be something like :-

Service interface class

Service{

public void someMethod();

}

ServiceImpl class

 ServiceImpl implements Service{
  public void someMethod(){
   //do something

   }    
 }

But when we want to access the service impl codes from controller, we call the method of service class as :-

@Autowired 
Service service;

Object obj =  service.someMethod();

How does the controller execute code of ServiceImpl class

Aucun commentaire:

Enregistrer un commentaire