我的 Grails 应用程序中有一个 NotificationsAtmosphereHandler 作为 Atmosphere 框架处理程序类。我想在其中使用 springSecurityService 服务。如何将服务对象注入我的处理程序类?
def springSecurityService
通常的服务注入不起作用。
我的 Grails 应用程序中有一个 NotificationsAtmosphereHandler 作为 Atmosphere 框架处理程序类。我想在其中使用 springSecurityService 服务。如何将服务对象注入我的处理程序类?
def springSecurityService
通常的服务注入不起作用。
资源.xml:
<bean id="notificationsAtmosphereHandler" class="your.package.NotificationsAtmosphereHandler"/>
在班上:
class NotificationsAtmosphereHandler {
.....
@Autowired
SpringSecurityService springSecurityService
.....
}
或者更确切地说,在您的 resources.groovy 中使用 Groovy 方式:
import package.NotificationsAtmosphereHandler
//...
notificationsAtmosphereHandler(NotificationsAtmosphereHandler) { bean ->
bean.autowire = 'byName'
}
这样,您也不需要@Autowired 表示法。