Injecting service into Grails Atmosphere Handler c

2019-07-23 17:35发布

I have an NotificationsAtmosphereHandler as an Atmosphere framework handler class in my Grails application. I would like to use springSecurityService service inside of it. How I can inject service object into my handler class?

def springSecurityService

The usual service injection does not work.

2条回答
倾城 Initia
2楼-- · 2019-07-23 18:31

resources.xml:

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

in class:

class NotificationsAtmosphereHandler {
  .....
  @Autowired
  SpringSecurityService springSecurityService
  .....
} 
查看更多
Viruses.
3楼-- · 2019-07-23 18:37

or rather do it the Groovy way in your resources.groovy:

import package.NotificationsAtmosphereHandler

//...

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

this way, you don't need the @Autowired notation also.

查看更多
登录 后发表回答