2

我的 Grails 应用程序中有一个 NotificationsAtmosphereHandler 作为 Atmosphere 框架处理程序类。我想在其中使用 springSecurityService 服务。如何将服务对象注入我的处理程序类?

def springSecurityService

通常的服务注入不起作用。

4

2 回答 2

2

资源.xml:

 <bean id="notificationsAtmosphereHandler" class="your.package.NotificationsAtmosphereHandler"/>

在班上:

class NotificationsAtmosphereHandler {
  .....
  @Autowired
  SpringSecurityService springSecurityService
  .....
} 
于 2011-11-19T21:57:06.613 回答
0

或者更确切地说,在您的 resources.groovy 中使用 Groovy 方式:

import package.NotificationsAtmosphereHandler

//...

notificationsAtmosphereHandler(NotificationsAtmosphereHandler) { bean ->
    bean.autowire = 'byName'
}

这样,您也不需要@Autowired 表示法。

于 2012-06-18T23:18:11.623 回答