Module loading config file at least 3 times.

I started working with creating a module today, and did a break point on the onLoad() method. I am under the impression that by the description this is called when it is fully loaded.

My question is would it be wrong of me to break point code in here, and find that this is actually being loaded 3 times?

Is there a reason for this? I wanted to add some stuff in here to save people from adding it to the main colbox.cfc config file, but I find that it is being added 3 times when I do this.

Regards,
Andrew Scott

Do you have module auto reload?
It is only called one when activated, you can see it on the ModulesService: line 252

it is called twice when starting up if reload is turned on.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Hmm, ok. But it still sounds wrong to me.

Try to follow it, I did on mine, the first hit sets of the first onload, but then the auto reload kicks in and reloads it again because this happens later in the lifecycle. This is for the FIRST hit only. Once that is done it reloads once per request if auto reloading is turned on.

If no autoreload is turned on, it fires only once. I cannot reproduce your 3 times.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Yeah makes sense, but I am wondering if I do the ModulesRoutes whether this will get added twice if I do it this way.

I can’t reproduce the 3 times either, but I have to ask this.

If the module is loaded on the first hit, why is it reloaded sometime later in the code? That really makes no sense to me, and to be honest I have noticed this same behaviour with events as well.

My logic would be when the page is hit, do we need to reload? No, then continue if we do then reload the module. Not load it then reload it sometime later.

It kind of defeats the purpose, because it is being reloaded on first hit anyway yes?

Andrew,

The way I had always understood the autoreload settings is that they are for development purposes only. Luis, please correct me if I’m wrong… but since I might make a change to my code after first hit /reload… when autoreload=true, subsequent requests should in fact reload things again. This is what I would want and expect in order for the framework to grab my recent changes inbetween first request and next request.

If autoreload=false, as it should be in production, then I really don’t see what the problem is, and you shouldn’t have any issues with what your trying to do on the module routes.

Also, are you using HandlersIndexAutoReload=true when you see this behavior on events?

Regards,
Adam

Adam,

My point is simple, if the onLoad fired once then it is loaded. In the same request it is being fired again (due to the flag in config settings), which is saying it actually isn’t loaded. So at what point is it loaded the first call to onLoad or the second call to onLoad in the same request?

Regards

Andrew Scott

These are development settings guys, the first hit to the app is a strange case as development flags still fire, subsequent requests just do reloading as the flags denote. Don’t get hang up on them. However, if they still fire twice without them, then there is a problem.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

But doesn’t make the flag obsolete, if it is already being loaded every request anyway?

Sorry Andrew, maybe its too early here and I am still glowing from the Argentina win, but I don’t understand?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Well you are saying that the module is loaded on every request, if it is the first request then further in the code it checks to see if the autoreload is true and reloads it again.

So my question is if it is already loaded once, it makes the autoload flag obsolete.

I cannot do that because the flag calls the reloadAll() which forces reloading of all modules again. This is necessary because I might have new things that I want reloaded. I cannot say, reload only if not loaded because it should force reload everything.

Also, how can I tell if this is the first request or not?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com