Injecting Prototype Beans in Singletons

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading "Spring Beginners to Professionals". In the previous posts,we talked about scopes of Spring beans. Now as there are many different scopes, the basic problem which arises is injecting prototype beans in singletons. We can also define this problem in a more general way, say collaboration between beans of different scopes. Injecting Prototype Beans in Singletons By now we have learnt that the dependency injection happens when the container starts. All the singleton...
Read More

Understanding the Bean Scopes in Spring

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading "Spring Beginners to Professionals". In one of the previous posts, I introduced the concept of scopes for beans. This post is completely focused on explaining the bean scopes in Spring and their usages. Bean Scopes in Spring A scope can be considered as a logical boundary within which a bean is deployed and known to the application. There are handful of scopes in Spring. Before moving on to the scopes defined by Spring, let us  understand how a scope in gener...
Read More

Spring Environment and Spring Profiles

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading “Spring Beginners to Professionals“. In real enterprise scenario you run your application in different environments. For e.g.: dev, testing, stage, production etc. And it is logical to have different set of properties for each of these environment. For e.g. a developer might want to use an in memory database configuration for his unit testing, whereas a QA might want to test it against a test database. Business users may want to test it against a stage database...
Read More

Properties and PropertySources in Spring

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading “Spring Beginners to Professionals“. All the modern enterprise level applications require external properties files and it is important to have a clean mechanism of using these properties in the application. Spring provides an abstraction for achieving the same in form of Properties and PropertySources. This post is a continuation to the ApplicationContext chapter. Remember, this is one of the important features imparted by the ApplicationContext? How are Prop...
Read More

Resources and ResourceLoaders in Spring

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading “Spring Beginners to Professionals“. An enterprise level application is found to deal with a lot of resources, both static and dynamic. For e.g. properties files, images, xmls etc. In this post we will discuss about resources and ResourceLoaders in Spring. Resources and ResourceLoaders in Spring It is important to understand, how Spring treats a Resource and what does it mean when we say Resource in a Spring application. What is a Resource? A resou...
Read More

Understanding the ApplicationContext in Spring

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading “Spring Beginners to Professionals“. In the previous post we discussed the BeanFactory in detail. Here we will try and put some more effort in understanding the ApplicationContext and its flavors. Understanding the ApplicationContext We have reached far enough and have acquired good knowledge to understand the concept of the Application Context. It is a sub interface of ListableBeanFactory and HierarchicalBeanFactory discussed in the previous post. Why do we ne...
Read More

Understanding the BeanFactory – Spring

Introduction This is a series and it would make a lot of sense if read in a sequence. You can find all the posts under the heading “Spring Beginners to Professionals“. In the previous post we mentioned about the BeanFactory. Here we will try and put some more effort in understanding the BeanFactory. A deeper understanding of the BeanFactory will ease our journey further. Understanding the BeanFactory As our XML configuration metadata is a container of bean elements, so is our BeanFactory a container of BeanDefinitions and in turn beans. We can consider the BeanFactory as a central registry ...
Read More