ColdBox Platform Version 2.6.3

coldbox.system.plugins
Class beanFactory

WEB-INF.cftags.component
        extended by coldbox.system.frameworkSupertype
            extended by coldbox.system.plugin
                extended by coldbox.system.plugins.beanFactory

public class beanFactory
extends plugin

I am the ColdBox beanFactory plugin that takes care of autowiring and dependency injection


Constructor Summary
init(any controller)
          constructor
 
Method Summary
 void addModelMapping([string alias], string path)
          Add a new model mapping. Ex: addModelMapping('myBean','security.test.FormBean'). The alias can be a single item or a comma delimmitted list
 void autowire(any target, [boolean useSetterInjection='true'], [boolean annotationCheck='false'], [string onDICompleteUDF='onDIComplete'], [boolean debugMode='false'], [string stopRecursion=''])
          Autowire an object using the ColdBox DSL
 Any create(string bean)
          Create a named bean, simple as that. If the bean has an init() method, it will be called.
private any getColdboxDSL(any definition)
          Get dependencies using the coldbox dependency DSL
private struct getConstructorArguments(any model='', [boolean debugMode='false'])
          The constructor argument collection for a model object
private BaseDictionary getDICacheDictionary()
          Get DICacheDictionary
private any getDSLDependency(any definition, [boolean debugMode='false'])
          get a dsl dependency
private any getIOCDependency(any definition)
          Get an IOC dependency
private any getLibraryDSL(any Definition)
          Get dependencies using the library dependency DSL
 any getModel(string name, [boolean useSetterInjection], [string onDICompleteUDF], [boolean debugMode], [string stopRecursion])
          Create or retrieve model objects by convention
private any getModelDSL(any definition, [boolean debugMode='false'])
          Get dependencies using the model dependency DSL
 struct getModelMappings()
          Get the model mappings structure
private struct getNewMDEntry()
          Get a new metadata entry structure
private any getOCMDependency(any definition)
          Get OCM dependencies
private any getWebserviceDSL(any Definition)
          Get webservice dependencies
private void injectBean(any targetBean, string beanName, any beanObject, string scope)
          Inject a bean with dependencies via setters or property injections
private array parseMetadata(any metadata, array dependencies, [boolean useSetterInjection='true'], [string stopRecursion=''])
          I get a components dependencies via searching for 'setters'
 Any populateBean(any formBean, [string scope=''], [boolean trustedSetter='false'])
          Populate a named or instantiated bean (java/cfc) from the request collection items
 any populateFromJSON(any formBean, string JSONString, [string scope=''], [boolean trustedSetter='false'])
          Populate a named or instantiated bean from a json string
 Any populateFromQuery(any formBean, query qry, [Numeric RowNumber='1'], [string scope=''], [boolean trustedSetter='false'])
          Populate a named or instantiated bean from query
 any populateFromStruct(any formBean, struct memento, [string scope], [boolean trustedSetter='false'])
          Populate a named or instantiated bean from a structure
 Any populateModel(any model, [string scope=''], [boolean trustedSetter='false'])
          Populate a named or instantiated model (java/cfc) from the request collection items
private void processAfterCompleteDI(any targetObject, [string onDICompleteUDF='onDIComplete'])
          see if we have a method to call after DI, and if so, call it
private void setDICacheDictionary(BaseDictionary DICacheDictionary)
          Set DICacheDictionary
private boolean stopClassRecursion(string classname, string stopRecursion)
          Should we stop recursion or not due to class name found
 
Methods inherited from class coldbox.system.plugin
getPluginDescription, getPluginName, getPluginVersion, getpluginPath, setPluginDescription, setPluginName, setPluginVersion
 
Methods inherited from class coldbox.system.frameworkSupertype
abort, announceInterception, dump, getColdboxOCM, getDatasource, getDebugMode, getHash, getInstance, getInterceptor, getMailSettings, getMyPlugin, getPlugin, getResource, getSetting, getSettingStructure, getSettingsBean, getcontroller, getfwLocale, htmlhead, include, includeUDF, locateDirectoryPath, locateFilePath, persistVariables, relocate, renderExternalView, renderView, rethrowit, runEvent, setDebugMode, setNextEvent, setNextRoute, setSetting, setcontroller, settingExists, throw
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init(any controller)

Method Detail

addModelMapping

public void addModelMapping([string alias], string path)
Add a new model mapping. Ex: addModelMapping('myBean','security.test.FormBean'). The alias can be a single item or a comma delimmitted list

Parameters:
alias - The model alias to use, this can also be a list of aliases. Ex: SecurityService,Security
path - The model class path (From the model conventions downward)

autowire

public void autowire(any target, [boolean useSetterInjection='true'], [boolean annotationCheck='false'], [string onDICompleteUDF='onDIComplete'], [boolean debugMode='false'], [string stopRecursion=''])
Autowire an object using the ColdBox DSL

Parameters:
target - The object to autowire
useSetterInjection - Whether to use setter injection alongside the annotations property injection. cfproperty injection takes precedence.
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 automatically.
onDICompleteUDF - After Dependencies are injected, this method will look for this UDF and call it if it exists. The default value is onDIComplete
debugMode - Whether to log debug messages. Default is false
stopRecursion - The stop recursion class. Ex: transfer.com.TransferDecorator. By default all ColdBox base classes are included.

create

public Any create(string bean)
Create a named bean, simple as that. If the bean has an init() method, it will be called.

Parameters:
bean - The type of bean to create and return. Uses full cfc path mapping.Ex: coldbox.beans.exceptionBean

getColdboxDSL

private any getColdboxDSL(any definition)
Get dependencies using the coldbox dependency DSL

Parameters:
definition - The dependency definition structure

getConstructorArguments

