0
让我们的阶级结构如何通过继承传递隐式参数在akka中?
类结构
抽象基类开始
abstract class BaseCass {
def someFunction() : Any
//Here is the place where someFunction is called
startUpMethod = {
someFunction()
}
}
基地implemetation
import Utility._
class BaseImpelmentation {
//These parameters are not passed into method calls
implicit object ParameterOne = ParameterOne
implicit object ParameterSecond = ParameterSecond
implicit object ParameterThird = ParameterThird
def someFunction() : Any = {
functionWithImplicitOne();
functionWithImplicitSecond();
functionWithImplicitThird();
}
}
类具有隐函数
class Utility {
//here all function with implicit are defined.
}
该算法
someFunction
在类的初始化被称为例如它的构造后调用,但之前在 类
someFunction
任何其他方法BaseImpelmentation overrided- BaseImpelmentation进口与实用工具类隐含参数的功能。
问题
当someFunction
被称为在从BaseImpelmentation BaseClass的隐式参数不被使用。所以我必须将它们放在BaseCass中。但是在这种情况下,我将一个实现放在抽象类中,这不是很好。
是否有可能将隐式参数设置到BaseImpelmentation中,但不像通常的参数那样传递它们?