Skip to content

sharmaaman088/PRAC-Spring-6-AOP-Spring-MVC-Spring-Boot-3-Thymeleaf-Spring-Security-6-Spring-JDBC-JPA-REST

Repository files navigation

@Configuration This means the class contains methods that define beans (components) for a Spring application. @Configuration is like a recipe book that tells how to prepare different dishes. The methods inside the class (annotated with @Bean) are like individual recipes. Spring reads this recipe book and prepares the required beans (ingredients/components) for the application.

@configuration class has bean annotation method

@Configuration → Marks a class as a Spring configuration. @Bean → Defines a Spring-managed object. Spring scans this class and creates beans for use in the application. Spring sees @Configuration → It knows this class contains beans. @Configuration is an annotation used to indicate that a class contains bean definitions and is a source of configuration for the application context.

@Component - Another way to declare a bean is to mark a class with a @Component annotation. Doing this turns the class into a Spring bean at the auto-scan time.

@Autowired as an automatic plug that connects parts of your code without you manually creating objects.Imagine a lamp that needs electricity to work. Normally, you would:

Find a power source (electricity).
Manually plug in the lamp.

With @Autowired, it's like the lamp automatically connects to electricity without you doing anything!

From 50

Aspect-Oriented Programming (AOP) a way to separate cross-cutting concerns (like logging, security, or transaction management) from the main business logic. Instead of writing repetitive code in multiple places, AOP allows you to define these concerns once and apply them where needed.

Make the coffee (Main business logic). Print a receipt (Logging). Charge the customer (Security/transaction).

Instead of adding steps 2 and 3 in every coffee-making process, AOP lets you define them separately and apply them automatically whenever needed.

LoggerAspect class monitors and logs when methods start, end, how long they take to execute, if they fail, and what they return.

@Aspect and @Component

These tell Spring that this class contains special "Aspect" (AOP-related) code. It will automatically apply logging to the relevant parts of the program.

(VehicleStartCheckAspect) that applies a pre-condition check before executing methods in the com.example.services package.

@Order(1): Sets the execution order of aspects (if multiple aspects exist). Lower numbers run first.

Logger from Java's built-in java.util.logging package to log messages for the VehicleServices

About

EasyBytesSelfPractice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages