Documentation ¶
Index ¶
- type BuildReferencesDecorator
- func (c *BuildReferencesDecorator) ClarifyLocator(locator interface{}, factory build.IFactory) interface{}
- func (c *BuildReferencesDecorator) Create(locator interface{}, factory build.IFactory) interface{}
- func (c *BuildReferencesDecorator) Find(locator interface{}, required bool) ([]interface{}, error)
- func (c *BuildReferencesDecorator) FindFactory(locator interface{}) build.IFactory
- func (c *BuildReferencesDecorator) GetOneOptional(locator interface{}) interface{}
- func (c *BuildReferencesDecorator) GetOneRequired(locator interface{}) (interface{}, error)
- func (c *BuildReferencesDecorator) GetOptional(locator interface{}) []interface{}
- func (c *BuildReferencesDecorator) GetRequired(locator interface{}) ([]interface{}, error)
- type ContainerReferences
- type LinkReferencesDecorator
- func (c *LinkReferencesDecorator) Close(correlationId string) error
- func (c *LinkReferencesDecorator) IsOpen() bool
- func (c *LinkReferencesDecorator) Open(correlationId string) error
- func (c *LinkReferencesDecorator) Put(locator interface{}, component interface{})
- func (c *LinkReferencesDecorator) Remove(locator interface{}) interface{}
- func (c *LinkReferencesDecorator) RemoveAll(locator interface{}) []interface{}
- type ManagedReferences
- type ReferencesDecorator
- func (c *ReferencesDecorator) Find(locator interface{}, required bool) ([]interface{}, error)
- func (c *ReferencesDecorator) GetAll() []interface{}
- func (c *ReferencesDecorator) GetAllLocators() []interface{}
- func (c *ReferencesDecorator) GetOneOptional(locator interface{}) interface{}
- func (c *ReferencesDecorator) GetOneRequired(locator interface{}) (interface{}, error)
- func (c *ReferencesDecorator) GetOptional(locator interface{}) []interface{}
- func (c *ReferencesDecorator) GetRequired(locator interface{}) ([]interface{}, error)
- func (c *ReferencesDecorator) Put(locator interface{}, component interface{})
- func (c *ReferencesDecorator) Remove(locator interface{}) interface{}
- func (c *ReferencesDecorator) RemoveAll(locator interface{}) []interface{}
- type RunReferencesDecorator
- func (c *RunReferencesDecorator) Close(correlationId string) error
- func (c *RunReferencesDecorator) IsOpen() bool
- func (c *RunReferencesDecorator) Open(correlationId string) error
- func (c *RunReferencesDecorator) Put(locator interface{}, component interface{})
- func (c *RunReferencesDecorator) Remove(locator interface{}) interface{}
- func (c *RunReferencesDecorator) RemoveAll(locator interface{}) []interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildReferencesDecorator ¶
type BuildReferencesDecorator struct {
ReferencesDecorator
}
References decorator that automatically creates missing components using available component factories upon component retrival.
func NewBuildReferencesDecorator ¶
func NewBuildReferencesDecorator(nextReferences crefer.IReferences, topReferences crefer.IReferences) *BuildReferencesDecorator
Creates a new instance of the decorator. Parameters:
- nextReferences crefer.IReferences the next references or decorator in the chain.
- topReferences IReferences the decorator at the top of the chain.
Returns *BuildReferencesDecorator
func (*BuildReferencesDecorator) ClarifyLocator ¶
func (c *BuildReferencesDecorator) ClarifyLocator(locator interface{}, factory build.IFactory) interface{}
Clarifies a component locator by merging two descriptors into one to replace missing fields. That allows to get a more complete descriptor that includes all possible fields. Parameters:
- locator intrface{} a component locator to clarify.
- factory build.IFactory a factory that shall create the component.
Returns interface{} clarified component descriptor (locator)
func (*BuildReferencesDecorator) Create ¶
func (c *BuildReferencesDecorator) Create(locator interface{}, factory build.IFactory) interface{}
Creates a component identified by given locator. throws a CreateEerror if the factory is not able to create the component. see findFactory Parameters:
- locator interface{} a locator to identify component to be created.
- factory build.IFactory a factory that shall create the component.
Returns interface{} the created component.
func (*BuildReferencesDecorator) Find ¶
func (c *BuildReferencesDecorator) Find(locator interface{}, required bool) ([]interface{}, error)
Gets all component references that match specified locator. throws a ReferenceError when required is set to true but no references found. Parameters:
- locator interface the locator to find a reference by.
- required bool forces to raise an exception if no reference is found.
Returns []interface, error a list with matching component references and error.
func (*BuildReferencesDecorator) FindFactory ¶
func (c *BuildReferencesDecorator) FindFactory(locator interface{}) build.IFactory
Finds a factory capable creating component by given descriptor from the components registered in the references. Parameters:
- locator interface{} a locator of component to be created.
Returns build.IFactory found factory or nil if factory was not found.
func (*BuildReferencesDecorator) GetOneOptional ¶
func (c *BuildReferencesDecorator) GetOneOptional(locator interface{}) interface{}
Gets an optional component reference that matches specified locator. Parameters:
- locator interface{} the locator to find references by.
Returns interface{} a matching component reference or nil if nothing was found.
func (*BuildReferencesDecorator) GetOneRequired ¶
func (c *BuildReferencesDecorator) GetOneRequired(locator interface{}) (interface{}, error)
Gets a required component reference that matches specified locator. throws a ReferenceException when no references found. Parameters:
- locator interface{} the locator to find a reference by.
Returns interface{}, error a matching component reference and error.
func (*BuildReferencesDecorator) GetOptional ¶
func (c *BuildReferencesDecorator) GetOptional(locator interface{}) []interface{}
Gets all component references that match specified locator. Parameters:
- locator interface{} the locator to find references by.
Returns []interface{} a list with matching component references or empty list if nothing was found.
func (*BuildReferencesDecorator) GetRequired ¶
func (c *BuildReferencesDecorator) GetRequired(locator interface{}) ([]interface{}, error)
Gets all component references that match specified locator. At least one component reference must be present. If it doesn't the method throws an error. throws a ReferenceException when no references found. Parameters:
- locator interface{} the locator to find references by.
Returns []interface{}, erorr a list with matching component references and error.
type ContainerReferences ¶
type ContainerReferences struct {
ManagedReferences
}
Container managed references that can be created from container configuration.
func NewContainerReferences ¶
func NewContainerReferences() *ContainerReferences
Creates a new instance of the references Returns *ContainerReferences
func (*ContainerReferences) PutFromConfig ¶
func (c *ContainerReferences) PutFromConfig(config config.ContainerConfig) error
Puts components into the references from container configuration. Parameters:
- config config.ContainerConfig a container configuration with information of components to be added.
Returns error CreateError when one of component cannot be created.
type LinkReferencesDecorator ¶
type LinkReferencesDecorator struct { ReferencesDecorator // contains filtered or unexported fields }
References decorator that automatically sets references to newly added components that implement IReferenceable interface and unsets references from removed components that implement IUnreferenceable interface.
func NewLinkReferencesDecorator ¶
func NewLinkReferencesDecorator(nextReferences crefer.IReferences, topReferences crefer.IReferences) *LinkReferencesDecorator
Creates a new instance of the decorator. Parameters:
- nextReferences crefer.IReferences the next references or decorator in the chain.
- topReferences crefer.IReferences the decorator at the top of the chain.
Returns *LinkReferencesDecorator
func (*LinkReferencesDecorator) Close ¶
func (c *LinkReferencesDecorator) Close(correlationId string) error
Closes component and frees used resources. Parameters:
- correlationId string transaction id to trace execution through call chain.
Returns error
func (*LinkReferencesDecorator) IsOpen ¶
func (c *LinkReferencesDecorator) IsOpen() bool
Checks if the component is opened. Returns bool true if the component has been opened and false otherwise.
func (*LinkReferencesDecorator) Open ¶
func (c *LinkReferencesDecorator) Open(correlationId string) error
Opens the component. Parameters:
- correlationId string transaction id to trace execution through call chain.
Returns error
func (*LinkReferencesDecorator) Put ¶
func (c *LinkReferencesDecorator) Put(locator interface{}, component interface{})
Puts a new reference into this reference map. Parameters:
- locator intrface{} a locator to find the reference by.
- component interface{} a component reference to be added.
func (*LinkReferencesDecorator) Remove ¶
func (c *LinkReferencesDecorator) Remove(locator interface{}) interface{}
Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use removeAll method instead. see removeAll Parameters:
- locator interface a locator to remove reference
Returns interface{} the removed component reference.
func (*LinkReferencesDecorator) RemoveAll ¶
func (c *LinkReferencesDecorator) RemoveAll(locator interface{}) []interface{}
Removes all component references that match the specified locator. Parameters:
- locator interface{} the locator to remove references by.
Returns []interface{} a list, containing all removed references.
type ManagedReferences ¶
type ManagedReferences struct { ReferencesDecorator References *crefer.References Builder *BuildReferencesDecorator Linker *LinkReferencesDecorator Runner *RunReferencesDecorator }
Managed references that in addition to keeping and locating references can also manage their lifecycle:
Auto-creation of missing component using available factories Auto-linking newly added components Auto-opening newly added components Auto-closing removed components
func NewEmptyManagedReferences ¶
func NewEmptyManagedReferences() *ManagedReferences
Creates a new instance of the references Returns *ManagedReferences
func NewManagedReferences ¶
func NewManagedReferences(tuples []interface{}) *ManagedReferences
Creates a new instance of the references Parameters:
- tuples []interface{} tuples where odd values are component locators (descriptors) and even values are component references
Returns *ManagedReferences
func NewManagedReferencesFromTuples ¶
func NewManagedReferencesFromTuples(tuples ...interface{}) *ManagedReferences
Creates a new ManagedReferences object filled with provided key-value pairs called tuples. Tuples parameters contain a sequence of locator1, component1, locator2, component2, ... pairs. Parameters:
- tuples ...interface{} the tuples to fill a new ManagedReferences object.
Returns *ManagedReferences a new ManagedReferences object.
func (*ManagedReferences) Close ¶
func (c *ManagedReferences) Close(correlationId string) error
Closes component and frees used resources. Parameters:
- correlationId string transaction id to trace execution through call chain.
Returns error
func (*ManagedReferences) IsOpen ¶
func (c *ManagedReferences) IsOpen() bool
Checks if the component is opened. Returns bool true if the component has been opened and false otherwise.
func (*ManagedReferences) Open ¶
func (c *ManagedReferences) Open(correlationId string) error
Opens the component. Parameters:
- correlationId string transaction id to trace execution through call chain.
Returns error
type ReferencesDecorator ¶
type ReferencesDecorator struct { NextReferences crefer.IReferences TopReferences crefer.IReferences }
func NewReferencesDecorator ¶
func NewReferencesDecorator(nextReferences crefer.IReferences, topReferences crefer.IReferences) *ReferencesDecorator
Creates a new instance of the decorator. Parameters:
- nextReferences crefer.IReferences the next references or decorator in the chain.
- topReferences crefer.IReferences the decorator at the top of the chain.
Returns *ReferencesDecorator
func (*ReferencesDecorator) Find ¶
func (c *ReferencesDecorator) Find(locator interface{}, required bool) ([]interface{}, error)
Gets all component references that match specified locator. Parameters:
- locator interface{} the locator to find a reference by.
- required bool forces to raise an exception if no reference is found.
Returns []interface{}, error a list with matching component references and a ReferenceError when required is set to true but no references found
func (*ReferencesDecorator) GetAll ¶
func (c *ReferencesDecorator) GetAll() []interface{}
Gets all component references registered in this reference map. Returns []interface{} a list with component references.
func (*ReferencesDecorator) GetAllLocators ¶
func (c *ReferencesDecorator) GetAllLocators() []interface{}
Gets locators for all registered component references in this reference map. Returns []interface{} a list with component locators.
func (*ReferencesDecorator) GetOneOptional ¶
func (c *ReferencesDecorator) GetOneOptional(locator interface{}) interface{}
Gets an optional component reference that matches specified locator. Parameters:
- locator interface{} the locator to find references by.
Returns interface{} a matching component reference or null if nothing was found.
func (*ReferencesDecorator) GetOneRequired ¶
func (c *ReferencesDecorator) GetOneRequired(locator interface{}) (interface{}, error)
Gets a required component reference that matches specified locator. Parameters:
- locator interface{} the locator to find a reference by.
Returns interface{}, error a matching component reference, a ReferenceError when no references found.
func (*ReferencesDecorator) GetOptional ¶
func (c *ReferencesDecorator) GetOptional(locator interface{}) []interface{}
Gets all component references that match specified locator. Parameters:
- locator interface{} the locator to find references by.
Returns []interface{} a list with matching component references or empty list if nothing was found.
func (*ReferencesDecorator) GetRequired ¶
func (c *ReferencesDecorator) GetRequired(locator interface{}) ([]interface{}, error)
Gets all component references that match specified locator. At least one component reference must be present. If it doesn't the method throws an error. Parameters:
- locator interface{} the locator to find references by.
Returns []interface{} a list with matching component references and error a ReferenceError when no references found.
func (*ReferencesDecorator) Put ¶
func (c *ReferencesDecorator) Put(locator interface{}, component interface{})
Puts a new reference into this reference map. Parameters:
- locator interface{} a locator to find the reference by.
- component interface{} a component reference to be added.
func (*ReferencesDecorator) Remove ¶
func (c *ReferencesDecorator) Remove(locator interface{}) interface{}
Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use removeAll method instead. see RemoveAll Parameters:
- locator interface{} a locator to remove reference
Returns interface{} the removed component reference.
func (*ReferencesDecorator) RemoveAll ¶
func (c *ReferencesDecorator) RemoveAll(locator interface{}) []interface{}
Removes all component references that match the specified locator. Parameters:
- locator interface{} the locator to remove references by.
Returns []interface{} a list, containing all removed references.
type RunReferencesDecorator ¶
type RunReferencesDecorator struct { ReferencesDecorator // contains filtered or unexported fields }
References decorator that automatically opens to newly added components that implement IOpenable interface and closes removed components that implement ICloseable interface.
func NewRunReferencesDecorator ¶
func NewRunReferencesDecorator(nextReferences crefer.IReferences, topReferences crefer.IReferences) *RunReferencesDecorator
Creates a new instance of the decorator. Parameters:
- nextReferences crefer.IReferences the next references or decorator in the chain.
- topReferences crefer.IReferences the decorator at the top of the chain.
Returns *RunReferencesDecorator
func (*RunReferencesDecorator) Close ¶
func (c *RunReferencesDecorator) Close(correlationId string) error
Closes component and frees used resources. Parameters:
- correlationId string transaction id to trace execution through call chain.
Returns error
func (*RunReferencesDecorator) IsOpen ¶
func (c *RunReferencesDecorator) IsOpen() bool
Checks if the component is opened. Returns bool true if the component has been opened and false otherwise.
func (*RunReferencesDecorator) Open ¶
func (c *RunReferencesDecorator) Open(correlationId string) error
Opens the component. Parameters:
- correlationId string transaction id to trace execution through call chain.
Returns error
func (*RunReferencesDecorator) Put ¶
func (c *RunReferencesDecorator) Put(locator interface{}, component interface{})
Puts a new reference into this reference map. Parameters:
- locator interface{} a locator to find the reference by.
- component interface{} a component reference to be added.
func (*RunReferencesDecorator) Remove ¶
func (c *RunReferencesDecorator) Remove(locator interface{}) interface{}
Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use removeAll method instead. see removeAll Parameters:
- locator interface{} a locator to remove reference
Returns interfce{} the removed component reference.
func (*RunReferencesDecorator) RemoveAll ¶
func (c *RunReferencesDecorator) RemoveAll(locator interface{}) []interface{}
Removes all component references that match the specified locator. Parameters:
- locator interface{} the locator to remove references by.
Returns []interface{} a list, containing all removed references.