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

ColdBox 7.2.0 Released

ColdBox 7.2.0 Released

ColdBox, a widely used development platform for ColdFusion (CFML), has unveiled version 7.2. Packed with compelling new features, bug fixes, and enhancements, this release is designed to empower developers by boosting productivity, refining scheduled task capabilities, and enhancing the overall reliability and efficiency of application development. This article will delve into the key highlights of ColdBox 7.2 and elucidate how these advancements can positively impact developers in their daily coding endeavors.

Luis Majano
Luis Majano
November 20, 2023
Into the Box 2023 Series on CFCast

Into the Box 2023 Series on CFCast

Excitement is in the air as we unleash the highly anticipated ITB 2023 series exclusively for our valued CFCast subscribers – and the best part? It's FREE for CFCast members! Now is the perfect time if you haven't joined the CFCast community yet. Plus, we've got an incredible End-of-Year deal that's too good to miss

Maria Jose Herrera
Maria Jose Herrera
November 20, 2023
Ortus Deals are Finally Here!

Ortus Deals are Finally Here!

The much-anticipated Ortus End-of-the-Year Sale has arrived, and it's time to elevate your development experience! Whether you're a seasoned developer, a tech enthusiast, or someone on the lookout for top-notch projects, Ortus has something special in store for you. Brace yourself for incredible discounts across a wide array of products and services, including Ortus annual events, books, cutting-edge services, and more.

Maria Jose Herrera
Maria Jose Herrera
November 15, 2023