jeudi 5 avril 2018

How to implement DAO design pattern in java 8

i have a Controller in spring.From where i am calling service interface and from serviccImpl iam calling DAO .

I did not want expose DAO in controller .How i will archive this in lambdas. Before java 8

class Cotroller{
Service service=new ServiceImpl();
service.getUser();

}

interface Service{
getUser();
}

ServiceImpl implements Service{
getUser(){

dao.getUser();
}
}

interface ServiceDAO{
getUser();
}

ServiceDAOImpl implements ServiceDAO{
getUser(){
 //database logic

}
}

java 8 using lambda

class Cotroller{
Service service=()->

//need to use lambda for both interfaces with out exposing DAO in controller

}

Aucun commentaire:

Enregistrer un commentaire