How it works...

The Spring IoC design pattern permits the creation of beans that look similar to anonymous beans for the purpose of injecting a lone bean object to a top-level one. Since inner beans are bounded within the scope of the top-level objects, their id and scope are no longer accessible outside the enclosing bean, generally anywhere in the container; thus, they are not considered mandatory <bean> attributes at this point.

The scope of an inner bean is by default Prototype. Changing it will be ignored by the container.

In JavaConfig containers, implementing inner beans is typically similar to creating an anonymous inner class instance at the method call level. But creating inner beans in Spring, generally, does not imply that the classes involved should be anonymous inner classes by specification. The Department classes are still loaded and initialized in some area of the container as top-level beans. Since the empRec5 object has exclusive access to a certain "Communication Department", the instance of the Department object per se was created immediately as an inner bean component of empRec5.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.134.198