WireBox doesn't observe inherited annotations

My coworker noticed recently that WireBox doesn’t use inherited annotations.

Consider the following two classes:

abstract.cfc

concrete.cfc

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.

https://github.com/ColdBox/coldbox-platform/pull/89

Thanks!

~Brad

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

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

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

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

concrete.cfc

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

Thanks!

~Brad

Brad,

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

Thanks

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

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano