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

BoxLang 1.0.0 Beta 7 Launched

BoxLang 1.0.0 Beta 7 Launched

We are pleased to announce the release of BoxLang 1.0.0-Beta 7! This latest beta version includes improvements and essential bug fixes, but more importantly it certifies the execution of ColdBox HMVC and TestBox.

What is BoxLang?

BoxLang is a modern dynamic JVM language that can be deployed on multiple runtimes: operating system (Windows/Mac/*nix/Embedded), web server, lambda, iOS, android, web assembly, and more. BoxLang combines many features from different progr

Luis Majano
Luis Majano
July 26, 2024
New BoxLang Feature: Java Method References and Higher-Order Functions

New BoxLang Feature: Java Method References and Higher-Order Functions

We’ve added more goodies to our BoxLang Java interop: method references and higher-order functions. CFML has never let you do these things, making Java Interop feel like a second-class citizen. But with BoxLang, we’re elevating Java integration to a new level.

Maria Jose Herrera
Maria Jose Herrera
July 26, 2024
Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Are you a CFML developer looking to take your skills to the next level? Look no further than the ColdBox from Zero to Hero Virtual Live Training! This intensive two-day course will equip you with the knowledge and expertise to build robust and scalable applications using ColdBox 7, the latest version of the most popular CFML MVC framework.

What You'll Learn:

  • Master the Fun...

Cristobal Escobar
Cristobal Escobar
July 24, 2024