// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved. package container import ( "errors" "fmt" ) // 基本组件信息 // @Implement LAPP_LF_MOM_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_LF_MOM_BACKEND/container/ComponentInformation.Interface func (info *ElementInformation) Interface() Interface { return info.interfaceType } // @Reference LAPP_LF_MOM_BACKEND/container/ComponentInformation.IsGlobal func (info *ElementInformation) IsGlobal() bool { return false } // @Reference LAPP_LF_MOM_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 }