GAAS GFrame项目web后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
package container
import (
"errors"
"fmt"
)
// 基本组件信息
// @Implement LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation
type ElementInformation struct {
// 实例工厂
factory Factory
// 接口类型
interfaceType Interface
}
// 创建服务组件信息
// 参数
// 1.工厂方法
// 返回值:
// 1.服务组件信息
// 2.错误
func NewElementInformation(factory interface{}) (*ElementInformation, error) {
valueOfFactory, interfaceType, err := parseFactory(factory)
if err != nil {
return nil, err
}
return &ElementInformation{valueOfFactory, interfaceType}, nil
}
// @Reference LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation.Interface
func (info *ElementInformation) Interface() Interface {
return info.interfaceType
}
// @Reference LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation.BuildHandler
func (info *ElementInformation) BuildHandler(session *Session) (ComponentHandler, error) {
if session == nil {
return nil, errors.New(fmt.Sprintf("会话不能为空!"))
}
instance, err := info.factory.Create(&session.SessionContext)
if err != nil {
return nil, err
}
return NewElementHandler(instance), nil
}