So that makes a little more sense, one of the issues I have been having is examples/docs/other peoples code using different syntax but now I see why. Thanks Aaron!
So I got everything working, thanks for pointing me in the right direction. My next question that kind of goes with this is…
If all I want to do is autowire dependencies that are in my model then there is no need for an ioc(coldspring/lightwire/wirebox) correct? If I start writing custom components or some other code that I will want to use an ioc to wire the dependencies for me. If not what are the advantages of using a framework if thats all I am doing? I know that most of the time I am going to need one but I am just trying to get a grasp on everything here.
I am used to having to manage all of my dependencies in ColdSpring where it looks like the bean factory can load my /model/.* into any of my handlers by using the dsl.
Yes, you do not need to use any dependency management if you are creating objects that themselves do not require objects from outside your /model folder. Your /model folder is your domain. You are responsible for how it behaves.
However, I would recommend you instantiate your singletons with ColdBox’s DI (now called WireBox). The day will come when you will may want to inject something as simple as a setting into the model to control its behavior and you will be glad your handlers/interceptors created your service/DAO using the framework.
A real world example is a /model/SearchService.cfc I just wrote for a project. The SolrSearchService is autowired into the /handlers/Search.cfc which allows ColdBox to inject settings such as “Environment” into the model. However, the /model/SearchService.cfc creates a new SolrGateway.cfc in a OnDIComplete() method (which is executed by ColdBox once all dependencies are injected). When this SolrGateway is created I simply use the new operator: SolrGateway = new model.SolrGateway({…});.
Also, when I have transient objects (like those that represent a User) I do not use any dependency injection to ensure things are as fast as possible.
Makes total sense, the autowire feature of the framework simply wires components into other components… It’s not truly a dependency injection framework. right?
It is a DI framework, but it is abstracted in such a way that it doesn’t feel like one to help you get down to business faster via annotations. Internally, ColdBox always uses WireBox to do all that DI for your handlers, models, etc.
If you want to create a configuration file to declare your object dependencies etc, you can, that is your choice.