application

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2021 License: MIT Imports: 4 Imported by: 130

Documentation

Index

Constants

View Source
const ExitCodeGeneratorClassName = "exit-code-generator"
View Source
const LooperClassName = "looper"

Variables

This section is empty.

Functions

func Exit

func Exit(context Context) (int, error)

Exit 函数用于退出应用

func Loop

func Loop(context Context) error

Loop 函数用于执行应用的主循环

Types

type ComponentFactory

type ComponentFactory interface {
	NewInstance() ComponentInstance
}

ComponentFactory 一个组件的工厂

type ComponentHolder

type ComponentHolder interface {
	GetInstance() ComponentInstance
	IsOriginalName(name string) bool
	GetInfo() ComponentInfo
	GetPrototype() lang.Object
	GetContext() Context
	MakeChild(context Context) ComponentHolder
}

ComponentHolder 一个具体的组件的代理

type ComponentHolderFilter

type ComponentHolderFilter func(name string, holder ComponentHolder) bool

type ComponentInfo

type ComponentInfo interface {
	GetID() string
	GetClass() string
	GetAliases() []string
	GetClasses() []string
	GetScope() ComponentScope
	GetFactory() ComponentFactory
	GetPrototype() lang.Object

	IsTypeOf(typeName string) bool
	IsNameOf(alias string) bool
}

ComponentInfo 一个组件的配置

type ComponentInstance

type ComponentInstance interface {
	Get() lang.Object
	IsLoaded() bool
	Inject(context Context) error
	Init() error
	Destroy() error
}

ComponentInstance 一个具体的组件的实例的引用

type ComponentLoader

type ComponentLoader interface {
	io.Closer
	Load(h ComponentHolder) (lang.Object, error)
	LoadAll(h []ComponentHolder) ([]lang.Object, error)
	GetReleasePool() lang.ReleasePool
	GetContext() Context
}

ComponentLoader 用于加载组件的实例

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 {
	// ids
	GetComponentNameList(includeAliases bool) []string

	// getters
	GetComponent(selector string) (ComponentHolder, error)
	GetComponents(selector string) []ComponentHolder
	GetComponentsByFilter(f ComponentHolderFilter) []ComponentHolder

	// export & import
	Export(map[string]ComponentHolder) map[string]ComponentHolder
	Import(map[string]ComponentHolder)
}

Components 接口表示一个组件的集合

type ConfigBuilder

type ConfigBuilder interface {
	AddComponent(info ComponentInfo)
	SetResources(res collection.Resources)

	SetEnableLoadPropertiesFromArguments(enable bool)
	IsEnableLoadPropertiesFromArguments() bool

	Create() Configuration
}

ConfigBuilder 表示应用程序配置

type Configuration

type Configuration interface {
	GetLoader() ContextLoader
	GetComponents() []ComponentInfo
	GetResources() collection.Resources
	GetEnvironment() collection.Environment
	IsEnableLoadPropertiesFromArguments() bool
}

Configuration 表示应用程序配置

type Context

type Context interface {
	ContextCollections
	ContextInfo

	// helper
	SetErrorHandler(h lang.ErrorHandler)
	GetErrorHandler() lang.ErrorHandler
	NewChild() Context

	FindComponent(selector string) (lang.Object, error)
	FindComponents(selector string) []lang.Object
	Injector() Injector
	InjectorScope(scope ComponentScope) Injector
}

Context 表示一个通用的上下文对象

func Run

func Run(config Configuration, args []string) (Context, error)

Run 函数启动一个应用实例,返回应用上下文

type ContextCollections

type ContextCollections interface {
	GetReleasePool() lang.ReleasePool
	GetComponents() Components

	GetArguments() collection.Arguments
	GetAttributes() collection.Attributes
	GetEnvironment() collection.Environment
	GetProperties() collection.Properties
	GetParameters() collection.Parameters
	GetResources() collection.Resources
}

type ContextGetter

type ContextGetter interface {

	// for property
	GetProperty(name string) (string, error)
	GetPropertySafely(name string, _default string) string
	GetPropertyString(name string, _default string) string
	GetPropertyInt(name string, _default int) int
}

ContextGetter 接口向 Context 的使用者提供简易的 getter 方法

type ContextInfo

type ContextInfo interface {

	// info
	GetURI() string
	GetApplicationName() string
	GetApplicationVersion() string
	GetStartupTimestamp() int64
	GetShutdownTimestamp() int64
}

type ContextLoader

type ContextLoader interface {
	Load(config Configuration, args []string) (Context, error)
}

ContextLoader 用于加载进程上下文

type ExitCodeGenerator

type ExitCodeGenerator interface {
	ExitCode() int
}

type Injection

type Injection interface {
	AsList() Injection
	IncludeAliases() Injection
	Accept(f ComponentHolderFilter) Injection
	To(func(lang.Object) bool)
}

type Injector

type Injector interface {
	ContextGetter

	//  selector 类似css中的selector,用“#xxx”表示id选择器,用“.xxx”表示类选择器,用“*”表示全部
	Inject(selector string) Injection
	GetComponent(selector string) (lang.Object, error)

	Done() error
}

type Looper

type Looper interface {
	Loop() error
}

type Runnable

type Runnable interface {
	Run(context Context) error
}

type SimpleContext

type SimpleContext interface {
	GetAttribute(name string) interface{}
	SetAttribute(name string, value interface{})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL