3 Replies Latest reply on Dec 18, 2007 5:22 PM by Pete Muir

    @Autowired in a Seam bean

    Tim Evers Master

      Hi all,

      Ok... currently I have a Spring application integrated with my Seam beans via a Variable resolver. The problem with this is that in my Seam bean injection is done via the name of the "implementation" of an interface. This is different from the way Spring works which can Autowire based on type.

      So, a collegue of mine suggested I could use the @Autowired tag in my Seam beans and use some sort of event that occurs on creation to inject the Spring beans by type.

      Does anyone know how I could do this? As in what type of component do I need to create. He knows how to do the injection. I just need to know how to hook into the creation of the beans.

      Thanks!

        • 1. Re: @Autowired in a Seam bean
          Pete Muir Master

          I don't really understand the question...

          • 2. Re: @Autowired in a Seam bean
            Tim Evers Master

            Ok, basically I want to do spring injection in a SEAM bean.

            But instead of doing it with the variable resolver, I want to have a listener on the creation of the SEAM bean that goes through and injects the spring components that have the @Autowired annotation.

            The reason is that the variable resolver method binds me to the name of the implementation of the interface. Whereas the @Autowired annotation resolves by type.

            All I need to know is how I can create a "listener" (not sure of the right teminology) that listens for the creation of a SEAM bean so that I can get spring to inject it's components. I know how to do the injection, I just don't know how to create a component that "listens" for the creation of a SEAM bean.

            I'm sorry if this doesn't make sense :(

            • 3. Re: @Autowired in a Seam bean
              Pete Muir Master

              Use an interceptor - take a look at the BijectionInterceptor for how Seam does injection/outjection.