Documentation
¶
Index ¶
- Constants
- type ArgContext
- func (a *ArgContext) Bind(v reflect.Value, tag string) error
- func (a *ArgContext) Check(c gs.Condition) (bool, error)
- func (a *ArgContext) Find(beanID gs.BeanID) ([]gs.ConditionBean, error)
- func (a *ArgContext) Has(key string) bool
- func (a *ArgContext) Prop(key string) (string, bool)
- func (a *ArgContext) Wire(v reflect.Value, tag string) error
- type Injecting
- type InjectionError
- type Injector
- type LazyField
- type Stack
- type WireTag
Constants ¶
const ( RefreshDefault = refreshState(iota) // Not refreshed yet Refreshing // Currently refreshing Refreshed // Successfully refreshed )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgContext ¶
type ArgContext struct {
// contains filtered or unexported fields
}
ArgContext provides runtime context when calling bean factory functions. It exposes access to configuration properties, bean lookups, condition checks, and allows wiring of parameters during construction.
func NewArgContext ¶
func NewArgContext(c *Injector, stack *Stack) *ArgContext
NewArgContext constructs a new ArgContext for a wiring operation.
func (*ArgContext) Bind ¶
func (a *ArgContext) Bind(v reflect.Value, tag string) error
Bind binds configuration data into the provided reflect.Value based on the given struct tag.
func (*ArgContext) Check ¶
func (a *ArgContext) Check(c gs.Condition) (bool, error)
Check evaluates a condition against the current ArgContext.
func (*ArgContext) Find ¶
func (a *ArgContext) Find(beanID gs.BeanID) ([]gs.ConditionBean, error)
Find retrieves beans matching the given selector.
func (*ArgContext) Has ¶
func (a *ArgContext) Has(key string) bool
Has checks whether a configuration key is present.
type Injecting ¶
type Injecting struct {
// contains filtered or unexported fields
}
Injecting is the core IoC container component. It handles bean creation, dependency injection, lifecycle management, dynamic property updates, and destroy callbacks.
func (*Injecting) Close ¶
func (c *Injecting) Close()
Close shuts down the container by invoking all registered destroyer callbacks. The destroyers are executed in reverse order respecting dependency relationships, ensuring that beans are destroyed after the beans they depend on. Any errors returned from destroy methods are logged but do not stop the shutdown process.
func (*Injecting) DynamicObjectsCount ¶ added in v1.3.0
DynamicObjectsCount returns the number of objects that can be dynamically refreshed.
func (*Injecting) Refresh ¶
func (c *Injecting) Refresh(roots, beans []*gs_bean.BeanDefinition) (err error)
Refresh wires all provided beans and prepares them for use. It performs the following operations:
- Builds indexes for bean lookup by name and type (by name and by type).
- Wires all root beans (entry points of the dependency graph), recursively wiring dependencies.
- Handles fields tagged with ',lazy' for deferred injection. Note: lazy wiring only applies to explicitly marked fields and does not resolve arbitrary circular dependencies.
- Registers destroyer callbacks for beans in dependency-safe order.
- Cleans up metadata.
Behavior is influenced by properties: - spring.allow-circular-references: whether lazy circular references are allowed. - spring.force-autowire-is-nullable: whether missing dependencies are treated as nullable.
type InjectionError ¶ added in v1.3.0
type InjectionError struct {
// contains filtered or unexported fields
}
InjectionError wraps an injection failure at a specific field path.
func (*InjectionError) Error ¶ added in v1.3.0
func (e *InjectionError) Error() string
Error formats the error with the field path and the root error.
func (*InjectionError) Path ¶ added in v1.3.0
func (e *InjectionError) Path() string
Path returns the full field path where injection failed.
func (*InjectionError) Unwrap ¶ added in v1.3.0
func (e *InjectionError) Unwrap() error
Unwrap returns the root error.
type Injector ¶
type Injector struct {
// contains filtered or unexported fields
}
Injector performs core dependency injection and bean lifecycle management. Responsibilities include: - Constructor invocation and creation of bean values. - Field injection and wiring of struct dependencies. - Initialization callbacks execution. - Bean status management (creating, created, wired). - Lazy field handling and circular dependency detection. - Respecting forceAutowireIsNullable flag to treat missing dependencies as optional.
type LazyField ¶
type LazyField struct {
// contains filtered or unexported fields
}
LazyField represents a field in a struct that should be injected lazily.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents the runtime context during bean wiring. It keeps track of the current wiring call stack, lazily injected fields, and the ordering of destroyers for proper shutdown.