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
How does Spring solve a cross cutting concern
Spring uses proxy objects to implement the method invocation interception part of AOP.
How many advice types does Spring support
- Before advice
- After returning advice
- After throwing advice
- After advice
- Around advice
Jdbc Template
Is a Spring class that simplifies the use of JDBC by implementing Workflows for querying, updating, ..
Benefits of the JDBC Template
- Simplification
- Handles Exceptions
- Translates Exceptions
- Avoid common mistakes
Callback
A callback is code or reference to a piece of code that is passed as an argument to a method that, at some point during the execution of the methods, will call the code passed as an argument.
Transaction
A transaction is an operation that consists of a number of tasks that takes place as a single unit - either all tasks are performed or no tasks are performed.
ACID principle
- Atomicity
- The changes within a
transaction are either all
applied or none applied
- The changes within a
- Consistency
- Any integrity constraints are not violated
- Isolation
- Translations don’t effect each other
- Durability
- Changes applied as the result of a
successfully completed transaction are
durable
- Changes applied as the result of a
Transaction isolation level
Determine how the changes within a transaction are visible to other users and systems accessing the database prior to the transaction being commited.