native DI DSL

Yes, in one of my managers (services) I am using this property…

This is where I had the most trouble…out of curiosity…what’s in the init function of your service?

<!----------------------------------- CONSTRUCTOR
--------------------------------------->

  <cffunction name="init" access="public" returntype="any"
output="false" hint="constructor">

    <!--- Any constructor code here --->

    <cfreturn this>
  </cffunction>

I was having the issues I was because I was trying to reference the object in a method called from my constructor, but that’s not what’s happening with you. I was able to recreate your error by removing the autowire interceptor from my config, and by removing the cfproperty tag from my object. If you can verify your interceptor is set up correctly, and that you have properly reinitialized the framework, I don’t know what else to check.

<!-- USE AUTOWIRING -->
<Interceptor class="coldbox.system.interceptors.autowire">
    <Property name='enableSetterInjection'>true</Property>
</Interceptor>

what does your interceptor config look like?

…but that’s no different than yours.

thanks man,

can you also send me you component headers?

what you have in both your models? <cfcomponent ... >

do you have autowire="true" in both?

Actually, I’m not using autowire in either one. I’m using autowire=“true” in my handlers. If I remove that attribute I get the same error you see, but the error occurs in my handler. Maybe Sana or Luis can speak to why you need the autowire attribute in your handler, but not in your model objects?

Here are the headers for my model objects anyway…

MoonDateManager (model alias)…

TimezoneManager…

Jonathan,

do you have cache="true" in your component headers? What do your
component headers look like?

thanks

MoonDateManager is transient, so I don’t cache it. TimezoneManager is a singleton, so I cache it and give it a timeout of 0…

MoonDateManager (model alias)…

TimezoneManager…

Hi guys,

Of course you can create inter-dependencies between model objects. Model objects are autowired by default, no need to set autowire=true in their cfcomponent declaration like you do in plugins, handlers and interceptors.

Now, Make sure you use the getModel() and populateModel() method, because that is the only way for the model integration to work. using cfproperty type model or mode:{name} is all you need. So I don’t know where are you missing this.

Other Data:
Do I need to define the autowire interceptor for model integration? No, this is done automatically by the bean factory plugin. Just for the records, the autowire interceptor basically calls the bean factory plugin for autowiring.

Do I need to define a IOCFramework or IOCDefinitionFile in my settings for model integration? No, this is only for using ColdSpring or Lightwire.

What you can do is turn debuggin on when calling getModel() so you can see the log file being populated with debug data to see how the dependencies are wired.
getModel(name=‘MyModel’,debugMode=true)

That should turn debuggin on for the autowire routines, this way you can see if the cfproperties are being read and how things are being injected.

Also,

This is the first round of the model integration features. I really hope that you guys can give me your input on what you like, don’t like, how it can be improved, verbosity, documentation, etc?

I think this could be a really nice way to introduce developers into dependency injection and help void the chasm between none and IoC.

luis

cool Luis!

thanks much for your input, I'll do my best to give you feedback on
model integration. I'm planning on strictly using native coldbox
dependency injection on the app Im currently writing.

thanks again! I'll be getting back to this code tomorrow. keep ya
updated!

happy holidays!

Thanks Luis!

It looks like I have finally convinced our lead that ColdBox is a great solution for what we do, and we will start implementation after the new year. We have been talking IoC implementation for a long time now. We’ve never made it out of the ‘talking about it’ stage, so I think our group is a perfect test case for introducing IoC with ColdBox. I’ll let you know how it goes.

Sal,
Are you using getModel() in your handler (or wherever it is you are invoking your model object)? Sounds like that is a key piece that hasn’t come up.

right.

no I have not implemented this code yet, but let me understand this
correctly...

I need to have the cfproperty and getModel() in my services... so for
example like this?

<!--- Dependencies --->
<cfproperty name="SomeService" type="model" scope="instance" />

then when I wanna to invoke a method within my SomeService...

<cfset users = instance.getModel("SomeService").getUsers() />

am I taking this wrong? kinda confused on the correlation between
cfproperty and injecting a model into my instance or whatever scope,
and using getModel()...?

Jonathan, are you using getModel() within your model dependencies?

plugins, and interceptors... I understand I use getModel() within my
handler to instantiate my service, but between services I shouldn't
need to use getModel() right?

the only difference I see between our code Jonathan, is that your
cache-ing your singelton object "TimeZoneManager"...

thanks in advance.

ok. strange.

everything works as advertised now. not sure what I did, besides
update to the latest release. 2.6.2 final from 2.6.2 RC...

thanks luis!