SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
Presented By: Jitendra Kr. Singh
Sr. Lead Consultant
Knoldus Inc
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Respect Knolx session timings, you
are requested not to join sessions
after a 5 minutes threshold post
the session start time.
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Silent Mode
Keep your screen on mute, in case
you have question ask and mute
again.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
Our Agenda
What is Servlet?
Servlets are the Java programs that runs on the Java-enabled web server or application server.
Servlet is an interface, They are used to handle the request obtained from the web server,
process the request, produce the response, then send response back to the web server.
init() service() destroy()
public abstract class GenericServlet extends Object implements Servlet, ServletConfig,Serializable
abstract void service(ServletRequest req, ServletResponse res)
public abstract class HttpServlet extends GenericServlet implements java.io.Serializable
doGet(HttpServletRequest req, HttpServletResponse resp)
doPost(HttpServletRequest req, HttpServletResponse resp)
doPut(HttpServletRequest req, HttpServletResponse resp)
doDelete(HttpServletRequest req, HttpServletResponse resp)
Lifecycle of a Servlet:
What is Filter?
A Filter is an object that is invoked at the preprocessing and postprocessing of a request.
It is mainly used to perform filtering tasks such as conversion, logging, compression,
encryption and decryption, input validation etc.
init() doFilter() destroy()
Lifecycle of a Filter:
Filter 1 Filter 2 Servlet
Request
Response
Request and Response Flow:
Configuring Filter and Servlet
Spring Framework
The Spring Framework is an application framework and inversion of control container for the Java
platform.
The framework's core features can be used by any Java application, but there are extensions for
building web applications on top of the Java EE (Enterprise Edition) platform.
Inversion of Control is a programming pattern to achieve loose coupling where the independent
objects don't responsible for their dependencies. The Spring Inversion of Control container is the heart
of the Spring Framework. The IoC container receives metadata from either an XML file, Java
annotations, or Java code.
Spring Base Servlets
HttpServletBean
FrameworkServlet
DispatcherServlet
HttpServlet
● This servlet leaves request handling to subclasses, inheriting the default
behavior of HttpServlet (doGet, doPost, etc).
● Provides servlets that integrate with the application context infrastructure
● Mapping an HTTP request to a certain processing method.
● parsing of HTTP request data and headers into data transfer objects
● model-view-controller interaction.
● Generation of responses from DTOs
● Manages a WebApplicationContext instance per servlet.
● Publishes events on request processing, whether or not a request is successfully
handled
Spring Base Filters
DelegatingFilterProxy
FilterChainProxy
UsernamePasswordAuthenticationFilter
SecurityContextHolderAwareRequestFilter
ExceptionTranslationFilter
FilterSecurityInterceptor
Delegate the Filter's methods through to a bean which is obtained from the Spring application
context. This enables the bean to benefit from the Spring web application context lifecycle
support and configuration flexibility
FilterChainProxy guarantees to only initialize and destroy each Filter bean once, no matter
how many times it is declared in the filter chain(s).
Authentication processing mechanisms
Allows the user to determine if they are authenticated and if not send the user to the login page
To catch any Spring Security exceptions so that either an HTTP error response can be
returned or an appropriate AuthenticationEntryPoint can be launched
To protect web URIs and raise exceptions when access is denied
Aware Interfaces
Sometimes we might require access to framework objects, such as ApplicationContext,
BeanFactory, and ResourceLoader . To gain access, a bean can implement one of the many Aware
interfaces of the Spring Framework.
When a bean implements an Aware interface, the Spring Framework injects a particular framework
object to the bean through a callback-style method
For example, if the bean implements the ApplicationContextAware interface, Spring will inject an
ApplicationContext object in to the bean
In the bean lifecycle, the Spring Framework calls the aware interface methods after populating bean
properties and just before pre initialization
List of Aware Interfaces
ApplicationContextAware
ApplicationEventPublisherAware
ApplicationEventPublisherAware
ApplicationStartupAware
BeanClassLoaderAware
BeanFactoryAware
BootstrapContextAware
MessageSourceAware
EmbeddedValueResolverAware
EnvironmentAware
ImportAware
LoadTimeWeaverAware
NotificationPublisherAware
ResourceLoaderAware
SchedulerContextAware
ServletConfigAware
ServletContextAware
Bean Lifecycle : Extended
Instantiate
Call the setBeanFactory of
BeanFactoryAware
Next Aware Interface……..
Populate Properties
Call the setApplicationContext of
ApplicationContextAware
Pre-initialization by postProcessor()
of bean
Call setBeanName of
BeanNameAware
Next Aware Interface
afterPropertiesSet() of bean
Custom Init Method Post Initialization
BeanPostProcessors
Bean Ready To Use
Demo
In Demo I have created an application which we will run in debug mode and will see all the above
classes in debug stack.
Demo application is a Spring Boot application with Spring Security.
https://www.javatpoint.com/servlet-filter
https://www.geeksforgeeks.org/introduction-to-spring-framework/
https://en.wikipedia.org/wiki/Spring_Framework
https://springframework.guru/using-spring-aware-interfaces/
Contact us at:
hello@knoldus.com
Connect with me:
https://www.linkedin.com/in/jitendra-singh-9b522134/

