gs_bean

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package gs_bean provides core bean management for Go-Spring framework.

Index

Constants

View Source
const (
	StatusDeleted   = BeanStatus(-1)   // Bean has been deleted.
	StatusDefault   = BeanStatus(iota) // Default status of the bean.
	StatusResolving                    // Bean is being resolved.
	StatusResolved                     // Bean has been resolved.
	StatusCreating                     // Bean is being created.
	StatusCreated                      // Bean has been created.
	StatusWired                        // Bean has been wired.
)

Variables

This section is empty.

Functions

func NewBean

func NewBean(objOrCtor any, ctorArgs ...gs.Arg) *gs.BeanDefinition

NewBean creates a new BeanDefinition. If objOrCtor is a constructor function, it binds its arguments and infers bean name. Otherwise, it wraps an existing instance as a bean.

Types

type BeanDefinition

type BeanDefinition struct {
	*BeanMetadata
	*BeanRuntime
}

BeanDefinition contains both metadata and runtime information of a bean.

func (*BeanDefinition) Callable

func (d *BeanDefinition) Callable() *gs_arg.Callable

Callable returns the bean's callable constructor.

func (*BeanDefinition) OnProfiles

func (d *BeanDefinition) OnProfiles(profiles string)

OnProfiles adds conditions based on active profiles.

func (*BeanDefinition) SetConfiguration

func (d *BeanDefinition) SetConfiguration(c ...gs.Configuration)

SetConfiguration sets configuration (include/exclude) for the bean.

func (*BeanDefinition) SetDestroy

func (d *BeanDefinition) SetDestroy(fn gs.BeanDestroyFunc)

SetDestroy sets the bean's destruction function.

func (*BeanDefinition) SetDestroyMethod

func (d *BeanDefinition) SetDestroyMethod(method string)

SetDestroyMethod sets the bean's destruction method by name.

func (*BeanDefinition) SetExport

func (d *BeanDefinition) SetExport(exports ...reflect.Type)

SetExport registers interfaces exported by the bean.

func (*BeanDefinition) SetInit

func (d *BeanDefinition) SetInit(fn gs.BeanInitFunc)

SetInit sets the bean's initialization function.

func (*BeanDefinition) SetInitMethod

func (d *BeanDefinition) SetInitMethod(method string)

SetInitMethod sets the bean's initialization method by name.

func (*BeanDefinition) SetMock

func (d *BeanDefinition) SetMock(obj any)

SetMock replaces the bean's runtime instance with a mock object.

func (*BeanDefinition) SetName

func (d *BeanDefinition) SetName(name string)

SetName sets the bean's name.

func (*BeanDefinition) SetStatus

func (d *BeanDefinition) SetStatus(status BeanStatus)

SetStatus sets the bean's current lifecycle status.

func (*BeanDefinition) Status

func (d *BeanDefinition) Status() BeanStatus

Status returns the bean's current lifecycle status.

func (*BeanDefinition) String

func (d *BeanDefinition) String() string

String returns a human-readable description of the bean.

func (*BeanDefinition) TypeAndName

func (d *BeanDefinition) TypeAndName() (reflect.Type, string)

TypeAndName returns the bean's type and name.

type BeanMetadata

type BeanMetadata struct {
	// contains filtered or unexported fields
}

BeanMetadata holds static (design-time) metadata about a bean, such as lifecycle functions, dependencies, conditions, and configuration.

func (*BeanMetadata) Conditions

func (d *BeanMetadata) Conditions() []gs.Condition

Conditions returns the list of conditions for the bean.

func (*BeanMetadata) Configuration

func (d *BeanMetadata) Configuration() *gs.Configuration

Configuration returns the configuration for the bean.

func (*BeanMetadata) DependsOn

func (d *BeanMetadata) DependsOn() []gs.BeanSelector

DependsOn returns the list of dependencies for the bean.

func (*BeanMetadata) Destroy

func (d *BeanMetadata) Destroy() gs.BeanDestroyFunc

Destroy returns the bean's destruction function.

func (*BeanMetadata) Exports

func (d *BeanMetadata) Exports() []reflect.Type

Exports returns the interfaces exported by the bean.

func (*BeanMetadata) FileLine

func (d *BeanMetadata) FileLine() string

FileLine returns the source file and line number of the bean.

func (*BeanMetadata) Init

func (d *BeanMetadata) Init() gs.BeanInitFunc

Init returns the bean's initialization function.

func (*BeanMetadata) Mocked

func (d *BeanMetadata) Mocked() bool

Mocked returns true if the bean is mocked.

func (*BeanMetadata) SetCaller

func (d *BeanMetadata) SetCaller(skip int)

SetCaller records the source file and line number of the bean.

func (*BeanMetadata) SetCondition

func (d *BeanMetadata) SetCondition(conditions ...gs.Condition)

SetCondition appends conditions for the bean.

func (*BeanMetadata) SetDependsOn

func (d *BeanMetadata) SetDependsOn(selectors ...gs.BeanSelector)

SetDependsOn adds dependencies to the bean.

func (*BeanMetadata) SetFileLine

func (d *BeanMetadata) SetFileLine(file string, line int)

SetFileLine sets the source file and line number of the bean.

type BeanRuntime

type BeanRuntime struct {
	// contains filtered or unexported fields
}

BeanRuntime holds runtime information about the bean.

func (*BeanRuntime) Callable

func (d *BeanRuntime) Callable() *gs_arg.Callable

Callable returns the bean's callable constructor.

func (*BeanRuntime) Interface

func (d *BeanRuntime) Interface() any

Interface returns the underlying bean.

func (*BeanRuntime) Name

func (d *BeanRuntime) Name() string

Name returns the bean's name.

func (*BeanRuntime) Status

func (d *BeanRuntime) Status() BeanStatus

Status returns the current status of the bean.

func (*BeanRuntime) String

func (d *BeanRuntime) String() string

String returns a string representation of the bean.

func (*BeanRuntime) Type

func (d *BeanRuntime) Type() reflect.Type

Type returns the bean's type.

func (*BeanRuntime) Value

func (d *BeanRuntime) Value() reflect.Value

Value returns the bean as reflect.Value.

type BeanStatus

type BeanStatus int8

BeanStatus represents the different lifecycle statuses of a bean.

func (BeanStatus) String

func (status BeanStatus) String() string

String returns a human-readable string for the bean status.

Jump to

Keyboard shortcuts

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