我想使用akka actor實施CRUD操作。我是一個新的阿卡,所以不知道阿卡演員的設計基礎。如何擴展超級演員在akka中的行爲
我想分享多個子角色中的akka角色的行爲。
我想保存並刪除學生,老師和其他實體的杉木例子。
我已經創建了男演員StudentDao.scala
class StudentDao extends Actor with ActorLogging{
override def Receive = {
case Add(student) =>
// Add to database
case Delete =>
//Delete from database
// Some other cases related to Student entity
}
}
case object StudentDao{
case class Add(user : Student)
case class Delete(id : String)
}
同我有演員的TeacherDao.scala
class TeacherDao extends Actor with ActorLogging{
override def Receive = {
case Add(teacher) =>
// Add to database
case Delete =>
//Delete from database
// Some other cases related to teacher entity
}
}
object TeacherDao{
case class Add(user : teacher)
case class Delete(id : String)
}
我想兩個DAO抽象的刪除方法。 所以我要創建BaseDao.scala
class BaseDao extends Actor with ActorLogging{
override def Receive = {
case Delete =>
//Delete from database dao.delete
}
我怎麼能抽象的使用基本演員。