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.

52 lines
1.3 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 {
valueOfFactory, interfaceType := parseFactory(factory)
return &ElementInformation{valueOfFactory, interfaceType}
}
// @Reference LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation.Interface
func (info *ElementInformation) Interface() Interface {
return info.interfaceType
}
// @Reference LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation.IsGlobal
func (info *ElementInformation) IsGlobal() bool {
return false
}
// @Reference LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation.BuildHandler
func (info *ElementInformation) BuildHandler(sessionContext *SessionContext) (ComponentHandler, error) {
if sessionContext == nil {
return nil, errors.New(fmt.Sprintf("会话上下文不能为空!"))
}
instance, err := info.factory.Create(sessionContext)
if err != nil {
return nil, err
}
return NewElementHandler(instance), nil
}