1 Reply Latest reply on Oct 8, 2008 4:43 AM by Ales Justin

    Getting an instance of a bean from JBoss

    krish p Novice

      When JBoss starts up, my Spring beans get initialized. How can I get an instance of that bean at runtime though? Essentially, I need to get to the DefaultListableBeanFactory and do a getBean() but I am a little unclear about what the best way to do that is. Thanks.

        • 1. Re: Getting an instance of a bean from JBoss
          Ales Justin Master

          The best way is to get it injected.
          Same way we do it for Enterprise Beans and @Spring.

          And you have different flavors of SpringInterceptor.
          One to use with EJB3 (the simplest way to use it in JEE env), or you can use it as AOP interceptor.
          If used with AOP you need to configure things a bit more.
          But once you do that, there is no limit on what you can intercept.

          In the worst case you can always fallback to JNDI lookup for BeanFactory
          and then do simple getBean on BF.