Skip to main content

Posts

Showing posts from November, 2014

Spring Custom Scope

Spring framework is one of the DI frameworks which is largely used to develop web applications(enterprise). It provides almost every feature which is required to develop a enterprise web application. Also it is extendable, so you can customize it the way it suits for your application. Custom bean scope Although bean scopes provided by Spring fulfills requirements of the application, some times you may need something different which is not available by default. In our application we faced the same situation. Requirement We had a requirement of the scope which uses an application value to decide which bean to use(return). The default scopes provided by Spring were not useful and was not providing the required functionality. Implementation As I said earlier, Spring is extendable. It provides an interface Scope, which you can implement to introduce custom scope in your application. To create custom scope, Scope interface needs to be implemented. Scope interface has