private struct getConstructorArguments(any model='', [boolean debugMode='false'])
The constructor argument collection for a model object

Parameters:
model - The model object
debugMode - Whether to log debug messages. Default is false

getDICacheDictionary

private BaseDictionary getDICacheDictionary()
Get DICacheDictionary


getDSLDependency

private any getDSLDependency(any definition, [boolean debugMode='false'])
get a dsl dependency

Parameters:
definition - The dependency definition structure
debugMode - Whether to log debug messages. Default is false

getIOCDependency

private any getIOCDependency(any definition)
Get an IOC dependency

Parameters:
definition - The dependency definition structure

getLibraryDSL

private any getLibraryDSL(any Definition)
Get dependencies using the library dependency DSL

Parameters:
Definition - The dependency definition structure

getModel

public any getModel(string name, [boolean useSetterInjection], [string onDICompleteUDF], [boolean debugMode], [string stopRecursion])
Create or retrieve model objects by convention

Overrides:
getModel in class frameworkSupertype
Parameters:
name - The name of the model to retrieve
useSetterInjection - Whether to use setter injection alongside the annotations property injection. cfproperty injection takes precedence.
onDICompleteUDF - After Dependencies are injected, this method will look for this UDF and call it if it exists. The default value is onDIComplete
debugMode - Debugging Mode or not
stopRecursion - A comma-delimmited list of stoprecursion classpaths.

getModelDSL

private any getModelDSL(any definition, [boolean debugMode='false'])
Get dependencies using the model dependency DSL

Parameters:
definition - The dependency definition structure
debugMode - Whether to log debug messages. Default is false

getModelMappings

public struct getModelMappings()
Get the model mappings structure


getNewMDEntry

private struct getNewMDEntry()
Get a new metadata entry structure


getOCMDependency

private any getOCMDependency(any definition)
Get OCM dependencies

Parameters:
definition - The dependency definition structure

getWebserviceDSL

private any getWebserviceDSL(any Definition)
Get webservice dependencies

Parameters:
Definition - The dependency definition structure

injectBean

private void injectBean(any targetBean, string beanName, any beanObject, string scope)
Inject a bean with dependencies via setters or property injections

Parameters:
targetBean - The bean that will be injected with dependencies
beanName - The name of the property to inject
beanObject - The bean object to inject.
scope - The scope to inject a property into.

parseMetadata

private array parseMetadata(any metadata, array dependencies, [boolean useSetterInjection='true'], [string stopRecursion=''])
I get a components dependencies via searching for 'setters'

Parameters:
metadata - The recursive metadata
dependencies - The dependencies
useSetterInjection - Whether to use setter injection alongside the annotations property injection. cfproperty injection takes precedence.
stopRecursion - The stop recursion class

populateBean

public Any populateBean(any formBean, [string scope=''], [boolean trustedSetter='false'])
Populate a named or instantiated bean (java/cfc) from the request collection items

Parameters:
formBean - This can be an instantiated bean object or a bean instantitation path as a string. This method follows the bean contract (set{property_name}). Example: setUsername(), setfname()
scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean

populateFromJSON

public any populateFromJSON(any formBean, string JSONString, [string scope=''], [boolean trustedSetter='false'])
Populate a named or instantiated bean from a json string

Parameters:
formBean - This can be an instantiated bean object or a bean instantitation path as a string. If you pass an instantiation path and the bean has an 'init' method. It will be executed. This method follows the bean contract (set{property_name}). Example: setUsername(), setfname()
JSONString - The JSON string to populate the object with. It has to be valid JSON and also a structure with name-key value pairs.
scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean

populateFromQuery

public Any populateFromQuery(any formBean, query qry, [Numeric RowNumber='1'], [string scope=''], [boolean trustedSetter='false'])
Populate a named or instantiated bean from query

Parameters:
formBean - This can be an instantiated bean object or a bean instantitation path as a string. If you pass an instantiation path and the bean has an 'init' method. It will be executed. This method follows the bean contract (set{property_name}). Example: setUsername(), setfname()
qry - The query to popluate the bean object with
RowNumber - The query row number to use for population
scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean

populateFromStruct

public any populateFromStruct(any formBean, struct memento, [string scope], [boolean trustedSetter='false'])
Populate a named or instantiated bean from a structure

Parameters:
formBean - This can be an instantiated bean object or a bean instantitation path as a string. If you pass an instantiation path and the bean has an 'init' method. It will be executed. This method follows the bean contract (set{property_name}). Example: setUsername(), setfname()
memento - The structure to populate the object with.
scope - Use scope injection instead of setters population.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean

populateModel

public Any populateModel(any model, [string scope=''], [boolean trustedSetter='false'])
Populate a named or instantiated model (java/cfc) from the request collection items

Overrides:
populateModel in class frameworkSupertype
Parameters:
model - The name of the model to get and populate or the acutal model object. If you already have an instance of a model, then use the populateBean() method
scope - Use scope injection instead of setters population. Ex: scope=variables.instance.
trustedSetter - If set to true, the setter method will be called even if it does not exist in the bean

processAfterCompleteDI

private void processAfterCompleteDI(any targetObject, [string onDICompleteUDF='onDIComplete'])
see if we have a method to call after DI, and if so, call it

Parameters:
targetObject - the target object to call on
onDICompleteUDF - After Dependencies are injected, this method will look for this UDF and call it if it exists.

setDICacheDictionary

private void setDICacheDictionary(BaseDictionary DICacheDictionary)
Set DICacheDictionary

Parameters:
DICacheDictionary

stopClassRecursion

private boolean stopClassRecursion(string classname, string stopRecursion)
Should we stop recursion or not due to class name found

Parameters:
classname - The class name to check
stopRecursion - The comma delimmitted list of stoprecursion classes

ColdBox Platform Version 2.6.3