CHAPTER 4

image

Using Beans Scopes

So far you have an application called My Documents that for now is exposing a service that returns either all the documents available or it can return a list of documents by specific type. We were talking about the SearchEngine class implementation and the way you had configured it. Based on your XML configuration, you have set its scope to be a Singleton class, meaning that every time you require it by invoking the context.getBean method, you always get the same instance. But what happens if you require different instances, such as another service that is required to handle a fresh instance of your SearchEngine

Get Introducing Spring Framework: A Primer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.