Now I can use the ortus
scope in my mappings DSL and even my annotations, isn't that cool!
The scoping process must be done by using some of the referenced injector's methods:
buildInstance(mapping, initArguments)
autowire()
These methods must be called sequentially in order to avoid circular reference locks. The first method buildInstance
is used to construct and initialize an object instance. The autowire method is used then to process DI and AOP on the targeted object. Let's look at my Ortus Scope:
Caution Always make sure that you use the
buildInstance
method and then store the results in the scope before wiring is done to avoid endless loops errors.
WireBox allows you to create your own object persistence scopes so you can have full control on their lifecycle. This is easily done in the following process:
Create a CFC that implements wirebox.system.ioc.scopes.IScope
Register your custom scope in your configuration binder
You can create your own persistence scope or if you are getting funky, override the internal persistence scopes with your own logic.