Created
March 6, 2014 16:31
-
-
Save whiter4bbit/9393603 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor._ | |
object TCPFrontend { | |
case class Event(id: String) | |
} | |
trait StorageComponent { | |
val storage: Storage | |
trait Storage { | |
def store(id: String): Unit | |
} | |
} | |
trait StorageComponentImpl extends StorageComponent { | |
val storage = new StorageImpl | |
class StorageImpl extends Storage { | |
def store(id: String): Unit = println(s"Stored") | |
} | |
} | |
trait TCPFrontend extends Actor { | |
self: StorageComponent => | |
def receive = { | |
case TCPFrontend.Event(id) => storage.store(id) | |
} | |
} | |
class TCPFrontendProd extends IndirectActorProducer { | |
override def actorClass = classOf[TCPFrontend] | |
override def produce = new TCPFrontend with StorageComponentImpl | |
} | |
object ShowCase { | |
def main(args: Array[String]): Unit = { | |
val system = ActorSystem() | |
val ref = system.actorOf(Props(classOf[TCPFrontendProd])) | |
ref ! TCPFrontend.Event("1") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment