using injection in an init function

I’m trying to use the configBean which I injected into my component. I can’t seem to use it in an init function.

component
{
property name=“configBean” inject=“coldbox:ConfigBean”;

function init()
{

if (configBean.getConfigStruct().ENVIRONMENT eq ‘PRODUCTION’)
{
//do some stuff
}
else
{
}
}
}

Sorry hit send before finishing. Is there some reason why I can’t use the configBean in the init function but I can in other functions?
Thanks.

Yes, because the object has to be instantiated before injection can take place.

Thanks. Can anyone tell me the best way to set an application wide variable based on environment?

This is one way…

http://www.andyscott.id.au/2011/4/15/Setting-up-your-ColdBox-30-application-for-development-and-production

Then inject it as you where doing, just can’t use it in the init section.