Más contenido relacionado

La actualidad más candente

Dissecting Java Server Faces for Penetration Testing
Dissecting Java Server Faces for Penetration Testing Dissecting Java Server Faces for Penetration Testing
Dissecting Java Server Faces for Penetration Testing
Aditya K Sood
 
Automated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS SitesAutomated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS Sites
joelabrahamsson
 

La actualidad más candente (20)

Javacro 2014 Spring Security 3 Speech
Javacro 2014 Spring Security 3 SpeechJavacro 2014 Spring Security 3 Speech
Javacro 2014 Spring Security 3 Speech
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
 
Sprint Portlet MVC Seminar
Sprint Portlet MVC SeminarSprint Portlet MVC Seminar
Sprint Portlet MVC Seminar
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 
Spring Security
Spring SecuritySpring Security
Spring Security
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 9...
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
 
Authentication in microservice systems - fsto 2017
Authentication in microservice systems - fsto 2017Authentication in microservice systems - fsto 2017
Authentication in microservice systems - fsto 2017
 
Spring security
Spring securitySpring security
Spring security
 
Spring Security 3
Spring Security 3Spring Security 3
Spring Security 3
 
Java Spring
Java SpringJava Spring
Java Spring
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
How to customize Spring Boot?
How to customize Spring Boot?How to customize Spring Boot?
How to customize Spring Boot?
 
Security Patterns for Microservice Architectures - ADTMag Microservices & API...
Security Patterns for Microservice Architectures - ADTMag Microservices & API...Security Patterns for Microservice Architectures - ADTMag Microservices & API...
Security Patterns for Microservice Architectures - ADTMag Microservices & API...
 
Dissecting Java Server Faces for Penetration Testing
Dissecting Java Server Faces for Penetration Testing Dissecting Java Server Faces for Penetration Testing
Dissecting Java Server Faces for Penetration Testing
 
Spring diy projects
Spring diy projectsSpring diy projects
Spring diy projects
 
Automated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS SitesAutomated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS Sites
 

Similar a Servlet to Spring: Internal Understanding

Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packages
vamsi krishna
 
eSobi Website Multilayered Architecture
eSobi Website Multilayered ArchitectureeSobi Website Multilayered Architecture
eSobi Website Multilayered Architecture
Allan Huang
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
NourhanTarek23
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
Jafar Nesargi
 

Similar a Servlet to Spring: Internal Understanding (20)

P20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxP20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptx
 
Spring 1 day program
Spring 1 day programSpring 1 day program
Spring 1 day program
 
Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packages
 
Liit tyit sem 5 enterprise java unit 1 notes 2018
Liit tyit sem 5 enterprise java  unit 1 notes 2018 Liit tyit sem 5 enterprise java  unit 1 notes 2018
Liit tyit sem 5 enterprise java unit 1 notes 2018
 
Java J2EE Interview Question Part 2
Java J2EE Interview Question Part 2Java J2EE Interview Question Part 2
Java J2EE Interview Question Part 2
 
Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2Java J2EE Interview Questions Part 2
Java J2EE Interview Questions Part 2
 
eSobi Website Multilayered Architecture
eSobi Website Multilayered ArchitectureeSobi Website Multilayered Architecture
eSobi Website Multilayered Architecture
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
TY.BSc.IT Java QB U3
TY.BSc.IT Java QB U3TY.BSc.IT Java QB U3
TY.BSc.IT Java QB U3
 
J2ee servlet
J2ee servletJ2ee servlet
J2ee servlet
 
Struts Interceptors
Struts InterceptorsStruts Interceptors
Struts Interceptors
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Azure in Developer Perspective
Azure in Developer PerspectiveAzure in Developer Perspective
Azure in Developer Perspective
 
J servlets
J servletsJ servlets
J servlets
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Chap4 4 1
Chap4 4 1Chap4 4 1
Chap4 4 1
 
Enterprice java
Enterprice javaEnterprice java
Enterprice java
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
selenium-webdriver-interview-questions.pdf
selenium-webdriver-interview-questions.pdfselenium-webdriver-interview-questions.pdf
selenium-webdriver-interview-questions.pdf
 

Más de Knoldus Inc.

