coldbox.system.ioc

Class Injector

railo-context.Component
        extended by coldbox.system.ioc.Injector
Class Attributes:
  • output : false
  •  
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
  • serializable : false
  •  
    All Implemented Interfaces:
    IInjector

    A WireBox Injector: Builds the graphs of objects that make up your application.

    Constructor Summary
    init([any binder='coldbox.system.ioc.config.DefaultBinder'], [any<struct> properties='[runtime expression]'], [any<Controller> coldbox=''])
          Constructor.
    Method Summary
    any autowire(any target, [any<Mapping> mapping], [any targetID=''], [any<Boolean> annotationCheck='false'])
         I wire up target objects with dependencies either by mappings or a-la-carte autowires.
    private any buildBinder(any binder, any properties)
         Load a configuration binder object according to passed in type.
    any buildInstance(any<Mapping> mapping, [any<struct> initArguments='[runtime expression]'])
         Build an instance, this is called from registered scopes only as they provide locking and transactions.
    any clearSingletons()
         Clear the singleton cache.
    void configure(any<Binder> binder, any<struct> properties)
         Configure this injector for operation, called by the init().
    private void configureCacheBox(any<struct> config)
         Configure a standalone version of cacheBox for persistence.
    private void configureEventManager()
         Configure a standalone version of a WireBox Event Manager.
    private void configureLogBox(any configPath)
         Configure a standalone version of logBox for logging.
    any<boolean> containsInstance(any name)
         Checks if this injector can locate a model instance or not.
    private void doScopeRegistration()
         Register this injector on a user specified scope.
    any<Binder> getBinder()
         Get the Injector's configuration binder object.
    any<Builder> getBuilder()
         Get the Injector's builder object.
    any<CacheFactory> getCacheBox()
         Get the instance of CacheBox linked in this Injector.
    any<Controller> getColdbox()
         Get the instance of ColdBox linked in this Injector.
    any getEventManager()
         Get the injector's event manager.
    any getInjectorID()
         Get the unique ID of this injector.
    any getInstance([any name], [any dsl], [any<struct> initArguments='[runtime expression]'], [any targetObject=''])
         Locates, Creates, Injects and Configures an object model instance.
    any<LogBox> getLogBox()
         Get the instance of LogBox configured for this Injector.
    any<BeanPopulator> getObjectPopulator()
         Get an object populator useful for populating objects from JSON,XML, etc.
    any<Injector> getParent()
         Get a reference to the parent injector instance, else an empty simple string meaning nothing is set.
    any getScope(any scope)
         Get a registered scope in this injector by name.
    any<struct> getScopeRegistration()
         Get the structure of scope registration information.
    any<struct> getScopes()
         Get all the registered scopes structure in this injector.
    any<ScopeStorage> getScopeStorage()
         Get the scope storage utility.
    any<Util> getUtil()
         Return the core util object.
    any getVersion()
         Get the Injector's version string.
    private void injectTarget(any target, any propertyName, any propertyObject, any scope, any argName)
         Inject a model object with dependencies via setters or property injections.
    any<boolean> isCacheBoxLinked()
         Checks if CacheBox is linked.
    any<boolean> isColdBoxLinked()
         Checks if Coldbox application context is linked.
    any locateInstance(any name)
         Tries to locate a specific instance by scanning all scan locations and returning the instantiation path.
    any<Injector> locateScopedSelf()
         Return a self reference using the scoped registration, mostly used by providers or scope widening objects.
    private void processAfterCompleteDI(any targetObject, any DICompleteMethods)
         Process after DI completion routines.
    private void processInjection(any targetObject, any DIData, any targetID)
         Process property and setter injection.
    private void processMixins(any targetObject, any mapping)
         Process mixins on the selected target.
    private void processProviderMethods(any targetObject, any mapping)
         Process provider methods on the selected target.
    any registerDSL(any namespace, any path)
         A direct way of registering custom DSL namespaces.
    private void registerListeners()
         Register all the configured listeners in the configuration file.
    any registerNewInstance(any name, any instancePath)
         Register a new requested mapping object instance thread safely and returns the mapping configured for this instance.
    private void registerScopes()
         Register all internal and configured WireBox Scopes.
    void removeFromScope()
         Remove the Injector from scope registration if enabled, else does nothing.
    void setParent(any<Injector> injector)
         Link a parent Injector with this injector.
    void shutdown()
         Shutdown the injector gracefully by calling the shutdown events internally.
     
    Methods inherited from class railo-context.Component
    None

    Constructor Detail

    init

    public init([any binder='coldbox.system.ioc.config.DefaultBinder'], [any<struct> properties='[runtime expression]'], [any<Controller> coldbox=''])

    Constructor. If called without a configuration binder, then WireBox will instantiate the default configuration binder found in: coldbox.system.ioc.config.DefaultBinder

    Parameters:
    binder - The WireBox binder or data CFC instance or instantiation path to configure this injector with
    properties - A structure of binding properties to passthrough to the Binder Configuration CFC
    coldbox - A coldbox application context that this instance of WireBox can be linked to, if not using it, we just ignore it.

    Method Detail

    autowire

    public any autowire(any target, [any<Mapping> mapping], [any targetID=''], [any<Boolean> annotationCheck='false'])

    I wire up target objects with dependencies either by mappings or a-la-carte autowires

    Parameters:
    target - The target object to wire up
    mapping - The object mapping with all the necessary wiring metadata. Usually passed by scopes and not a-la-carte autowires
    targetID - A unique identifier for this target to wire up. Usually a class path or file path should do. If none is passed we will get the id from the passed target via introspection but it will slow down the wiring
    annotationCheck - This value determines if we check if the target contains an autowire annotation in the cfcomponent tag: autowire=true|false, it will only autowire if that metadata attribute is set to true. The default is false, which will autowire anything automatically.

    buildBinder

    private any buildBinder(any binder, any properties)

    Load a configuration binder object according to passed in type

    Parameters:
    binder - The data CFC configuration instance, instantiation path or programmatic binder object to configure this injector with
    properties - A map of binding properties to passthrough to the Configuration CFC

    buildInstance

    public any buildInstance(any<Mapping> mapping, [any<struct> initArguments='[runtime expression]'])

    Build an instance, this is called from registered scopes only as they provide locking and transactions

    Parameters:
    mapping - The mapping to construct
    initArguments - The constructor structure of arguments to passthrough when initializing the instance

    clearSingletons

    public any clearSingletons()

    Clear the singleton cache


    configure

    public void configure(any<Binder> binder, any<struct> properties)

    Configure this injector for operation, called by the init(). You can also re-configure this injector programmatically, but it is not recommended.

    Parameters:
    binder - The configuration binder object or path to configure this Injector instance with
    properties - A structure of binding properties to passthrough to the Configuration CFC

    configureCacheBox

    private void configureCacheBox(any<struct> config)

    Configure a standalone version of cacheBox for persistence

    Parameters:
    config - The cacheBox configuration data structure

    configureEventManager

    private void configureEventManager()

    Configure a standalone version of a WireBox Event Manager


    configureLogBox

    private void configureLogBox(any configPath)

    Configure a standalone version of logBox for logging

    Parameters:
    configPath - The logBox configuration path to use

    containsInstance

    public any<boolean> containsInstance(any name)

    Checks if this injector can locate a model instance or not

    Specified by:
    containsInstance in interface IInjector
    Parameters:
    name - The object name or alias to search for if this container can locate it or has knowledge of it

    doScopeRegistration

    private void doScopeRegistration()

    Register this injector on a user specified scope


    getBinder

    public any<Binder> getBinder()

    Get the Injector's configuration binder object


    getBuilder

    public any<Builder> getBuilder()

    Get the Injector's builder object


    getCacheBox

    public any<CacheFactory> getCacheBox()

    Get the instance of CacheBox linked in this Injector. Empty if using standalone version


    getColdbox

    public any<Controller> getColdbox()

    Get the instance of ColdBox linked in this Injector. Empty if using standalone version


    getEventManager

    public any getEventManager()

    Get the injector's event manager


    getInjectorID

    public any getInjectorID()

    Get the unique ID of this injector


    getInstance

    public any getInstance([any name], [any dsl], [any<struct> initArguments='[runtime expression]'], [any targetObject=''])

    Locates, Creates, Injects and Configures an object model instance

    Specified by:
    getInstance in interface IInjector
    Parameters:
    name - The mapping name or CFC instance path to try to build up
    dsl - The dsl string to use to retrieve the instance model object, mutually exclusive with 'name'
    initArguments - The constructor structure of arguments to passthrough when initializing the instance
    targetObject - The object requesting the dependency, usually only used by DSL lookups

    getLogBox

    public any<LogBox> getLogBox()

    Get the instance of LogBox configured for this Injector


    getObjectPopulator

    public any<BeanPopulator> getObjectPopulator()

    Get an object populator useful for populating objects from JSON,XML, etc.


    getParent

    public any<Injector> getParent()

    Get a reference to the parent injector instance, else an empty simple string meaning nothing is set

    Specified by:
    getParent in interface IInjector

    getScope

    public any getScope(any scope)

    Get a registered scope in this injector by name

    Parameters:
    scope - The name of the scope

    getScopeRegistration

    public any<struct> getScopeRegistration()

    Get the structure of scope registration information


    getScopes

    public any<struct> getScopes()

    Get all the registered scopes structure in this injector


    getScopeStorage

    public any<ScopeStorage> getScopeStorage()

    Get the scope storage utility


    getUtil

    public any<Util> getUtil()

    Return the core util object


    getVersion

    public any getVersion()

    Get the Injector's version string.


    injectTarget

    private void injectTarget(any target, any propertyName, any propertyObject, any scope, any argName)

    Inject a model object with dependencies via setters or property injections

    Parameters:
    target - The target that will be injected with dependencies
    propertyName - The name of the property to inject
    propertyObject - The object to inject
    scope - The scope to inject a property into, if any else empty means it is a setter call
    argName - The name of the argument to send if setter injection

    isCacheBoxLinked

    public any<boolean> isCacheBoxLinked()

    Checks if CacheBox is linked


    isColdBoxLinked

    public any<boolean> isColdBoxLinked()

    Checks if Coldbox application context is linked


    locateInstance

    public any locateInstance(any name)

    Tries to locate a specific instance by scanning all scan locations and returning the instantiation path. If model not found then the returned instantiation path will be empty

    Parameters:
    name - The model instance name to locate

    locateScopedSelf

    public any<Injector> locateScopedSelf()

    Return a self reference using the scoped registration, mostly used by providers or scope widening objects


    processAfterCompleteDI

    private void processAfterCompleteDI(any targetObject, any DICompleteMethods)

    Process after DI completion routines

    Parameters:
    targetObject - The target object to do some goodness on
    DICompleteMethods - The array of DI completion methods to call

    processInjection

    private void processInjection(any targetObject, any DIData, any targetID)

    Process property and setter injection

    Parameters:
    targetObject - The target object to do some goodness on
    DIData - The DI data to use
    targetID - The target ID to process injections

    processMixins

    private void processMixins(any targetObject, any mapping)

    Process mixins on the selected target

    Parameters:
    targetObject - The target object to do some goodness on
    mapping - The target mapping

    processProviderMethods

    private void processProviderMethods(any targetObject, any mapping)

    Process provider methods on the selected target

    Parameters:
    targetObject - The target object to do some goodness on
    mapping - The target mapping

    registerDSL

    public any registerDSL(any namespace, any path)

    A direct way of registering custom DSL namespaces

    Parameters:
    namespace - The namespace you would like to register
    path - The instantiation path to the CFC that implements this scope, it must have an init() method and implement: coldbox.system.ioc.dsl.IDSLBuilder

    registerListeners

    private void registerListeners()

    Register all the configured listeners in the configuration file


    registerNewInstance

    public any registerNewInstance(any name, any instancePath)

    Register a new requested mapping object instance thread safely and returns the mapping configured for this instance

    Parameters:
    name - The name of the mapping to register
    instancePath - The path of the mapping to register

    registerScopes

    private void registerScopes()

    Register all internal and configured WireBox Scopes


    removeFromScope

    public void removeFromScope()

    Remove the Injector from scope registration if enabled, else does nothing


    setParent

    public void setParent(any<Injector> injector)

    Link a parent Injector with this injector

    Specified by:
    setParent in interface IInjector
    Parameters:
    injector - A WireBox Injector to assign as a parent to this Injector

    shutdown

    public void shutdown()

    Shutdown the injector gracefully by calling the shutdown events internally.

    Specified by:
    shutdown in interface IInjector