WireBox doesn't observe inherited annotations

41 views
Skip to first unread message

br...@bradwood.com

unread,
Apr 26, 2012, 3:06:59 PM4/26/12
to ColdBox List
My coworker noticed recently that WireBox doesn't use inherited annotations. 

Consider the following two classes:

abstract.cfc
<cfcomponent scope="session">
</cfcomponent>

concrete.cfc
<cfcomponent extends="abstract">
</cfcomponent>

If you ask WireBox to create an instance of abstract it will be persisted in the session scope.  However, if you create an instance of concrete it doesn't inherit the scope annotation from it's super class.

This is because getMetaData(concrete) represents inherited attributes in the "extends" key and doesn't combine them down.  WireBox currently solves that for functions and properties by recursion in the processDIMetadata method.

I propose that WireBox be changed to also look at extending classes to determine component annotations.  I have submitted a pull request which implements a utility method called getInheritedMetaData() that returns a combined metadata struct containing the "final" inherited list of properties, functions, and component annotations for Wirebox to use.  This means that component annotations will now be properly inherited plus processDIMetadata() doesn't need to recurse any longer.


Thanks!

~Brad

Luis Majano

unread,
Apr 26, 2012, 3:08:48 PM4/26/12
to col...@googlegroups.com
Brad, does this take in consideration that last annotation?

Being, don't override the scope or any other component annotation if already found? This is important, so parent's don't override children annotations
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

br...@bradwood.com

unread,
Apr 26, 2012, 3:13:23 PM4/26/12
to col...@googlegroups.com
Yes, it follows normal inheritance rules.  The getInheritedMetadata() function actually uses recursion to find the top most super class, it then works its way back down overwriting properties, functions, and annotations as it goes.  That way, the children classes have last say.

For example:

abstract.cfc
<cfcomponent scope="session">
</cfcomponent>

concrete.cfc
<cfcomponent scope="server" extends="abstract">
</cfcomponent>

An instance of concrete would have a scope of server since that overrides the scope of session in the parent class.

Thanks!

~Brad

Luis Majano

unread,
Apr 27, 2012, 11:25:02 AM4/27/12
to col...@googlegroups.com
Brad,

Would you mind doing some unit tests for this before we incorporate it? 

Thanks

Luis Majano
--

Brad Wood

unread,
Apr 27, 2012, 7:23:23 PM4/27/12
to col...@googlegroups.com
I will give it a try. I'm still kind of groping around when it comes to getting the unit tests running, but I'll see if I can get the tests you have bundled with CB running and then add some more around the stuff I changed.

I've got another pull request I'm working to allow provider annotations and methods to to provide DSLs instead of just specific mapping IDs. I guess I'd better write some unit tests for those as well before you even ask :)

Thanks!

~Brad

Sent from my ASUS Eee Pad

Luis Majano

unread,
Apr 28, 2012, 11:33:38 AM4/28/12
to col...@googlegroups.com
Jeje. Always instigating on testing. Also as a overview

The test are here /coldbox/testing/cases/IOC
The test model objects are here
/coldbox/testing/testmodel

So I'd you add things to the binder or mapping add the tests to the appropriate unit. However I also have a construction integration test that tests object constructions an dependencies. This one is under
/cases/IOC/injectorConstructionTest.cfc

Which uses a config binder in the /cases/IOC/config/samples directory

This last step is important a part from the individual unit tests because this one puts all of it together to verify object creation, di and aop

--
Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

Brad Wood

unread,
May 29, 2012, 4:54:49 PM5/29/12
to col...@googlegroups.com
Ok, I took a stab at some unit tests.  Please provide feedback as to whether or not I'm doing them right.  :)

Thanks!

~Brad
Reply all
Reply to author
Forward
0 new messages