RE: [coldbox:11167] Moving from Autowire to Wirebox not as easy as it sounds

Now if I remove the WireBox interceptor nothing, and I mean nothing gets Di’ed into my components.

Firstly, why would you want to remove the autowire interceptor? It is necessary to autowire handlers, plugins and interceptors. The autowire interceptor is not a replacement for WireBox, it uses WireBox to inject dependencies into pieces of the framework. It will go away eventually, is a requirement for now if you want autowiring to happen for handlers, plugins, and interceptors.

Secondly, it works fine for me. If remove the autowire interceptor, then get a user object that is in my models folder, via getPlugin(“beanFactory”).getModel(“user”), that user object is correctly autowired with all of its dependencies.

Thanks!

~Brad

Not if you do what I said in my next post Brad…

And as for removing it I was under the impression that WireBox is suppose to work without it, yes it works if you do but only to a point. Like I said in my next post, with an example given as well.

Ok several misconceptions.

WireBox is the bean factory abstracted to another name, ALL previous ColdBox functionality remains PLUS all the additional stuff. The autowire interceptor is needed (FOR NOW) so it bridges wirebox( or other DI engines) into ColdBox related objects: handlers, plugins, interceptors). As far as the conventions go, that is the case also, if you look in Binder.cfc you will see that it adds the model folder as the default scan location for coldbox in order to resolve the conventions. Also, the module service you can see it also adds more scan locations to a modules “model” folder. So again, all conventions remain as normal and previous versions. The compatibility bean factory is only left there to support cf7 and ALL of its features and capabilities are still in wirebox.

So, I am really at a loss at your issue of not finding model:MyService if /model/MyService.cfc exists as that is the core convention.

Luis F. Majano
President
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

Luis see my other post…

If I remove the interceptor AutoWire, then my code begins to fail.

The first failure is this code, which resides in a directory called interceptors in my root. Inside that file iut has this line of code.

property name=“pageService” inject=“model:pageService”;

And that is empty, and as I stated all I did was remove the interceptor AutoWire from the config.cfc for ColdBox… Are you beginning to see the problem?

Also another failure is with this line of code, which will no longer work.

beanFactory.appendExternalLocations(modules[interceptData.modulename].invocationPath & ‘.services’);

So if I switch the AutoWire interceptor off, then there are problems with the DI here. And I am asking why?

I thought I made that last line of code very clear in another post. maybe not. So this brings me back to ColdBox and WireBox as a package, if AutoWire is phased out, will ColdBox handle this under the hood when using code like the appendExternalLocation and others without me having to tell WireBox of these modifications?

And why does the interceptors directory I created work with AutoWire and not without?

The autowire interceptor is still needed to wire up your handlers, plugins and interceptors, without it there IS no autowire.

This: beanFactory.
appendExternalLocations(modules[interceptData.modulename].invocationPath & ‘.services’);

Still works, see the code:
if( instance.compatMode ){
instance.beanFactory.appendExternalLocations(arguments.locations);
return;
}
wirebox.getBinder().scanLocations( arguments.locations );

It adds to the scan locations.

So if I switch the AutoWire interceptor off, then there are problems with the DI here. And I am asking why?
You are not supposed to turn it off.

The autowire interceptor NEVER wired anything. It was a listener that delegated back to whatever DI library you are using to wire objects.

Luis F. Majano
President
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

Thanks Luis, it wasn’t clear from what I was reading if WireBox could live on its own. So when and if you do remove the AutoWire interceptor that you do make sure these problems will not exist, which knowing you will not be an issue.

You got it!!

The plan is for 3.5 to remove the autowire interceptor, so it becomes even easier.

Luis F. Majano
President
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

Cheers Luis, I somehow got it in my head that the AutoWire needed to be removed now.

Thanks all for helping me understand that was wrong.

Anytime my friend

Luis F. Majano
President
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