Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultLevel = 0
Variables ¶
View Source
var BeanClass = reflect.TypeOf((*Bean)(nil)).Elem()
View Source
var ContextClass = reflect.TypeOf((*Context)(nil)).Elem()
View Source
var DefaultCloseTimeout = time.Minute
View Source
var DisposableBeanClass = reflect.TypeOf((*DisposableBean)(nil)).Elem()
* This interface uses to select objects that could free resources after closing context
View Source
var FactoryBeanClass = reflect.TypeOf((*FactoryBean)(nil)).Elem()
View Source
var InitializingBeanClass = reflect.TypeOf((*InitializingBean)(nil)).Elem()
View Source
var NamedBeanClass = reflect.TypeOf((*NamedBean)(nil)).Elem()
* This interface used to collect all beans with similar type in map, where the name is the key
View Source
var OrderedBeanClass = reflect.TypeOf((*OrderedBean)(nil)).Elem()
* This interface used to collect beans in list with specific order
View Source
var PropertiesClass = reflect.TypeOf((*Properties)(nil))
View Source
var PropertyResolverClass = reflect.TypeOf((*PropertyResolver)(nil))
View Source
var PropertySourceClass = reflect.TypeOf((*PropertySource)(nil))
View Source
var ResourceClass = reflect.TypeOf((*Resource)(nil)).Elem()
* This interface used to access the specific resource
View Source
var ResourceSourceClass = reflect.TypeOf((*ResourceSource)(nil))
View Source
var ScannerClass = reflect.TypeOf((*Scanner)(nil)).Elem()
* This interface used to provide pre-scanned instances in gluten.New method
View Source
var VerboseClass = reflect.TypeOf((*Verbose)(nil))
Functions ¶
This section is empty.
Types ¶
type Bean ¶
type Bean interface { /** Returns name of the bean, that could be instance name with package or if instance implements NamedBean interface it would be result of BeanName() call. */ Name() string /** Returns real type of the bean */ Class() reflect.Type /** Returns true if bean implements interface */ Implements(ifaceType reflect.Type) bool /** Returns initialized object of the bean */ Object() interface{} /** Returns factory bean of exist only beans created by FactoryBean interface */ FactoryBean() (Bean, bool) /** Re-initialize bean by calling Destroy method if bean implements DisposableBean interface and then calls PostConstruct method if bean implements InitializingBean interface Reload can not be used for beans created by FactoryBean, since the instances are already injected */ Reload() error /** Returns current bean lifecycle */ Lifecycle() BeanLifecycle /** Returns information about the bean */ String() string }
type BeanLifecycle ¶
type BeanLifecycle int32
const ( BeanAllocated BeanLifecycle = iota BeanCreated BeanConstructing BeanInitialized BeanDestroying BeanDestroyed )
func (BeanLifecycle) String ¶
func (t BeanLifecycle) String() string
type Context ¶
type Context interface { /** Gets parent context if exist */ Parent() (Context, bool) /** New new context with additional beans based on current one */ Extend(scan ...interface{}) (Context, error) /** Destroy all beans that implement interface DisposableBean. */ Close() error /** Get list of all registered instances on creation of context with scope 'core' */ Core() []reflect.Type /** Gets obj by type, that is a pointer to the structure or interface. Example: package app type UserService interface { } list := ctx.Bean(reflect.TypeOf((*app.UserService)(nil)).Elem(), 0) Lookup level defines how deep we will go in to beans: level 0: look in the current context, if not found then look in the parent context and so on (default) level 1: look only in the current context level 2: look in the current context in union with the parent context level 3: look in union of current, parent, parent of parent contexts and so on. level -1: look in union of all contexts. */ Bean(typ reflect.Type, level int) []Bean /** Lookup registered beans in context by name. The name is the local package plus name of the interface, for example 'app.UserService' Or if bean implements NamedBean interface the name of it. Example: beans := ctx.Bean("app.UserService") beans := ctx.Bean("userService") Lookup parent context only for beans that were used in injection inside child context. If you need to lookup all beans, use the loop with Parent() call. */ Lookup(name string, level int) []Bean /** Inject fields in to the obj on runtime that is not part of core context. Does not add a new bean in to the core context, so this method is only for one-time use with scope 'runtime'. Does not initialize bean and does not destroy it. Example: type requestProcessor struct { app.UserService `inject` } rp := new(requestProcessor) ctx.Inject(rp) required.NotNil(t, rp.UserService) */ Inject(interface{}) error /** Returns resource and true if found Path should come with ResourceSource name prefix. Uses default level of lookup for the resource. */ Resource(path string) (Resource, bool) /** Returns context placeholder properties */ Properties() Properties /** Returns information about context */ String() string }
type DisposableBean ¶
type DisposableBean interface {
Destroy() error
}
type FactoryBean ¶
type FactoryBean interface { /** returns an object produced by the factory, and this is the object that will be used in context, but not going to be a bean */ Object() (interface{}, error) /** returns the type of object that this FactoryBean produces */ ObjectType() reflect.Type /** returns the bean name of object that this FactoryBean produces or empty string if name not defined */ ObjectName() string /** denotes if the object produced by this FactoryBean is a singleton */ Singleton() bool }
type InitializingBean ¶
type InitializingBean interface {
PostConstruct() error
}
type OrderedBean ¶
type OrderedBean interface { /** Returns bean order */ BeanOrder() int }
type Properties ¶
type Properties interface { PropertyResolver /** Register additional property resolver. It would be sorted by priority. */ Register(PropertyResolver) PropertyResolvers() []PropertyResolver /** Loads properties from map */ LoadMap(source map[string]interface{}) /** Loads properties from input stream */ Load(reader io.Reader) error /** Saves properties to output stream */ Save(writer io.Writer) (n int, err error) /** Parsing content as an UTF-8 string */ Parse(content string) error /** Dumps all properties to UTF-8 string */ Dump() string /** Extends parent properties */ Extend(parent Properties) /** Gets length of the properties */ Len() int /** Gets all keys associated with properties */ Keys() []string /** Return copy of properties as Map */ Map() map[string]string /** Checks if property contains the key */ Contains(key string) bool /** Gets property value and true if exist */ Get(key string) (value string, ok bool) /** Additional getters with type conversion */ GetString(key, def string) string GetBool(key string, def bool) bool GetInt(key string, def int) int GetFloat(key string, def float32) float32 GetDouble(key string, def float64) float64 GetDuration(key string, def time.Duration) time.Duration GetFileMode(key string, def os.FileMode) os.FileMode // properties conversion error handler GetErrorHandler() func(string, error) SetErrorHandler(onError func(string, error)) /** Sets property value */ Set(key string, value string) /** Remove property by key */ Remove(key string) bool /** Delete all properties and comments */ Clear() /** Gets comments associated with property */ GetComments(key string) []string /** Sets comments associated with property */ SetComments(key string, comments []string) /** ClearComments removes the comments for all keys. */ ClearComments() }
func NewProperties ¶
func NewProperties() Properties
type PropertyResolver ¶
type PropertySource ¶
type ResourceSource ¶
type ResourceSource struct { /** Used for resource reference based on pattern "name:path" ResourceSource instances sharing the same name would be merge and on conflict resource names would generate errors. */ Name string /** Known paths */ AssetNames []string /** FileSystem to access or serve assets or resources */ AssetFiles http.FileSystem }
Click to show internal directories.
Click to hide internal directories.