2019-11-13 14:01:03 +00:00
|
|
|
package di
|
2019-11-13 13:34:36 +00:00
|
|
|
|
|
|
|
// @Inject(name? string)
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"git.loafle.net/loafer/annotation-go"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-11-13 14:08:33 +00:00
|
|
|
if err := annotation.Register(ComponentAnnotationType); nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := annotation.Register(InjectAnnotationType); nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := annotation.Register(ResourceAnnotationType); nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-11-13 13:34:36 +00:00
|
|
|
}
|
|
|
|
|
2019-11-13 14:01:03 +00:00
|
|
|
var ComponentAnnotationType = reflect.TypeOf((*ComponentAnnotation)(nil))
|
|
|
|
|
2019-11-13 13:34:36 +00:00
|
|
|
type ComponentAnnotation struct {
|
|
|
|
annotation.TypeAnnotation `@annotation:"@Component"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
InitMethod string `json:"initMethod"` // func (receiver interface{}, cr ComponentRegistry) error
|
|
|
|
DestroyMethod string `json:"destroyMethod"` // func (receiver interface{}, cr ComponentRegistry) error
|
|
|
|
}
|
2019-11-13 14:01:03 +00:00
|
|
|
|
|
|
|
var InjectAnnotationType = reflect.TypeOf((*InjectAnnotation)(nil))
|
|
|
|
|
|
|
|
type InjectAnnotation struct {
|
|
|
|
annotation.TypeAnnotation `@annotation:"@Inject"`
|
|
|
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
}
|
|
|
|
|
|
|
|
var ResourceAnnotationType = reflect.TypeOf((*ResourceAnnotation)(nil))
|
|
|
|
|
|
|
|
type ResourceAnnotation struct {
|
|
|
|
annotation.TypeAnnotation `@annotation:"@Resource"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
}
|