Lecture 25 Demo: What Spring IoC + DI Actually Changes

Interactive simulation of bean definition, container wiring, dependency injection, and implementation swap without changing service code.

1) Configure the Container

Selected bean metadata:

Bean: paymentGateway Type: PaymentGateway Impl: UpiGateway Scope: singleton
class OrderService { private final PaymentGateway gateway; OrderService(PaymentGateway gateway) { this.gateway = gateway; } void placeOrder() { gateway.pay(); } }

2) IoC Container Trace

No actions yet. Click "Boot IoC Container" first.

3) Bean Registry Snapshot

Bean Name Type Implementation Scope Status
paymentGateway PaymentGateway UpiGateway singleton not created
orderService OrderService OrderService(PaymentGateway) singleton not created

4) Mapping to Lecture Points

  1. Bean definition: metadata describing class, type, scope, and wiring.
  2. IoC: container owns object creation instead of business classes.
  3. DI: dependencies are injected into constructors/setters.
  4. Loose coupling: switch implementation in config, keep service code unchanged.
  5. Testing benefit: inject mock/stub bean without editing business logic.

Try sequence: Boot with UpiGateway -> Run service -> switch to CardGateway -> Run again -> choose MockGateway and run test scenario.