Introduction
We know that IOC
(Inversion of Control) is an effective architectural design for system decoupling, and is also a supporting tool for the development of large-scale business systems
IOC Containers
There are two types of ioc containers in Vona:
global ioc container
(referred to as app container): During system initialization, a unique global bean container will be automatically created. Bean instances created in this container are all singleton moderequest ioc container
(referred to as ctx container): When requests coming, the system will create a bean container for each of them
Bean Class
Vona adopts a modular system, and Bean Classes are provided by different modules. When using the Bean Class inside the same module, you can directly resolve it based on Class type
. When using cross-module, you can resolve it based on Bean identifier
instead of Class type/file path
, which is conducive to achieving loose coupling between modules
Injection Scope
Vona provides the following injection scopes:
app
: Inject in the app containerctx
: Inject in the ctx containernew
: Always create a new bean instance
Injection method
Vona provides two injection methods:
Dependency injection
: Provides attribute-based dependency injection through the@Use
decoratorDependency lookup
: Directly lookup the required bean instance through the ioc container, and automatically create it if it does not exist