Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Beyond the Basics > Making Your Beans Spring Aware

Making Your Beans Spring Aware

One of the biggest selling points of DI over dependency lookup as a mechanism for achieving IoC is that your beans do not need to be aware of the implementation of the container that is managing them. To a bean that uses constructor injection, the Spring container is the same as the container provided by PicoContainer. However, in certain circumstances, you may need a bean that is using DI to obtain its dependencies so it can interact with the container for some other reason. An example of this may be a bean that needs access to the BeanFactory to automatically configure a shutdown hook for you. In other cases, a bean may wish to know its name so it can perform some additional processing based on this name.

Giving the bean name some kind of business meaning is generally a bad idea and can lead to configuration problems where bean names have to be artificially manipulated to support their business meaning.



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint