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

Ortus June 2024 Newsletter!

Ortus June 2024 Newsletter!

Welcome to the latest edition of the Ortus Newsletter! This month, we're excited to bring you highlights from our sessions at CFCamp and Open South Code, as well as a sneak peek into our upcoming events. Discover the latest developments in BoxLang, our dynamic new JVM language, and catch up on all the insightful presentations by our expert team. Let's dive in!

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang June 2024 Newsletter!

BoxLang June 2024 Newsletter!

We're thrilled to bring you the latest updates and exciting developments from the world of BoxLang. This month, we're diving into the newest beta release, introducing a new podcast series, showcasing innovative integrations, and sharing insights from recent events. Whether you're a seasoned developer or just getting started, there's something here for everyone to explore and enjoy.

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang 1.0.0 Beta 3 Launched

BoxLang 1.0.0 Beta 3 Launched

We are thrilled to announce the release of BoxLang 1.0.0-Beta 3! This latest beta version is packed with exciting new features and essential bug fixes, including robust encryption functionality, enhanced Java interoperability, and more efficient event handling. Key highlights include the introduction of query caching capabilities, seamless coercion of Java Single Abstract Method (SAM) interfaces from BoxLang functions, and support for virtual thread executors. So, let’s dive into the details of what’s new in BoxLang 1.0.0-Beta 3 and how you can start leveraging these updates today!

Luis Majano
Luis Majano
June 28, 2024