Container, Dependency and IoC Flashcards
What is Dependency Injection
A process whereby a framework establishes relationships between different parts of an application.
What are advantages of dependency injection
- Reduced coupling, cohesion, boilerplate code
- Increases testability, reusability, maintainability
What is an interface
Is a reference type, can contain constants, method signatures, default/static methods
Advantages of an interface
- Allows for decoupling, modularization, handling of groups of objects
Why are Interfaxes recommended by Spring
- Increased Testability
- Allows for Jdk Proxying
- Easier switching of Spring bean implementation
Stereotype Annotations
@Component @Controller @RestController @Repository @Service @Configuration
Bean scopes
singleton - Single Bean instance prototype - Each Time an instance is created request session application websocket
Limitations of JDK Dynamic Proxies
- requires proxied object to implement at least one interface
- only methods found the interface are available in the proxy
- does not support self invocations
Limitations of CGLIB Proxies
- Proxied object non final
- Methods in proxied object non final
- Does not support self invocations
- Third-party library
Advantage Proxy object
- Can add power to existing beans
- Separation to business logic
Disadvantages Proxy Object
- Not obvious where a method invocation is handled when proxy objects are used
- Multiple layers of proxy objects -> developers need to take into account the order
- Overhead
- Identity issues
Three Typical Cross Cutting Concerns
- Logging
- Caching
- Security
- Data Validation
- Transaction management
- Error handling
- Monitoring
Which problems does AOP solve
- Code duplication
- Avoding mixing of concerns
Join Point
A join point is a point in the execution of a program at which additional behavior can be inserted using AOP
Pointcut
A pointcut selects one or more join points