Spring Learnings
Monday, August 24, 2020
Spring - AutoWiring
Sunday, August 23, 2020
Spring - The IoC Container
There are two types of IoC containers:
Spring Boot - Asynchronus Messaging (AMPQ)
Spring - Boot - Data
Spring Data provides rich support for RDBMS and NoSQL databases.
Certain databases like H2/HSQLDB autoconfigure an embedded database
Leverage common scripts to prime embedded database
Saturday, August 22, 2020
Spring - Boot
Spring - Aspects
Spring Aspects are blocks of code that can be injected into the application at runtime
example logging, transaction management, caching, security.
- Spring uses AspectJ (byte code modification - run time interweaving) for aspecting.
Parts of spring Aspect
- Aspect - a class that implements enterprise application concerns that cut across multiple classes. Aspects can be a normal class configured through Spring XML configuration or we can use Spring AspectJ integration to define a class as Aspect using @Aspect annotation.
- Join Point - the place or specific point in the application code flow where the aspect code will be applied
- Point Cut - a selection criteria to select the 'Join Point' to apply the aspect code.
- Advice - The advice is the aspect class method that will be applied at the 'Join Point' selected by the 'Point Cut'
Point Cut:
Syntax: designator("r p.c.m(arg)")
r- return type
p- package
c-class
m-method
arg-arguments
designator-there are several designators provided by spring which can be used to implement an aspect.
e.g. execution - for matching method execution
within-for matching within certain types
target-for matching a specific type
@annotation-for matching a specific annotation
Wednesday, August 19, 2020
Spring Lifecycle
The three phases of lifecycle:
1. Initialization
- begins when the application context is created.
- can be broken down in to further two phases
a) BeanFactory Initialization
b) Bean Initialization and Instantiation
2. Use
3. Destruction
- begins when close is called on the application context.
Some examples of lifecycle methods:
@PostConstruct
a method which should be executed after construction of the object.
@PreDestroy
a method which should be called before marking the object for garbage collection.
Spring - AutoWiring
Spring automatically resolves the dependencies between the collaborating beans by inspecting the contents of the BeanFactory. This is called...
-
The three phases of lifecycle: 1. Initialization - begins when the application context is created. - can be broken down in to fu...
-
Asynchronus messaging can reduce strain on the system Spring uses RabbitMQ which is efficient for sending and receiving asynchronous message...
-
Spring Data provides rich support for RDBMS and NoSQL databases. Certain databases like H2/HSQLDB autoconfigure an embedded database Leverag...