Best way to retrieve beans instances from the ioc container
I am pretty new to Spring and I am trying to find my way in this.
In EJB in order to get stateless beans ref from anywhere in your project(from different classes) you could use jndi lookup or annotation injection.
How does it work with Spring?
should I use this code in each class which desire to get reference to a certain bean:
Or should I declare ApplicationContext in a Singleton class and then pass it's reference between the classes and then use context.getBean(..)
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
MyBean myBean= (MyBean ) context.getBean("MyBean");