私はbeforeInterceptor
のクラスから継承するコントローラを持っています。どのようにしてBeforeInterceptorsをチェーン化しますか?
ここは私の基本クラスです。
class FooBase {
def beforeInterceptor = [action: {parentInterceptor()}]
def parentInterceptor() {
render("Snarge")
}
}
ここでは動作しないコントローラのバージョンです。ここで
class BrokenController extends FooBase
{
def beforeInterceptor = [action: {childInterceptor()}]
def childInterceptor() {
super.beforeInterceptor.action.call()
render("Bar")
}
def index = {
render("Foo")
}
}
は、私がWorkingController
にインデックスを呼び出すとが、私は出力SnargeBarFoo
を作業
class WorkingController extends FooBase
{
def beforeInterceptor = {
super.beforeInterceptor.action.call()
render("Bar")
}
def index = {
render("Foo")
}
}
を取得しないことをバージョンです。私がBrokenController
のインデックスを呼び出すと、私はIllegalAccessError
私は、私の質問はここで何が起こっているの詳細については動作していると思いますか?なぜ1つのバージョンで子クラスの親クラスにアクセスできますが、他のバージョンではできませんか?
私が探しているユースケースは、except
機能を持つインターセプタ機能を使用できるようになっています。そのためには、インターセプタがマップを使用して実装されているときに、それらを連結できる必要があります。このaboit次
class BrokenController extends FooBase
{
def beforeInterceptor = [action: {this&childInterceptor()}]
def childInterceptor() {
super.beforeInterceptor.action.call()
render("Bar")
}
def index = {
render("Foo")
}
}
ドキュメントは述べている:第三のラインをチェック -
この問題の解決方法はありますか? – arvind