Spring Flashcards
Frameworks ?
what do u mean by a Frameworks in java?
Frameworks are large bodies (usually many classes) of prewritten code to which we add our own code to solve a problem in a specific domain.
- & the framework will be in control.
spring framework?
- Spring is a lightweight framework.
- It can be thought of as a framework of frameworks because it provides support to various frameworks such as Struts, Hibernate, Tapestry, EJB, JSF etc.
- The framework, in broader sense, can be defined as a structure where we find solution of the various technical problems.
- The Spring framework comprises several modules such as IOC, AOP, DAO, Context, ORM, WEB MVC etc.
POJO ?
full form?
use?
POJO stands for Plain Old Java Object,
-its used to describe the same things as a “Normal Class” whereas a JavaBean follows a set of rules.
-Most commonly Beans use getters and setters to protect their member variables, which are typically set to private and have a no-argument constructor.
For example, to receive messages from JMS, need to write a class that implements the MessageListener interface.
IoC ?
- Inversion of Control is a software engineering principle
- in which it transfers the control of objects or portions of a program to a container or framework.
extra: -
- We most often use it in the context of object-oriented programming.
- In contrast with traditional programming, in which our custom code makes calls to a library, IoC enables a framework to take control of the flow of a program and make calls to our custom code.
- To enable this, frameworks use abstractions with additional behavior built in.
- If we want to add our own behavior, we need to extend the classes of the framework or plugin our own classes.
Dependency injection ?
- Dependency injection is a pattern we can use to implement IoC, where the control being inverted is setting an object’s dependencies.
Connecting objects with other objects, or “injecting” objects into other objects, is done by an assembler rather than by the objects themselves.
Spring framework’s 6 types of scopes:
Spring framework defines 6 types of scopes:
singleton prototype request session application websocket
Singleton Scope ?
Singleton Scope
When we define a bean with the singleton scope, the container creates a single instance of that bean; all requests for that bean name will return the same object, which is cached. Any modifications to the object will be reflected in all references to the bean. This scope is the default value if no other scope is specified.
Prototype Scope ?
Prototype Scope :-
A bean with the prototype scope will return a different instance every time it is requested from the container. It is defined by setting the value prototype to the @Scope annotation in the bean definition: