Interface is Used in Java?
Ans-> Because it is a good practice for Software engineer is to make the generic things as a part of Interface.
Q. . What is IOC?
Ref: https://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/beans.html
Q. What is classpath xml application context ??
Q. What is Spring Bean?
Ans--> Spring Bean is an Object that are managed by Spring IOC internally.
Beans are created and wired by the spring framework put it into a bag of objects (The Container).
from there we cab get them.
features of Beans:
1. Control Bean Lifecycle.
2. Can initialize or destroy the Objects.
Q. What are bean Scope?
1. Has effect on Bean Lifecycle -- when it will created or destroy.
2. How many instances get created.
3. How bean is shared.
- singleton – only one instance of the spring bean will be created for the spring container. This is the default spring bean scope. While using this scope, make sure bean doesn’t have shared instance variables otherwise it might lead to data inconsistency issues.
- prototype – A new instance will be created every time the bean is requested from the spring container.
- request – This is same as prototype scope, however it’s meant to be used for web applications. A new instance of the bean will be created for each HTTP request.
- session – A new bean will be created for each HTTP session by the container.
- global-session – This is used to create global session beans for Portlet applications.
Spring Bean Singleton and Prototype Scope
Spring bean singleton and prototype scopes can be used in standalone spring apps. Let’s see how we can easily configure these scopes using @Scope
annotation.
Ref: https://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch04s04.html
Scope | Description |
---|---|
Scopes a single bean definition to a single object instance per Spring IoC container. | |
Scopes a single bean definition to any number of object instances. | |
Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring | |
Scopes a single bean definition to the lifecycle of a HTTP | |
Scopes a single bean definition to the lifecycle of a global HTTP |
No comments:
Post a Comment