Más de Knoldus Inc. (20)

Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable Testing
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose Kubernetes
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptx
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptx
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptx
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptx
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake Presentation
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics Presentation
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIs
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II Presentation
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Servlet to Spring: Internal Understanding

  • 1. Presented By: Jitendra Kr. Singh Sr. Lead Consultant Knoldus Inc
  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Respect Knolx session timings, you are requested not to join sessions after a 5 minutes threshold post the session start time. Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Silent Mode Keep your screen on mute, in case you have question ask and mute again. Avoid Disturbance Avoid unwanted chit chat during the session.
  • 4. What is Servlet? Servlets are the Java programs that runs on the Java-enabled web server or application server. Servlet is an interface, They are used to handle the request obtained from the web server, process the request, produce the response, then send response back to the web server. init() service() destroy() public abstract class GenericServlet extends Object implements Servlet, ServletConfig,Serializable abstract void service(ServletRequest req, ServletResponse res) public abstract class HttpServlet extends GenericServlet implements java.io.Serializable doGet(HttpServletRequest req, HttpServletResponse resp) doPost(HttpServletRequest req, HttpServletResponse resp) doPut(HttpServletRequest req, HttpServletResponse resp) doDelete(HttpServletRequest req, HttpServletResponse resp) Lifecycle of a Servlet:
  • 5. What is Filter? A Filter is an object that is invoked at the preprocessing and postprocessing of a request. It is mainly used to perform filtering tasks such as conversion, logging, compression, encryption and decryption, input validation etc. init() doFilter() destroy() Lifecycle of a Filter: Filter 1 Filter 2 Servlet Request Response Request and Response Flow:
  • 7. Spring Framework The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE (Enterprise Edition) platform. Inversion of Control is a programming pattern to achieve loose coupling where the independent objects don't responsible for their dependencies. The Spring Inversion of Control container is the heart of the Spring Framework. The IoC container receives metadata from either an XML file, Java annotations, or Java code.
  • 8. Spring Base Servlets HttpServletBean FrameworkServlet DispatcherServlet HttpServlet ● This servlet leaves request handling to subclasses, inheriting the default behavior of HttpServlet (doGet, doPost, etc). ● Provides servlets that integrate with the application context infrastructure ● Mapping an HTTP request to a certain processing method. ● parsing of HTTP request data and headers into data transfer objects ● model-view-controller interaction. ● Generation of responses from DTOs ● Manages a WebApplicationContext instance per servlet. ● Publishes events on request processing, whether or not a request is successfully handled
  • 9. Spring Base Filters DelegatingFilterProxy FilterChainProxy UsernamePasswordAuthenticationFilter SecurityContextHolderAwareRequestFilter ExceptionTranslationFilter FilterSecurityInterceptor Delegate the Filter's methods through to a bean which is obtained from the Spring application context. This enables the bean to benefit from the Spring web application context lifecycle support and configuration flexibility FilterChainProxy guarantees to only initialize and destroy each Filter bean once, no matter how many times it is declared in the filter chain(s). Authentication processing mechanisms Allows the user to determine if they are authenticated and if not send the user to the login page To catch any Spring Security exceptions so that either an HTTP error response can be returned or an appropriate AuthenticationEntryPoint can be launched To protect web URIs and raise exceptions when access is denied
  • 10. Aware Interfaces Sometimes we might require access to framework objects, such as ApplicationContext, BeanFactory, and ResourceLoader . To gain access, a bean can implement one of the many Aware interfaces of the Spring Framework. When a bean implements an Aware interface, the Spring Framework injects a particular framework object to the bean through a callback-style method For example, if the bean implements the ApplicationContextAware interface, Spring will inject an ApplicationContext object in to the bean In the bean lifecycle, the Spring Framework calls the aware interface methods after populating bean properties and just before pre initialization
  • 11. List of Aware Interfaces ApplicationContextAware ApplicationEventPublisherAware ApplicationEventPublisherAware ApplicationStartupAware BeanClassLoaderAware BeanFactoryAware BootstrapContextAware MessageSourceAware EmbeddedValueResolverAware EnvironmentAware ImportAware LoadTimeWeaverAware NotificationPublisherAware ResourceLoaderAware SchedulerContextAware ServletConfigAware ServletContextAware
  • 12. Bean Lifecycle : Extended Instantiate Call the setBeanFactory of BeanFactoryAware Next Aware Interface…….. Populate Properties Call the setApplicationContext of ApplicationContextAware Pre-initialization by postProcessor() of bean Call setBeanName of BeanNameAware Next Aware Interface afterPropertiesSet() of bean Custom Init Method Post Initialization BeanPostProcessors Bean Ready To Use
  • 13. Demo In Demo I have created an application which we will run in debug mode and will see all the above classes in debug stack. Demo application is a Spring Boot application with Spring Security.
  • 15.
  • 16. Contact us at: hello@knoldus.com Connect with me: https://www.linkedin.com/in/jitendra-singh-9b522134/