プラグイン記述子で Spring Bean を定義する Grails プラグインを作成しています
def doWithSpring = {
myBean(MyBean)
}
プラグインの別のクラスからこの Bean への参照を取得する必要があります。
class Something {
def doIt() {
// I need to get a reference to myBean here. Is this the best way?
MyBean myBean = ApplicationHolder.application.mainContext.getBean('myBean')
}
}
Something
src/groovy
Bean と同じプラグイン内で定義されたクラスですが、Something
それ自体は Spring Bean ではありません。Grails 1.3.7 では、上記よりもこれを達成するためのより良い方法はありますか? *Holder クラスが Grails 2.0 で非推奨になっていることを知っているため、より良い方法を探しています。