question regarding the new Coldbox 2.6.2 model integration. if I want
an instance of a model service in my handler would I just give a type
model in my cfproperty attribute, and everything works out?
If you don’t create a mapping, then the name will be matched to whatever exists in the model directory. Example:
/model
Book.cfc
/security
SecurityService.cfc
If I want book: getModel(‘Book’)
If I want the security service: getModel(‘security.SecurityService’)
Now, the best practice is to create mappings for model objects that do not exist in the root. So if you want to refactor them or change their names or whatever, you basically just change the mappings file and not the actual code that uses it. So overall, I would suggest you use model mappings for objects in directories inside the model folder.
sounds good. thats what I thought (or at least hoped).
But one more newb question. Why do I see you creating the instance
scope structure in some CFCs and not others...? Is there places
(models, handlers, plugins) I need to do this and not others?
<cfset var user = instance.SomeService.getUser(arguments) />
any thoughts here, I know this leads back to my original question on
this thread, but I hadn't tested the service yet. Not sure what the
issue is here... It seems as though Im not properly getting and
"instance" of my service (someService)
I was getting that too, so I added the autowire attribute to my handler and re-init’ed the framework. This seemed to fix it. Why it fixed it, I’m not totally sure, but it fixed it.
however this didn't solve my problem, I'm trying to autowire a model
service into another model service. I don't think the handler has
anything to do with it besides instantiating the call via getModel().
I'm trying to test a method within one of my services that is
dependent on another service.
in the case of the simple example given on that page. I'm doing
exactly what the UserService is! In addition, is the example
leveraging coldspring or any other DI for the UserGateway object? In
the UserService all that is declared is the cfproperty, as in my case.
The example "places" the UserGateway into the "instance" scope of the
UserService cfc and away it goes.. I have that same exact setup!
What leads me to the question of other DI frameworks acting upon those
objects is this statement:
"Below you will learn how to wire up dependencies AFTER the object
get's created ". I believe coldspring will "create" then inject into
your dependencies...? Is this not the case for the "built in DI DSL"
of coldbox?
Oh yeah…correct me if I’m wrong…but what the example doesn’t say is that you need to set up your autowire interceptor in the ColdBox config for that example to work.
I can autowire handlers and plugins just fine. it's injecting
instances of models to models is where I keep getting object not found
issues... I'm not to clear on how integrated coldbox DI DSL is with
coldspring or lightwire... I'm trying to get away from a coldspring
bean definition file, and strictly use coldbox native tools...
I haven’t played very much with the DI DSL yet, but I’m pretty sure that you must have either ‘lightwire’ or ‘coldspring’ setup as your IOCFramework (setting in coldbox.xml).
I wish I could be more help. For what it’s worth though, last weekend I went through my site and completely replaced ColdSpring with the new model stuff and deleted my ColdSpring folder, my ColdSpring config file, and removed my IOC settings when I was finished.
I saw the error you are seeing several times during that process, but changed so many things I don’t know exactly why the object in question wasn’t being injected and what changes I made fixed it. Stay the course!
Assuming the answer to that is ‘yes’, I’m betting that it also means that you do not have any properties set as type=“ioc” or type=“ioc:bean”.
sal, if you’re using anything with type=“ioc” or type=“ioc:bean”, then you’d need either ‘coldspring’ or ‘lightwire’ setup as the IOCFramework. Otherwise, from what Jonathan is saying, it appears that you do not need it.
I’m not using IOC (unless you recognize ColdBox as my IOC Framework). Now, in my code i’ve started using cfproperty with the following types: ocm (the new TransferLoader blows my socks off), model, coldbox:plugin:{…}, coldbox:setting:{…}, coldbox:datasource:{…}
I can autowire native plugins into my model, objects from cache, I
just cannot autowire a plain jane component model...
@ Jonathan, since you removed your IoC layer, do you have any model to
model dependencies, or service to service dependencies? if so how are
you handling instantiation or injection?