Data Configuration Settings
In the configure() method you can create a structure called wirebox in the variables scope that will hold the configuration data for WireBox. You can configure WireBox for operation using these structures or via programmatic method calls.
1
/**
2
* Configure WireBox
3
*/
4
function configure(){
5
6
// The WireBox configuration structure DSL
7
wireBox = {
8
9
// LogBox Config: instantiation path
10
logBoxConfig = "wirebox.system.ioc.config.LogBox",
11
12
// CacheBox
13
cacheBox = { enabled = true },
14
15
// Scope registration, automatically register a wirebox injector instance on any CF scope
16
// By default it registeres itself on application scope
17
scopeRegistration = {
18
enabled = true,
19
scope = "application", // server, cluster, session, application
20
key = "wireBox"
21
},
22
23
// DSL Namespace registrations
24
customDSL = {
25
// namespace = "mapping name"
26
},
27
28
// Custom Storage Scopes
29
customScopes = {
30
// annotationName = "mapping name"
31
},
32
33
// Package scan locations
34
scanLocations = [],
35
36
// Stop Recursions
37
stopRecursions = [],
38
39
// Parent Injector to assign to the configured injector, this must be an object reference
40
parentInjector = "",
41
42
// Register all event listeners here, they are created in the specified order
43
listeners = [
44
// { class="", name="", properties={} }
45
]
46
};
47
48
// Map Bindings below
49
}
Copied!
Please note that it is completely optional to use the implicit structure configuration. You can use the programmatic methods instead. Each configuration key has the same method in the binder for programmatic configuration.

logBoxConfig

The path to the LogBox Configuration object to use. By default it uses the one displayed below. If you are using WireBox within a ColdBox application, the LogBox configuration is taken from the ColdBox application.
1
wirebox.logBoxConfig = "wirebox.system.ioc.config.LogBox";
Copied!

cachebox

If you are using WireBox within a ColdBox application this setting is ignored and it will use the ColdBox application's CacheBox configuration. The following are the keys for this configuration structure:
1
wirebox.cacheBox = {
2
// Activate the CacheBox DSL and caching
3
enabled = false,
4
// An optional configuration file to use for loading CacheBox
5
configFile = "coldbox.system.ioc.config.CacheBox",
6
// A reference to an already instantiated CacheBox CacheFactory, instead of building one
7
cacheFactory = "",
8
//A class path namespace to use to create CacheBox: Default=coldbox.system.cache or wirebox.system.cache
9
classNamespace = ""
10
};
Copied!

scopeRegistration

This structure tells WireBox how to leach itself into any ColdFusion scope when initialized instead of you placing it in the scope.
1
wirebox.scopeRegistration = {
2
// activate scope registration
3
enabled = true,
4
// The CF scope to place the WireBox injector on
5
scope = "application",
6
// The key used to store it in the scope
7
key = "wireBox"
8
};
Copied!
Caution Scope registration must be enabled in order for Providers to work.

customDSL

Please refer to the Custom DSL section to find out more about custom DSLs, the following are just the way you declare them:
1
wirebox.customDSL = {
2
// The value of the DSL Namespace is the instantiation path
3
// of the DSL Namespace builder that implements wirebox.system.ioc.DSL.IDSLBuilder
4
cool = "my.path.CoolDSLBuilder",
5
funkyBox = "my.funky.DSLBuilder"
6
};
Copied!

customScopes

Please refer to the Custom scopes section to find out more about custom scopes, the following are just the way you declare them:
1
wirebox.customScopes = {
2
// The value of the instantiation path of the custom scope
3
// that implements coldbox.system.ioc.scopes.IScope.
4
// The name of the scope will be used when registered
5
// the scope annotation.
6
CoolSingletons = "my.path.SingletonScope",
7
FunkyTransaction = "my.funky.Transaction"
8
};
Copied!

scanLocations

The instantiation paths that this Injector will have registered to do object locations in order. So if you request an object called Service and no mapping has been configured for it, then WireBox will search all these scan locations for a Service.cfc in the specified order. The last lookup is the no namespace lookup which basically represents a createObject("component","Service") call. If you are using WireBox within a ColdBox application, ColdBox will register the models convention folder for you.
1
wirebox.scanLocations = ["models","com","org.majano"];
Copied!
Please note that order of declaration is the same as order of lookup, so it really matters. Also note that this setting only makes sense if you do not like to create mappings for objects and you just want WireBox to discover them for you.

stopRecursions

This is an array of class path's that WireBox will use to stop recursion on any object graph that has inheritance when looking for dependencies.
1
wirebox.stopRecursions = [ "transfer.com.TransferDecorator", "coldbox.system.EventHandler" ];
Copied!

parentInjector

This setting is actually a reference to another parent injector you would like this injector to set as its parent injector. Now say this sentence 10 times without hiccuping.
1
wirebox.parentInjector = application.coolInjector;
2
// or
3
wirebox.parentInjector = new coldbox.system.ioc.Injector( "old.legacy.binder" );
Copied!

listeners

This section only shows you how to register WireBox listeners, so please refer to the object life cycle events section for more information. This setting is an array of listener structure definitions that WireBox's event manager will use when broadcasting object life cycle events.
1
wirebox.listeners = [
2
{
3
// The path to the listener
4
class="path.to.CFC",
5
// A unique name for the listener
6
name="UniqueName",
7
// A structure of name-value pairs for configuring this interceptor
8
properties = {}
9
}
10
{class="my.AOPTracker"},
11
{class="annotationTransactioner",properties={target='*'} },
12
{class="Timer", name="CoolTimer"}
13
];
Copied!
Caution Please note that order of declaration is the same as order of execution, so it really matters, just like ColdBox Interceptors. Please note that if you are using WireBox within a ColdBox application, you can also register listeners as interceptors in your ColdBox configuration file.
Last modified 2yr ago