Documentation
¶
Overview ¶
开箱即用的 Go-Spring 程序启动框架。
Index ¶
- Constants
- func BindProperty(name string, i interface{})
- func CollectBeans(i interface{}) bool
- func Exit()
- func FindBeanByName(beanId string) (interface{}, bool)
- func GetAllBeanDefinitions() []*SpringCore.BeanDefinition
- func GetAllProperties() map[string]interface{}
- func GetBean(i interface{}) bool
- func GetBeanByName(beanId string, i interface{}) bool
- func GetBoolProperty(name string) bool
- func GetDefaultProperty(name string, defaultValue interface{}) (interface{}, bool)
- func GetFloatProperty(name string) float64
- func GetIntProperty(name string) int64
- func GetPrefixProperties(prefix string) map[string]interface{}
- func GetProfile() string
- func GetProperty(name string) interface{}
- func GetStringProperty(name string) string
- func GetUintProperty(name string) uint64
- func RegisterBean(bean interface{}) *SpringCore.Annotation
- func RegisterBeanDefinition(beanDefinition *SpringCore.BeanDefinition) *SpringCore.Annotation
- func RegisterBeanFn(fn interface{}, tags ...string) *SpringCore.Annotation
- func RegisterNameBean(name string, bean interface{}) *SpringCore.Annotation
- func RegisterNameBeanFn(name string, fn interface{}, tags ...string) *SpringCore.Annotation
- func RunApplication(configLocation ...string)
- func SetProfile(profile string)
- func SetProperty(name string, value interface{})
- func WireBean(bean interface{})
- type Application
- type ApplicationContext
- type ApplicationEvent
- type CommandLineRunner
- type ConfigMapPropertySource
- type DefaultApplicationContext
- type DefaultPropertySource
- type GoFunc
- type PropertySource
Constants ¶
View Source
const (
SPRING_PROFILE = "spring.profile"
)
Variables ¶
This section is empty.
Functions ¶
func CollectBeans ¶
func CollectBeans(i interface{}) bool
收集数组或指针定义的所有符合条件的 Bean 对象,收集到返回 true,否则返回 false。
func FindBeanByName ¶
根据名称和类型获取单例 Bean,若多于 1 个则 panic;找到返回 true 否则返回 false。
func GetAllBeanDefinitions ¶
func GetAllBeanDefinitions() []*SpringCore.BeanDefinition
获取所有 Bean 的定义,一般仅供调试使用。
func GetBeanByName ¶
根据名称和类型获取单例 Bean,若多于 1 个则 panic;找到返回 true 否则返回 false。
func GetDefaultProperty ¶
获取属性值,如果没有找到则使用指定的默认值,属性名称不支持大小写。
func GetPrefixProperties ¶
获取指定前缀的属性值集合,属性名称不支持大小写。
func RegisterBean ¶
func RegisterBean(bean interface{}) *SpringCore.Annotation
注册单例 Bean,不指定名称,重复注册会 panic。
func RegisterBeanDefinition ¶
func RegisterBeanDefinition(beanDefinition *SpringCore.BeanDefinition) *SpringCore.Annotation
注册单例 Bean,使用 BeanDefinition 对象,重复注册会 panic。
func RegisterBeanFn ¶
func RegisterBeanFn(fn interface{}, tags ...string) *SpringCore.Annotation
通过构造函数注册单例 Bean,不指定名称,重复注册会 panic。
func RegisterNameBean ¶
func RegisterNameBean(name string, bean interface{}) *SpringCore.Annotation
注册单例 Bean,需指定名称,重复注册会 panic。
func RegisterNameBeanFn ¶
通过构造函数注册单例 Bean,需指定名称,重复注册会 panic。
Types ¶
type Application ¶
type Application struct { AppContext ApplicationContext // 应用上下文 ConfigLocation []string // 配置文件目录 }
定义 SpringBoot 应用。
type ApplicationContext ¶
type ApplicationContext interface { // 继承 SpringContext 的功能。 SpringCore.SpringContext // 安全的启动一个 goroutine。 SafeGoroutine(fn GoFunc) // 等待所有 goroutine 退出。 Wait() }
定义 Application 上下文。
type ApplicationEvent ¶
type ApplicationEvent interface { OnStartApplication(ctx ApplicationContext) // 应用启动的事件 OnStopApplication(ctx ApplicationContext) // 应用停止的事件 }
应用运行过程中的事件。
type ConfigMapPropertySource ¶
type ConfigMapPropertySource struct {
// contains filtered or unexported fields
}
基于 k8s ConfigMap 的属性源
func NewConfigMapPropertySource ¶
func NewConfigMapPropertySource(filename string) *ConfigMapPropertySource
构造函数
func (*ConfigMapPropertySource) Load ¶
func (p *ConfigMapPropertySource) Load(profile string) map[string]interface{}
func (*ConfigMapPropertySource) Name ¶
func (p *ConfigMapPropertySource) Name() string
type DefaultApplicationContext ¶
type DefaultApplicationContext struct { *SpringCore.DefaultSpringContext // contains filtered or unexported fields }
定义 ApplicationContext 的默认版本。
func (*DefaultApplicationContext) SafeGoroutine ¶
func (ctx *DefaultApplicationContext) SafeGoroutine(fn GoFunc)
安全地启动一个 goroutine。
func (*DefaultApplicationContext) Wait ¶
func (ctx *DefaultApplicationContext) Wait()
等待所有 goroutine 安全地退出。
type DefaultPropertySource ¶
type DefaultPropertySource struct {
// contains filtered or unexported fields
}
基于默认配置文件的属性源
func NewDefaultPropertySource ¶
func NewDefaultPropertySource(fileLocation string) *DefaultPropertySource
构造函数
func (*DefaultPropertySource) Load ¶
func (p *DefaultPropertySource) Load(profile string) map[string]interface{}
func (*DefaultPropertySource) Name ¶
func (p *DefaultPropertySource) Name() string
type PropertySource ¶
type PropertySource interface { // 属性源的名称 Name() string // 加载属性文件,profile 配置文件剖面。 Load(profile string) map[string]interface{} }
属性源
Click to show internal directories.
Click to hide internal directories.