-
Notifications
You must be signed in to change notification settings - Fork 0
/
def.go
84 lines (70 loc) · 2.89 KB
/
def.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package container
import (
"github.com/go-kid/ioc/component_definition"
"github.com/go-kid/ioc/configure"
)
type SingletonRegistry interface {
RegisterSingleton(singleton any)
GetSingleton(name string) (any, error)
ContainsSingleton(name string) bool
GetSingletonNames() []string
GetSingletonCount() int
}
type DefinitionRegistry interface {
RegisterMeta(m *component_definition.Meta)
GetMetas(opts ...Option) []*component_definition.Meta
GetMetaByName(name string) *component_definition.Meta
GetMetaOrRegister(name string, component any) *component_definition.Meta
}
type SingletonComponentRegistry interface {
AddSingleton(name string, meta *component_definition.Meta)
AddSingletonFactory(name string, method SingletonFactory)
GetSingleton(name string, allowEarlyReference bool) (*component_definition.Meta, error)
RemoveSingleton(name string)
GetSingletonOrCreateByFactory(name string, factory SingletonFactory) (*component_definition.Meta, error)
IsSingletonCurrentlyInCreation(name string) bool
}
type SingletonFactory interface {
GetComponent() (*component_definition.Meta, error)
}
type FuncSingletonFactory func() (*component_definition.Meta, error)
func (d FuncSingletonFactory) GetComponent() (*component_definition.Meta, error) {
return d()
}
type Factory interface {
GetRegisteredComponents() map[string]any
GetDefinitionRegistryPostProcessors() []DefinitionRegistryPostProcessor
SetRegistry(r SingletonRegistry)
SetConfigure(c configure.Configure)
PrepareComponents() error
Refresh() error
GetComponents(opts ...Option) ([]any, error)
GetComponentByName(name string) (any, error)
GetConfigure() configure.Configure
GetDefinitionRegistry() DefinitionRegistry
}
type ComponentFactoryPostProcessor interface {
PostProcessComponentFactory(factory Factory) error
}
type DefinitionRegistryPostProcessor interface {
PostProcessDefinitionRegistry(registry DefinitionRegistry, component any, componentName string) error
}
type ComponentPostProcessor interface {
PostProcessBeforeInitialization(component any, componentName string) (any, error)
PostProcessAfterInitialization(component any, componentName string) (any, error)
}
type InstantiationAwareComponentPostProcessor interface {
ComponentPostProcessor
PostProcessBeforeInstantiation(m *component_definition.Meta, componentName string) (any, error)
PostProcessAfterInstantiation(component any, componentName string) (bool, error)
PostProcessProperties(properties []*component_definition.Property, component any, componentName string) ([]*component_definition.Property, error)
}
type SmartInstantiationAwareBeanPostProcessor interface {
InstantiationAwareComponentPostProcessor
GetEarlyBeanReference(component any, componentName string) (any, error)
}
type DestructionAwareComponentPostProcessor interface {
ComponentPostProcessor
PostProcessBeforeDestruction(component any, componentName string) error
RequireDestruction(component any) bool
}