coldbox.system.ioc.config

Class Binder

lucee.Component
    extended by coldbox.system.ioc.config.Binder
Direct Known Subclasses:
DefaultBinder

This is a WireBox configuration binder object. You can use it to configure a WireBox injector instance using our WireBox Mapping DSL

Class Attributes:
  • output : false
  •  
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
    Constructor Summary
    init(any<Injector> injector, [any config], [any properties='[runtime expression]'])
          Constructor: You can pass a data CFC instance, data CFC path or nothing at all for purely programmatic configuration.
    Method Summary
    any asEagerInit()
         If this method is called, the mapped object will be created once the injector starts up.
    any asSingleton()
         Map as a singleton, shortcut to using 'in( this.
    any bindAspect(Matcher<Matcher> classes, Matcher<Matcher> methods, any aspects)
         Bind a aspects to classes and methods.
    any cacheBox([any configFile=''], [any cacheFactory=''], [any enabled='true'], [any classNamespace='[runtime expression]'])
         Integrate with CacheBox.
    any configure()
         The main configuration method that must be overriden by a specific WireBox Binder configuration object.
    any constructor(any constructor)
         You can choose what method will be treated as the constructor.
    any extraAttributes(struct data)
         Adds a structure of metadata to be stored with the mapping for later retrieval by the developer in events, manually or builders.
    any getAppMapping()
         Get the ColdBox app mapping variable if context linked.
    any getAspectBindings()
         Get the collection of aspect bindings for this binder.
    any getCacheBoxConfig()
         Get the CacheBox Configuration Integration structure.
    any<Controller> getColdBox()
         Get the bounded ColdBox context for this binder, if any.
    any getCurrentMapping()
         Get the current set mapping (UTILITY method).
    any getCustomDSL()
         Get the custom dsl namespace registration structure.
    struct getCustomScopes()
         Get the registered custom scopes.
    any getDefaults()
         Get the default WireBox settings structure.
    any<Injector> getInjector()
         Get the bounded injector for this binder.
    any getListeners()
         Get the configured listeners array.
    any getLogBoxConfig()
         Get the logBox Configuration file to use.
    any<Mapping> getMapping(any name)
         Get a specific object mapping: coldbox.
    any getMappings()
         Get all the registered object mappings structure.
    any getMemento()
         Get the instance data structure.
    string getMetadataCache()
         Get the metadataCache setting.
    any getParentInjector()
         Get the parent injector reference this binder is linked to.
    any getProperties()
         Get the binded properties structure.
    any getProperty(any name, [any default])
         Get a binded property.
    any<java.util.LinkedHashMap> getScanLocations()
         Get the linked map of package scan locations for CFCs.
    any getScopeRegistration()
         Get the scope registration details structure.
    any getStopRecursions()
         Get all the stop recursion classes array.
    any inCacheBox([any key=''], [any timeout=''], [any lastAccessTimeout=''], [any provider='default'])
         Map an object into CacheBox.
    any initArg([any name], [any ref], [any dsl], [any value], [any javaCast], [any required='true'])
         Map a constructor argument to a mapping.
    any initWith()
         Positional or named value arguments to use when initializing the mapping.
    any into(any scope)
         Map an object into a specific persistence scope.
    any listener(any class, [any properties='[runtime expression]'], [any name=''], [any register='false'])
         Add a new listener configuration.
    void loadDataDSL([any rawDSL])
         Load a data configuration CFC data DSL.
    any logBoxConfig(any config)
         Set the logBox Configuration to use.
    any map(any alias, [any force='false'])
         Create a mapping to an object.
    any mapAspect(any aspect, boolean autoBinding='true')
         Map a new aspect.
    any mapDirectory(any packagePath, any include='', any exclude='', [any influence], [any filter], [any namespace=''], [any prepend='false'])
         Maps an entire instantiation path directory, please note that the unique name of each file will be used and also processed for alias inspection.
    any mapDSL(any namespace, any path)
         Register a new custom dsl namespace.
    any mapPath(any path, [any namespace=''], [any prepend='false'], [any force='false'])
         Directly map to a path by using the last part of the path as the alias.
    any mappingExists(any name)
         Check if an object mapping exists.
    any mapScope(any annotation, any path)
         Register a new WireBox custom scope.
    any match()
         Create a new matcher class for usage in class or method matching.
    any methodArg([any name], [any ref], [any dsl], [any value], [any javaCast])
         Map a method argument to a factory method.
    any mixins(any mixins='')
         Adds one, a list or an array of UDF templates to mixin to a CFC.
    any noAutowire()
         If you call this method on an object mapping, the object will NOT be inspected for injection/wiring metadata, it will use ONLY whatever you define in the mapping.
    any noInit()
         If you call this method on an object mapping, the object's constructor will not be called.
    any notThreadSafe()
         This is the default wiring of objects that allow circular dependencies.
    any onDIComplete(any methods)
         The methods to execute once DI completes on the mapping.
    any parent(any alias)
         this method lets you use an abstract or parent mapping as a template for other like objects.
    any parentInjector(any injector)
         Link a parent injector to this configuration binder.
    any processMappings()
         Process all registered mappings, called by injector when ready to start serving requests.
    any property(any name, [any ref], [any dsl], [any value], [any javaCast], [any scope='variables'], [any required='true'])
         Map a cfproperty to a mapping.
    boolean propertyExists(any name)
         Checks if a property exists.
    any providerMethod(any method, any mapping)
         Add a new provider method mapping.
    void removeScanLocations(any locations)
         Try to remove all the scan locations passed in.
    void reset()
         Reset the configuration back to the original binder defaults.
    any scanLocations(any locations)
         Register one or more package scan locations for CFC lookups.
    any scopeRegistration([any enabled='[runtime expression]'], [any scope='[runtime expression]'], [any key='[runtime expression]'])
         Use to define injector scope registration.
    any setMapping(any name, any mapping)
         Set a mapping object into the mappings map.
    string setMetadataCache(any metadataCache)
         Set the metadataCache setting.
    any setProperties(any properties)
         Set the binded properties structure.
    void setProperty(any name, any value)
         Create a new binding property.
    any setter(any name, [any ref], [any dsl], [any value], [any javaCast], [any argName])
         Map a setter function to a mapping.
    any stopRecursions(any classes)
         Configure the stop recursion classes.
    any threadSafe()
         Tells persistence scopes to build, wire, and do onDIComplete() on objects in an isolated lock.
    any to(any path)
         Map to a destination CFC class path.
    any toDSL(any dsl)
         Map to a dsl that will be used to create the mapped object.
    any toFactoryMethod(any factory, any method)
         Map to a factory and its executing method.
    any toJava(any path)
         Map to a java destination class path.
    any toProvider(any provider)
         Map to a provider object that must implement coldbox.
    any toRSS(any path)
         Map to a rss destination class path.
    any toValue(any value)
         Map to a constant value.
    any toWebservice(any path)
         Map to a webservice destination class path.
    any unMap(any name)
         Destroys a mapping by name.
    any virtualInheritance(any mapping)
         Tells WireBox to do a virtual inheritance mixin of the target and this passed mapping.
    any with(any alias)
         Used to set the current working mapping name in place for the maping DSL.
    any withInfluence([any influenceClosure])
         This is a closure that will be able to influence the creation of the instance.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init(any<Injector> injector, [any config], [any properties='[runtime expression]'])

    Constructor: You can pass a data CFC instance, data CFC path or nothing at all for purely programmatic configuration

    Parameters:
    injector - The Injector this binder is bound to
    config - The WireBox Injector Data Configuration CFC instance or instantiation path to it. Leave blank if using this configuration object programatically
    properties - A structure of binding properties to passthrough to the Binder Configuration CFC

    Method Detail

    asEagerInit

    public any asEagerInit()

    If this method is called, the mapped object will be created once the injector starts up. Basically, not lazy loaded


    asSingleton

    public any asSingleton()

    Map as a singleton, shortcut to using 'in( this.SCOPES.SINGLETON )'


    bindAspect

    public any bindAspect(Matcher<Matcher> classes, Matcher<Matcher> methods, any aspects)

    Bind a aspects to classes and methods

    Parameters:
    classes - The class matcher that will be affected with this aspect binding
    methods - The method matcher that will be affected with this aspect binding
    aspects - The name or list of names or array of names of aspects to apply to the classes and method matchers

    cacheBox

    public any cacheBox([any configFile=''], [any cacheFactory=''], [any enabled='true'], [any classNamespace='[runtime expression]'])

    Integrate with CacheBox

    Parameters:
    configFile - The configuration file to use for loading CacheBox if creating it.
    cacheFactory - The CacheBox cache factory instance to link WireBox to
    enabled - Enable or Disable CacheBox Integration, if you call this method then enabled is set to true as most likely you are trying to enable it
    classNamespace - The package namespace to use for creating or connecting to CacheBox. Defaults to: coldbox.system.cache

    configure

    public any configure()

    The main configuration method that must be overriden by a specific WireBox Binder configuration object


    constructor

    public any constructor(any constructor)

    You can choose what method will be treated as the constructor. By default the value is 'init', so don't call this method if that is the case.

    Parameters:
    constructor - The constructor method to use for the mapped object

    extraAttributes

    public any extraAttributes(struct data)

    Adds a structure of metadata to be stored with the mapping for later retrieval by the developer in events, manually or builders.

    Parameters:
    data - The data structure to store with the maping

    getAppMapping

    public any getAppMapping()

    Get the ColdBox app mapping variable if context linked


    getAspectBindings

    public any getAspectBindings()

    Get the collection of aspect bindings for this binder


    getCacheBoxConfig

    public any getCacheBoxConfig()

    Get the CacheBox Configuration Integration structure


    getColdBox

    public any<Controller> getColdBox()

    Get the bounded ColdBox context for this binder, if any


    getCurrentMapping

    public any getCurrentMapping()

    Get the current set mapping (UTILITY method)


    getCustomDSL

    public any getCustomDSL()

    Get the custom dsl namespace registration structure


    getCustomScopes

    public struct getCustomScopes()

    Get the registered custom scopes


    getDefaults

    public any getDefaults()

    Get the default WireBox settings structure


    getInjector

    public any<Injector> getInjector()

    Get the bounded injector for this binder


    getListeners

    public any getListeners()

    Get the configured listeners array


    getLogBoxConfig

    public any getLogBoxConfig()

    Get the logBox Configuration file to use


    getMapping

    public any<Mapping> getMapping(any name)

    Get a specific object mapping: coldbox.system.ioc.config.Mapping

    Parameters:
    name - The name of the mapping to retrieve

    getMappings

    public any getMappings()

    Get all the registered object mappings structure


    getMemento

    public any getMemento()

    Get the instance data structure


    getMetadataCache

    public string getMetadataCache()

    Get the metadataCache setting


    getParentInjector

    public any getParentInjector()

    Get the parent injector reference this binder is linked to


    getProperties

    public any getProperties()

    Get the binded properties structure


    getProperty

    public any getProperty(any name, [any default])

    Get a binded property. If not found it will try to return the default value passed, else it returns an exception

    Parameters:
    name - The name of the property
    default - A default value if property does not exist

    getScanLocations

    public any<java.util.LinkedHashMap> getScanLocations()

    Get the linked map of package scan locations for CFCs


    getScopeRegistration

    public any getScopeRegistration()

    Get the scope registration details structure


    getStopRecursions

    public any getStopRecursions()

    Get all the stop recursion classes array


    inCacheBox

    public any inCacheBox([any key=''], [any timeout=''], [any lastAccessTimeout=''], [any provider='default'])

    Map an object into CacheBox

    Parameters:
    key - You can override the key it will use for storing in cache. By default it uses the name of the mapping.
    timeout - Object Timeout, else defaults to whatever the default is in the choosen cache
    lastAccessTimeout - Object Timeout, else defaults to whatever the default is in the choosen cache
    provider - Uses the 'default' cache provider by default

    initArg

    public any initArg([any name], [any ref], [any dsl], [any value], [any javaCast], [any required='true'])

    Map a constructor argument to a mapping

    Parameters:
    name - The name of the constructor argument. NA: JAVA-WEBSERVICE
    ref - The reference mapping id this constructor argument maps to
    dsl - The construction dsl this argument references. If used, the name value must be used.
    value - The value of the constructor argument, if passed.
    javaCast - The type of javaCast() to use on the value of the argument. Only used if using dsl or ref arguments
    required - If the argument is required or not, by default we assume required DI arguments.

    initWith

    public any initWith()

    Positional or named value arguments to use when initializing the mapping. (CFC-only)


    into

    public any into(any scope)

    Map an object into a specific persistence scope

    Parameters:
    scope - The scope to map to, use a valid WireBox Scope by using binder.SCOPES.* or a custom scope

    listener

    public any listener(any class, [any properties='[runtime expression]'], [any name=''], [any register='false'])

    Add a new listener configuration.

    Parameters:
    class - The class of the listener
    properties - The structure of properties for the listner
    name - The name of the listener
    register - If true, registers the listener right away

    loadDataDSL

    public void loadDataDSL([any rawDSL])

    Load a data configuration CFC data DSL

    Parameters:
    rawDSL - The data configuration DSL structure to load, else look internally

    logBoxConfig

    public any logBoxConfig(any config)

    Set the logBox Configuration to use

    Parameters:
    config - The configuration file to use

    map

    public any map(any alias, [any force='false'])

    Create a mapping to an object

    Parameters:
    alias - A single alias or a list or an array of aliases for this mapping. Remember an object can be refered by many names
    force - Forces the registration of the mapping in case it already exists

    mapAspect

    public any mapAspect(any aspect, boolean autoBinding='true')

    Map a new aspect

    Parameters:
    aspect - The name or aliases of the aspect
    autoBinding - Allow autobinding of this aspect or not? Defaults to true

    mapDirectory

    public any mapDirectory(any packagePath, any include='', any exclude='', [any influence], [any filter], [any namespace=''], [any prepend='false'])

    Maps an entire instantiation path directory, please note that the unique name of each file will be used and also processed for alias inspection

    Parameters:
    packagePath - The instantiation packagePath to map
    include - An include regex that if matches will only include CFCs that match this case insensitive regex
    exclude - An exclude regex that if matches will exclude CFCs that match this case insensitive regex
    influence - The influence closure or UDF that will receive the currently working mapping so you can influence it during the iterations
    filter - The filter closure or UDF that will receive the path of the CFC to process and returns TRUE to continue processing or FALSE to skip processing
    namespace - Provide namespace to merge it in
    prepend - where to attach the namespace

    mapDSL

    public any mapDSL(any namespace, any path)

    Register a new custom dsl namespace

    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

    mapPath

    public any mapPath(any path, [any namespace=''], [any prepend='false'], [any force='false'])

    Directly map to a path by using the last part of the path as the alias. This is equivalent to map('MyService').to('model.MyService'). Only use if the name of the alias is the same as the last part of the path.

    Parameters:
    path - The class path to the object to map
    namespace - Provide namespace to merge it in
    prepend - Where to attach the namespace
    force - Forces the registration of the mapping in case it already exists

    mappingExists

    public any mappingExists(any name)

    Check if an object mapping exists

    Parameters:
    name - The name of the mapping to verify

    mapScope

    public any mapScope(any annotation, any path)

    Register a new WireBox custom scope

    Parameters:
    annotation - The unique scope name to register. This translates to an annotation value on CFCs
    path - The path to the CFC that implements this scope, it must have an init() method and implement: coldbox.system.ioc.scopes.IScope

    match

    public any match()

    Create a new matcher class for usage in class or method matching


    methodArg

    public any methodArg([any name], [any ref], [any dsl], [any value], [any javaCast])

    Map a method argument to a factory method

    Parameters:
    name - The name of the argument
    ref - The reference mapping id this method argument maps to
    dsl - The construction dsl this argument references. If used, the name value must be used.
    value - The value of the constructor argument, if passed.
    javaCast - The type of javaCast() to use on the value of the argument. Only used if using dsl or ref arguments

    mixins

    public any mixins(any mixins='')

    Adds one, a list or an array of UDF templates to mixin to a CFC

    Parameters:
    mixins - The udf include location(s) to mixin at runtime

    noAutowire

    public any noAutowire()

    If you call this method on an object mapping, the object will NOT be inspected for injection/wiring metadata, it will use ONLY whatever you define in the mapping.


    noInit

    public any noInit()

    If you call this method on an object mapping, the object's constructor will not be called. By default all constructors are called.


    notThreadSafe

    public any notThreadSafe()

    This is the default wiring of objects that allow circular dependencies. By default all object's constructors are the only thread safe areas


    onDIComplete

    public any onDIComplete(any methods)

    The methods to execute once DI completes on the mapping

    Parameters:
    methods - A list or an array of methods to execute once the mapping is created, inited and DI has happened.

    parent

    public any parent(any alias)

    this method lets you use an abstract or parent mapping as a template for other like objects

    Parameters:
    alias - The parent class to copy dependencies and definitions from

    parentInjector

    public any parentInjector(any injector)

    Link a parent injector to this configuration binder

    Parameters:
    injector - A parent injector to configure link

    processMappings

    public any processMappings()

    Process all registered mappings, called by injector when ready to start serving requests


    property

    public any property(any name, [any ref], [any dsl], [any value], [any javaCast], [any scope='variables'], [any required='true'])

    Map a cfproperty to a mapping

    Parameters:
    name - The name of the cfproperty to inject into
    ref - The reference mapping id this property maps to
    dsl - The construction dsl this property references. If used, the name value must be used.
    value - The value of the property, if passed.
    javaCast - The type of javaCast() to use on the value of the property. Only used if using dsl or ref arguments
    scope - The scope in the CFC to inject the property to. By default it will inject it to the variables scope
    required - If the property is required or not, by default we assume required DI properties.

    propertyExists

    public boolean propertyExists(any name)

    Checks if a property exists

    Parameters:
    name - The name of the property

    providerMethod

    public any providerMethod(any method, any mapping)

    Add a new provider method mapping

    Parameters:
    method - The provided method to override or inject as a provider
    mapping - The mapping to provide via the selected method

    removeScanLocations

    public void removeScanLocations(any locations)

    Try to remove all the scan locations passed in

    Parameters:
    locations - Locations to remove from the lookup. A list or array of locations

    reset

    public void reset()

    Reset the configuration back to the original binder defaults


    scanLocations

    public any scanLocations(any locations)

    Register one or more package scan locations for CFC lookups

    Parameters:
    locations - A list or array of locations to add to package scanning.e.g.: ['coldbox','com.myapp','transfer']

    scopeRegistration

    public any scopeRegistration([any enabled='[runtime expression]'], [any scope='[runtime expression]'], [any key='[runtime expression]'])

    Use to define injector scope registration

    Parameters:
    enabled - Enable registration or not (defaults=false) Boolean
    scope - The scope to register on, defaults to application scope
    key - The key to use in the scope, defaults to wireBox

    setMapping

    public any setMapping(any name, any mapping)

    Set a mapping object into the mappings map

    Parameters:
    name - The name of the mapping to register
    mapping - The mapping object to register

    setMetadataCache

    public string setMetadataCache(any metadataCache)

    Set the metadataCache setting

    Parameters:
    metadataCache - The name of the cache for metadata caching

    setProperties

    public any setProperties(any properties)

    Set the binded properties structure

    Parameters:
    properties

    setProperty

    public void setProperty(any name, any value)

    Create a new binding property

    Parameters:
    name - The name of the property
    value - The value of the property

    setter

    public any setter(any name, [any ref], [any dsl], [any value], [any javaCast], [any argName])

    Map a setter function to a mapping

    Parameters:
    name - The name of the setter method (without 'set').
    ref - The reference mapping object this setter method will receive
    dsl - The construction dsl this setter method will receive
    value - The value to pass into the setter method.
    javaCast - The type of javaCast() to use on the value. Only used if using dsl or ref arguments
    argName - The name of the argument to use, if not passed, we default it to the setter name

    stopRecursions

    public any stopRecursions(any classes)

    Configure the stop recursion classes

    Parameters:
    classes - A list or array of classes to use so the injector can stop when looking for dependencies in inheritance chains

    threadSafe

    public any threadSafe()

    Tells persistence scopes to build, wire, and do onDIComplete() on objects in an isolated lock. This will disallow circular references unless object providers are used. By default all object's constructors are the only thread safe areas


    to

    public any to(any path)

    Map to a destination CFC class path.

    Parameters:
    path - The class path to the object to map

    toDSL

    public any toDSL(any dsl)

    Map to a dsl that will be used to create the mapped object

    Parameters:
    dsl - The DSL string to use

    toFactoryMethod

    public any toFactoryMethod(any factory, any method)

    Map to a factory and its executing method.

    Parameters:
    factory - The mapping factory reference name
    method - The method to execute

    toJava

    public any toJava(any path)

    Map to a java destination class path.

    Parameters:
    path - The class path to the object to map

    toProvider

    public any toProvider(any provider)

    Map to a provider object that must implement coldbox.system.ioc.IProvider or a closure or UDF

    Parameters:
    provider - The provider to map to

    toRSS

    public any toRSS(any path)

    Map to a rss destination class path.

    Parameters:
    path - The class path to the object to map

    toValue

    public any toValue(any value)

    Map to a constant value

    Parameters:
    value - The value to bind to

    toWebservice

    public any toWebservice(any path)

    Map to a webservice destination class path.

    Parameters:
    path - The class path to the object to map

    unMap

    public any unMap(any name)

    Destroys a mapping by name

    Parameters:
    name - The name of the mapping to register

    virtualInheritance

    public any virtualInheritance(any mapping)

    Tells WireBox to do a virtual inheritance mixin of the target and this passed mapping

    Parameters:
    mapping - The mapping name of CFC to create the virtual inheritance from.

    with

    public any with(any alias)

    Used to set the current working mapping name in place for the maping DSL. An exception is thrown if the mapping does not exist yet.

    Parameters:
    alias - The name of the maping to set as current for working with it via the mapping DSL

    withInfluence

    public any withInfluence([any influenceClosure])

    This is a closure that will be able to influence the creation of the instance

    Parameters:
    influenceClosure