Documentation ¶
Index ¶
- func Exit(context RuntimeContext) int
- type ComponentFactory
- type ComponentHolder
- type ComponentInfo
- type ComponentInstance
- type ComponentScope
- type Components
- type ConfigBuilder
- type Configuration
- type Context
- type ContextGetter
- type ContextLoader
- type CreationContext
- type ExitCodeGenerator
- type RuntimeContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ComponentFactory ¶
type ComponentFactory interface {
NewInstance() ComponentInstance
}
ComponentFactory 一个组件的工厂
type ComponentHolder ¶
type ComponentHolder interface { GetInstance() ComponentInstance IsOriginalName(name string) bool GetInfo() ComponentInfo GetContext() RuntimeContext MakeChild(context RuntimeContext) ComponentHolder }
ComponentHolder 一个具体的组件的代理
type ComponentInfo ¶
type ComponentInfo interface { GetID() string GetClass() string GetAliases() []string GetClasses() []string GetScope() ComponentScope GetFactory() ComponentFactory IsTypeOf(typeName string) bool IsNameOf(alias string) bool }
ComponentInfo 一个组件的配置
type ComponentInstance ¶
type ComponentInstance interface { Get() lang.Object IsLoaded() bool Inject(context RuntimeContext) error Init() error Destroy() error }
ComponentInstance 一个具体的组件的实例的引用
type ComponentScope ¶
type ComponentScope uint32
ComponentScope 枚举表示组件的作用域
const ( // ScopeMin 是作用域的最小值 ScopeMin ComponentScope = 0 // 最小 // ScopeSingleton 表示单例模式 ScopeSingleton ComponentScope = 1 // ScopeContext 表示上下文模式 ScopeContext ComponentScope = 2 // ScopePrototype 表示原型模式 ScopePrototype ComponentScope = 3 // ScopeMax 是作用域的最大值 ScopeMax ComponentScope = 4 // 最大 )
type Components ¶
type Components interface { GetComponent(name string) (lang.Object, error) GetComponentByClass(classSelector string) (lang.Object, error) GetComponentsByClass(classSelector string) []lang.Object GetComponentNameList(includeAliases bool) []string //// Export(map[string]ComponentHolder) map[string]ComponentHolder Import(map[string]ComponentHolder) }
Components 接口表示一个组件的集合
type ConfigBuilder ¶
type ConfigBuilder interface {
AddComponent(info ComponentInfo)
}
ConfigBuilder 表示应用程序配置
type Configuration ¶
type Configuration interface { GetBuilder() ConfigBuilder GetLoader() ContextLoader GetComponents() []ComponentInfo GetResources() collection.Resources }
Configuration 表示应用程序配置
type Context ¶
type Context interface { GetComponents() Components GetReleasePool() collection.ReleasePool GetArguments() collection.Arguments GetAttributes() collection.Attributes GetEnvironment() collection.Environment GetProperties() collection.Properties GetParameters() collection.Parameters GetResources() collection.Resources }
Context 表示一个通用的上下文对象
type ContextGetter ¶
type ContextGetter interface { ErrorCollector() lang.ErrorCollector Result() error GetProperty(name string) string GetPropertySafely(name string, _default string) string GetComponent(name string) lang.Object GetComponentByClass(classSelector string) lang.Object GetComponentsByClass(classSelector string) []lang.Object }
ContextGetter 接口向 Context 的使用者提供简易的 getter 方法
func NewGetter ¶
func NewGetter(context Context) ContextGetter
type ContextLoader ¶
type ContextLoader interface {
Load(config Configuration, args []string) (RuntimeContext, error)
}
ContextLoader 用于加载进程上下文
type CreationContext ¶
type CreationContext interface { io.Closer GetScope() ComponentScope GetContext() RuntimeContext }
CreationContext 是构建时的上下文
type ExitCodeGenerator ¶
type ExitCodeGenerator interface {
GetExitCode() int
}
type RuntimeContext ¶
type RuntimeContext interface { Context // info GetURI() string GetApplicationName() string GetApplicationVersion() string GetStartupTimestamp() int64 GetShutdownTimestamp() int64 // helper SetErrorHandler(h lang.ErrorHandler) GetErrorHandler() lang.ErrorHandler NewGetter(ec lang.ErrorCollector) ContextGetter NewChild() RuntimeContext OpenCreationContext(scope ComponentScope) CreationContext }
RuntimeContext 是app的全局上下文
func Run ¶
func Run(config Configuration, args []string) (RuntimeContext, error)
Run 函数启动一个应用实例,返回应用上下文
Source Files ¶
Click to show internal directories.
Click to hide internal directories.