2017-12-05 10:02:41 +00:00
|
|
|
package annotation
|
|
|
|
|
2017-12-06 06:07:44 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
)
|
2017-12-05 13:28:42 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
ResourceTag = "@Resource"
|
|
|
|
)
|
|
|
|
|
2017-12-06 06:07:44 +00:00
|
|
|
func init() {
|
|
|
|
registerAnnotation(ResourceTag, reflect.TypeOf((*Resource)(nil)))
|
|
|
|
}
|
|
|
|
|
2017-12-05 10:02:41 +00:00
|
|
|
type Resource struct {
|
2017-12-05 13:28:42 +00:00
|
|
|
Annotation
|
2017-12-05 10:02:41 +00:00
|
|
|
Name string
|
|
|
|
}
|
2017-12-05 13:28:42 +00:00
|
|
|
|
2017-12-06 06:07:44 +00:00
|
|
|
func (a *Resource) parseAttribute(attributes map[string]string) error {
|
|
|
|
for k, v := range attributes {
|
2017-12-05 13:28:42 +00:00
|
|
|
switch k {
|
|
|
|
case "name":
|
2017-12-06 06:07:44 +00:00
|
|
|
a.Name = v
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("Syntax error: not supported attribute[%s]", k)
|
2017-12-05 13:28:42 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-06 06:07:44 +00:00
|
|
|
return nil
|
2017-12-05 13:28:42 +00:00
|
|
|
}
|