Blog

WireBox version 1.3.0 Released!

Luis Majano November 28, 2011

Spread the word

Luis Majano

November 28, 2011

Spread the word


Share your thoughts

Welcome to another release of WireBox, Dependency Injection and AOP library for ColdFusion, version 1.3.0. This release introduces a few fixes and some incredibly new useful features that will enhance not only your AOP but DI capabilities in your ColdBox and non-ColdBox applications. Also, remember that WireBox can work in ANY ColdFusion framework and not only ColdBox. ColdBox only uses WireBox as its default DI engine for operation.

The following are the enhancements for this version 1.3.0 release:

Setter Injection Improvements

Allow Setter injection to specify argument names or pass positionally. Before you could not specify the name of the argument in a setter method and had to comply to the convention of using the same name as the setter. Now you can define the argument name using the argName argument.

mapPath("my.path.Service)
	.setter(name="CategoryDAO",ref="CategoryDAO", argName="dao");

This would expect the setter signature to be:

function setCategoryDAO(required dao){}

AOP Aspect Improvements

The AOP Method Invocation object now has two new methods: getTargetMapping() and getMethodMetadata(). The getTargetMapping() gives you the mapping object for the target so you can request any metadata, wiring, and construction information. The getMethodMetadata() gives you the actual metadata structure the method that was adviced contains. This is great to determine if the method has a specific annotation or not. You can now build AOP aspects that can determine a target's mapping information and specific method annotations.

Virtual Inheritance

You can now make two CFCs blend together simulating a virtual runtime inheritance. It will grab the target CFC and blend into it all of the virtual inheritance CFC's methods and properties. It will then also create a $super reference in the target and a $superinit() reference. This is a great alternative to real inheritance and allows for runtime mixins to occur. You start off my mapping the base or source CFC from which you will virtually inherit from and then mapping the target CFC and declaring it a virtualInheritance to the base or source CFC:

// Declare base CFC 
map("BaseModel")
.to("model.base.BaseModel"); map("UserService")
.to("model.users.UserService")
.virtualInheritance("BaseModel");

This will grab all methods and properties in the BaseModel CFC and mix them into the UserService, then create a virtual $super scope which will map to an instantiated instance of the BaseModel object that will exist inside of the UserService in case you need to do method overrides much how you do overrides already. This is a great way to change CFCs dynamically at runtime. You are restricted to 1 virtual inheritance per target CFC at this point in time.

Mapping Extra Attributes

You can now store a-la-carte attributes in a specific mapping so it can be retrieved at a later time by either an AOP aspect or Events. This is a great way to store custom metadata about an object so it can be read later for some meaningful purpose. Let's say you want to tag a mapping with a custom type that is not so easily determined from the object instance itself. You don't want to do all kinds of introspection in order to know what object you received in an aspect or an event.


map("MyPlugin") .to("plugins.CustomPlugin") .extraAttributes({ pluginPath = pluginLocation, custom = arguments.custom, module = arguments.module, isPlugin = true });

This mapping declares that an object has some extra attributes that will be stored in the mapping, such as the location, if it is a custom plugin, if it belongs to a module and a marker that determines if it is a plugin or not. This is then incredibly useful when you have an attached listener to WireBox:

function afterInstanceAutowire(event, interceptData){ 	
  var attribs = interceptData.mapping.getExtraAttributes(); 	
  var iData 	= {}; 	 	
  // listen to plugins only 	
  if( structKeyExists(attribs, "isPlugin") ){ 		
    //Fill-up Intercepted MetaData 		
    iData.pluginPath = attribs.pluginPath; 		
    iData.custom 	 = attribs.custom;	 		
    iData.module 	 = attribs.module;		 		
    iData.oPlugin    = interceptData.target; 		 		
    //Fire My Own Custom Interception 		
    instance.interceptorService.processState("afterPluginCreation",iData); 	
    } 
  } 

As you can see from this sample, the extra attributes are incredibly essential, as the listener just sends the target object. It would take lots of introspection and metadata inspections in order for me to determine if the incoming object is my system's plugin or not. However, with the extra attributes, it is just a snap!

Runtime Mixins()

You can now use our spanking new mixins() binder method to define that a mapping should be mixed in with one or more set of UDF templates. It will then at runtime inject all the methods in those templates and mix them into the target object as public methods.

// map with mixins 
map("MyService") 	
  .to("model.UserService") 	
  .mixins("/helpers/base");  
  
// map with mixins as list 
map("MyService") 	
  .to("model.UserService") 	
  .mixins("/helpers/base, /helpers/model");  

// map with mixins as array 
map("MyService") 	
  .to("model.UserService") 	
  .mixins( ["/helpers/base", "/helpers/model"] ); 

This will grab all the methods in the base.cfm and model.cfm templates and inject them into the target mapping as public methods. Awesome right?

Expanded ColdBox DSL

  • coldbox:setting:mySetting@module : You can now inject easily a module setting by using the @module directive.
  • coldbox:moduleSettings:{module} : You can now inject the entire module settings structure
  • coldbox:moduleConfig:{module} : You can now inject the entire module configuration structure

Download Now!

So if you are using WireBox standalone, get the update or if you are using ColdBox, then just upgrade to the latest ColdBox build, 3.5.0 BETA

Add Your Comment

Recent Entries

Must-See Into the Box 2025 Sessions for CommandBox Users!

Must-See Into the Box 2025 Sessions for CommandBox Users!

Power Up your CommandBox experience and practices at Into the Box 2025

Want to get hands-on with the new CommandBox features or learn how others are pushing it to the next level? These are the must-see sessions at ITB 2025 if you're a CommandBox user:

Maria Jose Herrera
Maria Jose Herrera
April 21, 2025
Must-See ITB 2025 Sessions for TestBox Users!

Must-See ITB 2025 Sessions for TestBox Users!

Are you a fan of TestBox or looking to level up your testing game in 2025? Whether you're just getting started with unit testing or you're already building advanced specs for ColdBox and BoxLang apps, Into the Box 2025 has an exciting lineup tailored just for you. Into the Box 2025 has an exciting lineup tailored just for you. With the recent launch of TestBox 6.3.0 we have amazing new tools, features and tips and tricks to get your testing experience to the next level, review our sessions and test like a pro efficiently and easy!

From hands-on testing strategies to BoxLang innovations, here are the sessions you won’t want to miss this May — and why they matter to you as a TestBox user.

Maria Jose Herrera
Maria Jose Herrera
April 17, 2025
The Into the Box 2025 Agenda is LIVE and Done!

The Into the Box 2025 Agenda is LIVE and Done!

The wait is over! The official Into the Box 2025 agenda is now live — and it's packed with high-impact sessions designed for modern CFML and BoxLang developers. Whether you’re building APIs, modernizing legacy apps, diving into serverless, or exploring AI integrations, this is the conference you’ve been waiting for.

Here’s a look at what you can expect — categorized by key topics to help you plan your learning journey, there’s something for everyone covering modern CFML tools and BoxLang:

Maria Jose Herrera
Maria Jose Herrera
April 15, 2025