Blog

WireBox DI & AOP v1.3.1 Released

Luis Majano March 27, 2012

Spread the word

Luis Majano

March 27, 2012

Spread the word


Share your thoughts

As part of release week, we are proud to announce yet another release to WireBox, our Dependency Injection and AOP Framework.  Here are the resources:

WireBox is a ColdFusion Dependency Injection and AOP Framework that can work with any ColdFusion framework or no framework at all.  The major features of this release are laid out below or you can read our What's New Guide for full Geeky details!

  • Lots of fixes on concurrency and DI automation
  • Binder declarations now take precendence over annotations
  • Setter injections now allow you to declare the name of the argument used in the setter instead of by convention.

AOP 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 allow for runtime mixins to occur. You start off my mapping the base or source CFC and then mapping the target CFC and declaring 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 is a great way for framework or library developers also to allow for inheritance or not when using their libraries or frameworks.

Mapping 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
	});

You can then later retrieve this metadata on a mapping and use it according to your needs.

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);
	}
}

Runtime Mixins()

WireBox version 1.3.1 now allows you to do runtime mixins on any target component.  So take advantage of a dynamic language to the fullest!  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 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");

ORM Services

ColdBox introduced some great ORM abstractions, event models and service layers that help you develop applications using ColdFusion ORM with much ease.  It can create even virtual service layers and also we introduced ActiveEntity, which gives you the ability to use a similar Active Record pattern with hibernate ORM entities.  All of our ORM services are now standalone and can be used alongside WireBox and any or no ColdFusion framework at all.  A part from giving you great enhanced ORM capabilities, you can now do dependency injection and AOP on ORM entities.  We also tapped in to Hibernate and exposed Hibernate Criteria Queries via our own WireBox Hibernate Criteria Builder DSL.

Here are some cool samples of what you can do with WireBox ORM Services:

Active Entity

user = entityNew("User");
usersFound = user.count();

coolUser = user.new( {firstName="Luis",lastName="Majano",Awesome=true} );
coolUser.save();

luis = user.get("123");
users = user.findAll({age=30});

WireBox Hibernate Criteria Builders

// Base ORM Service
c = newCriteria( 'entityName' );
// Virtual
c = newCriteria();

// Examples
var results = c.like("firstName","Lui%")
     .maxResults( 50 )
     .order("balance","desc")
     .and( 
          c.restrictions.between( "balance", 200, 300),
          c.restrictions.eq("department", "development")
     )
     .list();

// with pagination
var results = c.like("firstName","Lui%")
     .order("balance","desc")
     .and( 
          c.restrictions.between( "balance", 200, 300),
          c.restrictions.eq("department", "development")
     )
     .list(max=50,offset=20);

// more complex
var results = c.in("name","luis,fred,joe")
     .OR( c.restrictions.isNull("age"), c.restrictions.eq("age"

So what are you waiting for? Get the greatest ColdFusion dependency injection and AOP library now!

 

 

Add Your Comment

Recent Entries

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Unfortunately, we often hear this message from clients who thought it would never happen to them... until it did. Some believed they could delay the expense of Implementing ColdFusion security best practices for one year, while others were tempted to put it off for just a few months. However, in today's rapidly evolving digital landscape, the security of web applications, including ColdFusio...

Cristobal Escobar
Cristobal Escobar
April 16, 2024
Ortus March Newsletter

Ortus March Newsletter

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
April 01, 2024
Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024