Java Hyd Team
Photo
Don't write handler adaptor rest everything is same just replace everything with your file name
Q3.) What is IOC & IOC Lifecycle ?
A3.) it is a design pattern that allows program control to be inverted
or
transfer from traditional in-process control structure to separate service provider .
LifeCycle of IOC
1. Initialization :- IOC container is initialised and configured.
2. Binding :- Components are registered with container & can be specifying interfaces
.
3. Resolution :- Dependencies of the components are resolved and the appropriate
instance is created
4. Invocation :- Container invokes specific methods of the components.
5. Destruction :- Component destroyed & restore released
A3.) it is a design pattern that allows program control to be inverted
or
transfer from traditional in-process control structure to separate service provider .
LifeCycle of IOC
1. Initialization :- IOC container is initialised and configured.
2. Binding :- Components are registered with container & can be specifying interfaces
.
3. Resolution :- Dependencies of the components are resolved and the appropriate
instance is created
4. Invocation :- Container invokes specific methods of the components.
5. Destruction :- Component destroyed & restore released
Q5.) What is dependency Injection and Types
A5.) a class receives instances of object it depends upon external
source rather than creating them itself .
this allows class to be independent of how the object
it depends on are created & makes code easier to maintain test
Rules of DI
1. Constructor-based Dependency Injection:- in this dependent object is provided
as the parameter in the constructor of class .
it is provided when class is instantiated.
2. Setter-based Dependency Injection :- dependent object is provided in class
through setter methods
this is useful when dependency is optional or when it can be changed even
after class is instantiated
3. Interface-based Dependency Injection :- defined some methods that must be
implemented by dependent objects
this is useful when class needs to be decoupled from dependent objects
allowing it into different implementations of dependent objects
4. Autowiring Dependency Injection :- this injection in spring
framework enables you to inject the object dependency implicitly.
It internally uses setter or constructor injection.
Autowiring can't be used to inject primitive and string values. It works with
reference only
A5.) a class receives instances of object it depends upon external
source rather than creating them itself .
this allows class to be independent of how the object
it depends on are created & makes code easier to maintain test
Rules of DI
1. Constructor-based Dependency Injection:- in this dependent object is provided
as the parameter in the constructor of class .
it is provided when class is instantiated.
2. Setter-based Dependency Injection :- dependent object is provided in class
through setter methods
this is useful when dependency is optional or when it can be changed even
after class is instantiated
3. Interface-based Dependency Injection :- defined some methods that must be
implemented by dependent objects
this is useful when class needs to be decoupled from dependent objects
allowing it into different implementations of dependent objects
4. Autowiring Dependency Injection :- this injection in spring
framework enables you to inject the object dependency implicitly.
It internally uses setter or constructor injection.
Autowiring can't be used to inject primitive and string values. It works with
reference only
Q11.) StereoType annotations & use ?
A11.) it is used to define & classify type of classes , fields & methods
it can be used to define / improve code readability & maintainability & to ensure that code elements are used properly.
it can be used to apply common behaviour such as applying security or logging ,across multiple elements examples of stereotype annotations in springboot
1. @Component: This stereotype annotation is used to mark a class as a component. It is used to indicate that a class is a candidate for auto-detection by Springβs component scanning mechanism.
2. @Service: This stereotype annotation is used to mark a class as a service. It is used to indicate that a class is a business service class.
3. @Repository: This stereotype annotation is used to mark a class as a repository. It is used to indicate that a class is a data access object.
4. @Controller: This stereotype annotation is used to mark a class as a controller. It is used to indicate that a class is a web controller class.
5. @RestController: This stereotype annotation is used to mark a class as a rest controller. It is used to indicate that a class is a web rest controller class.
A11.) it is used to define & classify type of classes , fields & methods
it can be used to define / improve code readability & maintainability & to ensure that code elements are used properly.
it can be used to apply common behaviour such as applying security or logging ,across multiple elements examples of stereotype annotations in springboot
1. @Component: This stereotype annotation is used to mark a class as a component. It is used to indicate that a class is a candidate for auto-detection by Springβs component scanning mechanism.
2. @Service: This stereotype annotation is used to mark a class as a service. It is used to indicate that a class is a business service class.
3. @Repository: This stereotype annotation is used to mark a class as a repository. It is used to indicate that a class is a data access object.
4. @Controller: This stereotype annotation is used to mark a class as a controller. It is used to indicate that a class is a web controller class.
5. @RestController: This stereotype annotation is used to mark a class as a rest controller. It is used to indicate that a class is a web rest controller class.
π1
Q13.) @ComponentScan:-it is used to detect & register components /beans as managed by Spring frameWork .
it is used to detect classes annotated with @Component , @Service ,@Repository & @Controller
@Configuration:- it is used to define bean definitions in application Context.
it is used to define beans & their properties as part of Spring Framework.
@Value :- it is used to inject literal values into fields ,methods & constructor
it is used to inject literal values in properties
@Required :- it is used to indicate the presence of a dependency for a bean .
it is used to indicate bean property must be configured in bean configuration file .
@Controller :- it is used on a class that provides web interfaces .
it is used to denote class as controller class & will
be detected automatically detected by spring framework
for Component Scan & managed as bean.
@Service :- it is used for class that contains business logic.
it is used to denote that the class is a service class
@Repository :- it is used to indicate that class is repository
it is used to mark class as DataAccess object.
it is used in combination with other annotation such as service & Component
@EnableAutoConfiguration :- automatically configuration all stereotype classes & manage springBoot entire cycle
it is used to detect classes annotated with @Component , @Service ,@Repository & @Controller
@Configuration:- it is used to define bean definitions in application Context.
it is used to define beans & their properties as part of Spring Framework.
@Value :- it is used to inject literal values into fields ,methods & constructor
it is used to inject literal values in properties
@Required :- it is used to indicate the presence of a dependency for a bean .
it is used to indicate bean property must be configured in bean configuration file .
@Controller :- it is used on a class that provides web interfaces .
it is used to denote class as controller class & will
be detected automatically detected by spring framework
for Component Scan & managed as bean.
@Service :- it is used for class that contains business logic.
it is used to denote that the class is a service class
@Repository :- it is used to indicate that class is repository
it is used to mark class as DataAccess object.
it is used in combination with other annotation such as service & Component
@EnableAutoConfiguration :- automatically configuration all stereotype classes & manage springBoot entire cycle
Q16.) Spring MVC execution flow ?
A16.)
1. User sends an HTTP Request to a web browser.
2. DispatcherServlet, receives the request and checks the web.xml file to identify the appropriate Controller.
3. The DispatcherServlet maps the request to the appropriate Controller and calls its handler methods.
4. The Controller processes the request and generates the Model or view object.
5. The view object is passed to the appropriate View Resolver.
6. The View Resolver identifies the appropriate View Component and prepares the output.
7. The DispatcherServlet passes the output to the web browser.
A16.)
1. User sends an HTTP Request to a web browser.
2. DispatcherServlet, receives the request and checks the web.xml file to identify the appropriate Controller.
3. The DispatcherServlet maps the request to the appropriate Controller and calls its handler methods.
4. The Controller processes the request and generates the Model or view object.
5. The view object is passed to the appropriate View Resolver.
6. The View Resolver identifies the appropriate View Component and prepares the output.
7. The DispatcherServlet passes the output to the web browser.
π1
how to exclude embeded tomcat server in springboot
We can exclude the embedded Tomcat server in Spring Boot by setting the spring-boot-starter-web dependency scope to provided in the pom.xml file. This will make sure that the embedded Tomcat server will not be included in the build.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
We can exclude the embedded Tomcat server in Spring Boot by setting the spring-boot-starter-web dependency scope to provided in the pom.xml file. This will make sure that the embedded Tomcat server will not be included in the build.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
Q23.) @SpringBootApplication β
** the entry point of the spring boot application is the class contains @SpringBootApplication annotation & the main method
** it automatically scans all components included in the project by using @ComponentScan annotation
Indicates a configuration of class that declares one or more @Bean method & also triggers auto-configuration & component scanning
** this is convenience annotation this is equivalent to declare @Configuration + @EnableAutoConfiguration + @componentScan .
@RequestMapping(β/β) β
It is used with class & method level in controller class & which indicates webapp http request or we can cast web-mapping of web request
@RequestBody β
In controller & in rest controller and in rest controller to write data to in the webpage body of the response in the form of String or in form of JSON object
** the entry point of the spring boot application is the class contains @SpringBootApplication annotation & the main method
** it automatically scans all components included in the project by using @ComponentScan annotation
Indicates a configuration of class that declares one or more @Bean method & also triggers auto-configuration & component scanning
** this is convenience annotation this is equivalent to declare @Configuration + @EnableAutoConfiguration + @componentScan .
@RequestMapping(β/β) β
It is used with class & method level in controller class & which indicates webapp http request or we can cast web-mapping of web request
@RequestBody β
In controller & in rest controller and in rest controller to write data to in the webpage body of the response in the form of String or in form of JSON object
π1
what is @pathvariable annotation in java
The @PathVariable annotation is used to bind a method parameter to a URI template variable. This annotation is used to extract information from the URI path and bind it to the method parameter. It is part of the Spring Web MVC framework and is used in conjunction with the @RequestMapping annotation.
The @PathVariable annotation is used to bind a method parameter to a URI template variable. This annotation is used to extract information from the URI path and bind it to the method parameter. It is part of the Spring Web MVC framework and is used in conjunction with the @RequestMapping annotation.
what is pojo poji bean model and entity in springboot
POJO (Plain Old Java Object) is a Java object that does not have any special methods or inherited classes. It is a basic object that just contains properties and getter/setter methods for accessing those properties.
A POJO bean model is an object-oriented representation of a domain model. It is an abstraction of a domain model that is used to facilitate communication between components. The POJO bean model is typically used in the service layer of an application to provide a consistent interface for different components to interact with.
An entity in Spring Boot is an object that represents a row in a database table. It is used to map the data in the database to an object-oriented model. Entities are the fundamental building blocks of any Spring Boot application. They are used to define the data model of the application and to make it easier to access the data in the database.
POJO (Plain Old Java Object) is a Java object that does not have any special methods or inherited classes. It is a basic object that just contains properties and getter/setter methods for accessing those properties.
A POJO bean model is an object-oriented representation of a domain model. It is an abstraction of a domain model that is used to facilitate communication between components. The POJO bean model is typically used in the service layer of an application to provide a consistent interface for different components to interact with.
An entity in Spring Boot is an object that represents a row in a database table. It is used to map the data in the database to an object-oriented model. Entities are the fundamental building blocks of any Spring Boot application. They are used to define the data model of the application and to make it easier to access the data in the database.
Java Hyd Team
HOW MANY OF YOU WANNA LEARN PYTHON AS MOST OF US ARE FREE NOW
From Monday we have a tutor for this
REST APIs: The foundation of modern web development
As a software engineer, I have always been passionate about sharing my knowledge and helping others to understand complex technical concepts. That's why I was so excited to create this small presentation on REST API.
For those who may not know, a REST API (which stands for Representational State Transfer API) is a way for different software systems to communicate with each other through the internet.
It's a crucial component of modern software development, and something that every aspiring developer should understand.
Imagine you're trying to book a flight online. When you search for flights and enter your preferences, the website sends a request to the airline's computer system to find available flights that match your criteria. The airline's system then sends a response back to the website with the available flights, and you can choose one to book. This interaction between the website and the airline's system is made possible through a REST API.
There are five main methods used in a REST API:
GET - retrieves a specific resource or collection of resources
POST - creates a new resource
PUT - updates an existing resource
DELETE - removes a specific resource
PATCH - partially updates an existing resource
The response from a REST API can either be a success or an error. A success response typically includes the requested information or a message confirming that the requested action was completed. An error response includes a message explaining why the request could not be completed.
Overall, a REST API is a crucial tool for allowing different software systems to communicate with each other and exchange information seamlessly.
If you're working with software systems or just want to understand how different websites and apps work together, it's important to understand the basics of REST APIs.
I know firsthand how confusing and overwhelming it can be to learn about new technologies, especially when you're just starting out in the field. That's why I wanted to create this presentation - to provide a clear, concise, and easy-to-understand explanation of what a REST API is and how it works.
I hope that this presentation will be helpful to those who are new to software development, or who are simply looking to learn more about APIs. And I plan to keep creating more such documents in the future, so that all the needy and new enthusiasts out there can benefit from my knowledge and experience.
So if you're interested in learning more about APIs, or if you have any questions or feedback about this presentation, please don't hesitate to reach out. I'm always happy to help, and I'm committed to doing my part to make the world of software development more accessible and understandable to everyone.
π If you like my posts, please follow https://www.linkedin.com/in/aman-raj-6168b616a πΊπΈ ππ and hit the π on my profile to get a notification for all my new posts.
#programming #coding #softwareengineering
As a software engineer, I have always been passionate about sharing my knowledge and helping others to understand complex technical concepts. That's why I was so excited to create this small presentation on REST API.
For those who may not know, a REST API (which stands for Representational State Transfer API) is a way for different software systems to communicate with each other through the internet.
It's a crucial component of modern software development, and something that every aspiring developer should understand.
Imagine you're trying to book a flight online. When you search for flights and enter your preferences, the website sends a request to the airline's computer system to find available flights that match your criteria. The airline's system then sends a response back to the website with the available flights, and you can choose one to book. This interaction between the website and the airline's system is made possible through a REST API.
There are five main methods used in a REST API:
GET - retrieves a specific resource or collection of resources
POST - creates a new resource
PUT - updates an existing resource
DELETE - removes a specific resource
PATCH - partially updates an existing resource
The response from a REST API can either be a success or an error. A success response typically includes the requested information or a message confirming that the requested action was completed. An error response includes a message explaining why the request could not be completed.
Overall, a REST API is a crucial tool for allowing different software systems to communicate with each other and exchange information seamlessly.
If you're working with software systems or just want to understand how different websites and apps work together, it's important to understand the basics of REST APIs.
I know firsthand how confusing and overwhelming it can be to learn about new technologies, especially when you're just starting out in the field. That's why I wanted to create this presentation - to provide a clear, concise, and easy-to-understand explanation of what a REST API is and how it works.
I hope that this presentation will be helpful to those who are new to software development, or who are simply looking to learn more about APIs. And I plan to keep creating more such documents in the future, so that all the needy and new enthusiasts out there can benefit from my knowledge and experience.
So if you're interested in learning more about APIs, or if you have any questions or feedback about this presentation, please don't hesitate to reach out. I'm always happy to help, and I'm committed to doing my part to make the world of software development more accessible and understandable to everyone.
π If you like my posts, please follow https://www.linkedin.com/in/aman-raj-6168b616a πΊπΈ ππ and hit the π on my profile to get a notification for all my new posts.
#programming #coding #softwareengineering