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

Could you clarify what you mean by “autowire” as opposed to “WireBox”? Are you referring to the old compatible BeanFactory plugin that used the modelMappings.cfm config file or something else?

> With Autowire it is simple and easy to use, but I believe this will be phased out for favour of WieBox.

The old BeanFactory plugin has been phased out in favor of WireBox, but you will always be able to “autowire” your components. Any component you get from WireBox will be autowired (unless it is disabled for that component) and the autowire interceptor is still at play to wire up things like handlers. Point is though-- it’s still all WireBox doing the work.

> With Autowire, it automatically knows the directories to look into for DI. WireBox inside ColdBox does not.

I’m not sure if I follow that statement. Perhaps it’s because I’m not sure what the differentiation is between “Autowire” and “WireBox”.

> If I use the default settings for WireBox, non of the handlers, models, modules, plugins etc are automatically added to WireBox

If you mean that mappings are not created for these objects, that would be correct for handlers, modules, and plugins. Any model paths relative to the ROOT of the models folder should and will be accessible per the docs.

> property name="someService: inject=“model:someService”:

To confirm, for this to work the following file would need to exist: <site_root>/model/someService.cfc

> it will throw an undefined error, this is because the model Directory is not automatically being added to WireBox from ColdBox conventions,

Can you post your WireBox config?

> which means that if one is to change the convention, you have to manually change WireBox to reflect this change.

Yes. Did you expect something different? Using a convention different from the default one will require a configuration change.

> Why doesn’t ColdBox automatically add the convention paths to WireBox for us?

If by convention paths, you mean “<site_root>/model/”, it should. Please confirm the location of your models and your config for us so we can take a look.
Also, it is important to note that model conventions are NOT recursive. Therefore, <site_root>/model/security/securityService.cfc will not be picked up with the DSL “model:securityService”. You would need to use the full package name of “model:security.securityService”. If you want recursive searching (and don’t want to configure mappings for all your components) then use the mapDirectory() function in the config like so: mapDirectory(“model”). That should make the first DSL work (model:securityService)



Brad this is what I mean and I will show the config file.

In my ColdBox config file I have the following



//WireBox Integration
wireBox = {
enabled = true

Now if I remove the WireBox interceptor nothing, and I mean nothing gets Di’ed into my components. And that is because my WireBox.cfc has this.

// Package scan locations
scanLocations = [],

// Stop Recursions
stopRecursions = [],

Now it is my understanding that if I want it to work with WireBox, I am forced to manually add the scan locations to this. My beef so to speak, is that why is ColdBox not automatically adding the conventions to the scanLocations?

Does that make better sense? Till this is fixed I am currently forced to leave the AutoWire interceptor in place, and is why I am continually asking this question. I should not be forced to manually add to these locations, especially if I change the conventions in ColdBox, ColdBox should be smart enough to just do it for me.

Sorry but the last bit of information I gave is still wrong, that is not the real problem.

The real problem is with code like this.

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

All calls like this should automatically add any WireBox stuff, I should not have to manually do this. Does this make sense?

The point I made months ago is that there are all these ways to change the conventions via code, but not one of these methods adjust WireBox either. It is left up to us to do, and I still think this is wrong. ColdBox should do this for us.