Created
October 19, 2013 21:16
-
-
Save volgar1x/7061702 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
trait ConfigComponent { | |
trait Config { | |
def get[T](key: String): T | |
} | |
val config: Config | |
} | |
trait ConfigComponentImpl extends ConfigComponent { | |
class ConfigImpl extends Config { | |
val values = Map[String, Any]("some.key" -> 42) | |
def get[T](key: String) = values(key).asInstanceOf[T] | |
} | |
val config = new ConfigImpl | |
} |
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
trait NetServiceComponent { | |
type NetSession <: NetSessionInterface | |
val netService: NetServiceInterface | |
trait NetServiceInterface { | |
type TFut = Future[this.type] | |
def connected: Seq[NetSession] | |
def boot(): TFut | |
def kill(): TFut | |
} | |
trait NetSessionInterface { | |
type TFut = Future[this.type] | |
def service: NetService | |
def write(o: Any): TFut | |
def flush(): TFut | |
def close(): TFut | |
} | |
} | |
trait NetServiceComponentImpl { self: ConfigurationComponent => | |
private val port = config.get("port"): Int | |
type NetSession = NetSessionImpl | |
val netService = new NetServiceImpl | |
class NetServiceImpl extends NetService { | |
val connected = mutable.ArrayBuffer.empty[NetSession] | |
def boot(): TFut = ??? | |
def kill(): TFut = ??? | |
} | |
class NetSessionImpl extends NetSessionInterface { | |
def service = netService | |
def write(o: Any) = ??? | |
def flush() = ??? | |
def close() = ??? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment