I spent quite a while late last night trying to get something to work that I was sure should have, but I did not succeed. I’m wondering if you all would mind taking a look and tell me if what I’m doing is possible and if it is, what I am doing wrong?
Think CB model integration…
I have a security handler that will use a userService model object to perform logging in and logging out. My userService object will need to be able to create instances of a user bean at different times. So, the plan is to inject the beanfactory and the datasource into my security handler via autowiring, and let the handler pass these two items to the userService via it’s constructor when the handler creates it via a private setter. My reason for wanting to do this: keep my model segregated from ColdBox as much as possible, but still take advantage of model integration.
SO, I enable the autowire interceptor. I add my userService and my userBean to my modelmappings.cfm . In my security handler, I enable autowiring, inject the datasource and the beanfactory, then leverage the onDIComplete method to then inject the userService manually via a private setter.
It all looks to me like it should work, but an error is thrown from the userService telling me that “DSN is required”; it is behaving as if userService is being instantiated without the required arguments being passed in, but, unless Coldbox is trying to instantiate my userService outside of my private setter, I cannot see why this would be true.
Any ideas? Anybody see anything wrong with the code below, or my approach to this? I am open to suggestions! I know that I can make it work if I allow my model objects to use autowiring, but my goal is to keep the model separate if at all possible.
Thanks in advance for your valuable input! And now, the relevant code:
THE COMPONENTS.... .....
And the userService…
<cfif qryLogin.recordcount eq 1>