Spring Bean Scope Method Injection
Spring Bean Scope Method Injection
www.java9s.com
Bean Scopes
Description (Default)Only one single instance will be created Prototype Creates any number of instances from a single bean configuration Request Scope of the bean instance will be limited to the Request life cycle Session Limited to session <bean name =student class =Student scope =prototype/> Global session Limited to global Scope Singleton
Singleton scope
ctx.getBean( student)
Spring Containe r
Prototype scope
ctx.getBean( student)
Spring Containe r
Multiple Bean
class MobileStore{ public String buyMobile() { return "Bought a Mobile Phone"; obileStoreReplacer implements MethodReplacer{ }} ic Object reimplement(Objectobj, Methodmethod, Object hrows Throwable{ rn Bought an iPhone;
ublic abstract class BookStorepublic interface Book { { public String bookTitle(); ublic abstract Book orderBook(); }
public class StoryBook implements Book{ public String bookTitle() { return "HarryPotter; } } public class ProgrammingBook implements Book{ public String bookTitle() { return "spring programming; } }
Managed by Spring
The ability of the container to override methods on container managed beans, to return the lookup result for another named bean in the container.