di/injection/annotation/component.go

27 lines
670 B
Go
Raw Normal View History

2018-03-15 13:19:44 +00:00
package annotation
// @Inject(name? string)
import (
"reflect"
"git.loafle.net/commons_go/di"
cda "git.loafle.net/commons_go/di/annotation"
)
const (
ComponentTag = "@Component"
)
func init() {
cda.RegisterAnnotation(ComponentTag, reflect.TypeOf((*Component)(nil)))
}
type Component struct {
cda.Annotation
Name string `annotation-meta:"name"`
InitMethod string `annotation-meta:"initMethod"` // func (receiver interface{}, cr ComponentRegistry) error
DestroyMethod string `annotation-meta:"destroyMethod"` // func (receiver interface{}, cr ComponentRegistry) error
Scope di.ScopeType `annotation-meta:"scope"`
}