苏州瑞玛APS项目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

  1. // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
  2. package container
  3. import (
  4. "errors"
  5. "fmt"
  6. )
  7. // 基本组件信息
  8. // @Implement LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation
  9. type ElementInformation struct {
  10. // 实例工厂
  11. factory Factory
  12. // 接口类型
  13. interfaceType Interface
  14. }
  15. // 创建服务组件信息
  16. // 参数
  17. // 1.工厂方法
  18. // 返回值:
  19. // 1.服务组件信息
  20. // 2.错误
  21. func NewElementInformation(factory interface{}) *ElementInformation {
  22. valueOfFactory, interfaceType := parseFactory(factory)
  23. return &ElementInformation{valueOfFactory, interfaceType}
  24. }
  25. // @Reference LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation.Interface
  26. func (info *ElementInformation) Interface() Interface {
  27. return info.interfaceType
  28. }
  29. // @Reference LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation.IsGlobal
  30. func (info *ElementInformation) IsGlobal() bool {
  31. return false
  32. }
  33. // @Reference LAPP_GAAS_GFrame_BACKEND/container/ComponentInformation.BuildHandler
  34. func (info *ElementInformation) BuildHandler(sessionContext *SessionContext) (ComponentHandler, error) {
  35. if sessionContext == nil {
  36. return nil, errors.New(fmt.Sprintf("会话上下文不能为空!"))
  37. }
  38. instance, err := info.factory.Create(sessionContext)
  39. if err != nil {
  40. return nil, err
  41. }
  42. return NewElementHandler(instance), nil
  43. }