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

Want native Redis Support in Lucee/CFML? Ortus Redis Extension v2.0.0 Released!

Want native Redis Support in Lucee/CFML? Ortus Redis Extension v2.0.0 Released!

We are very excited to bring you another release for our Redis Lucee Extension. This is a major release spawning research of over 9 months. We have done great strides in this new extension to not only bring you the best scaling capabilities via Redis, but also now to introduce to the CFML world: Real-Time messaging with Redis Pub/Sub! Here is our full release notes in our brand new documentation book: What's New With 2.0.0!

Luis Majano
Luis Majano
August 05, 2022
Ortus Content Digest for week of August 5th

Ortus Content Digest for week of August 5th

It's August 5th... what has Ortus been publishing this week? We have the CFML News Podcast, some CFCasts and YouTube Videos, lots of Ortus and ITB Blog Posts. We have a lot more planned for next week as well.

Gavin Pickin
Gavin Pickin
August 05, 2022