Prototype creates a brand new instance everytime you call getBean on
the ApplicationContext. Whereas for Request, only one instance is
created for an HttpRequest. So in a single HttpRequest, I can call
getBean twice on Application and there will only ever be one bean
instantiated, whereas that same bean scoped to Prototype in that same
single HttpRequest would get 2 different instances.
HttpRequest scope
HttpRequest scope
Prototype scopeEmployeeemployee1= context.getBean("employee");Employee= context.getBean("employee2employee");==employee1; //This will return trueemployee2
Employeeemployee1= context.getBean("employee");Employee= context.getBean("employee2employee");==employee1; //This will return falseemployee2
No comments:
Post a Comment