[Coldbox 3.8] Execution order of Config/Wirebox/Modules/Interceptors

In short, I have a similar need to what Andrew Scott asks for here:
https://groups.google.com/forum/#!msg/coldbox/PTpwoGZzJzg/dyUSyTaTIocJ

I have an application which isn’t behaving, and it appears to be related to certain code being run before Wirebox is ready, and thus being unable to find dependencies.

Initially I thought the issue was with interceptors, and I’ve tried resolving it by moving from structs in configure() to manual registerInterceptor calls in afterConfigurationLoad (both in core application and in various modules), which appeared to work, except I then have issues with modules (in particular a customised version of ContentBox).

If I change the afterConfigurationLoad to preModuleLoad (after seeing Brad’s list - I would never have guessed that came first from the http://wiki.coldbox.org/wiki/Interceptors.cfm docs), I then get dependency errors again.

So yeah, what I really need is a precise diagram/explanation of the lifecycle. The one Curt linked to (http://wiki.coldbox.org/wiki/RequestLifecycles.cfm) would be fine, except it misses too much information: it doesn’t include preModuleLoad; I don’t understand why Configuration File Loaded is separated from afterConfigurationLoad by two steps; is “Modules Activated” the same as Modules being Loaded; at what point does Wirebox get involved - it is only mentioned in the non-fwreinit path; etc…

That was the exact reason I did ask, but I gave up asking again.

Just out of curiosity, what is the error? And have you tried moving what you need over to postModuleLoad instead, do you get the same errors from doing that?

With my afterConfigurationLoad changes, the app starts successfully, but on of the cms-related pages I get:

Element CBSETTINGS.CB_DASHBOARD_DEFAULT_WIDGETS is undefined in PRC

Which is occuring inside contentbox-admin/interceptors/CBRequest.cfc - the value of that variable is set in a function in another module which is obviously not being called in time.

Hmmm, I’ve just realised I don’t actually know if that code was working before - possibly it is due to bad data or something on my machine (another developer who is off today has done the ContentBox stuff), so it may or not be a separate issue. Will check that in a second.

Anyhow, changing to postModuleLoad didn’t appear to make a difference - same behaviour as preModuleLoad, and similar to other things I had being trying, with error messages of the form:

The DSL Definition {JAVACAST={null},NAME={XXX},ARGNAME={},DSL={model},VALUE={null},REQUIRED={true},SCOPE={variables},REF={null}} did not produce any resulting dependency

With detail:

The target requesting the dependency is: ‘common.modules.YYY.model.ZZZ’

I forgot to mention that an initial attempted solution was to put mapDirectory calls inside Wirebox.cfc configure - one for each item in scanLocations array.

This appeared to resolve the startup dependency issues at first, but was discovered to cause this error:

Error Type: Builder.BuildCFCDependencyException : [N/A]
Error Messages: Error building: X -> The CONTROLLER parameter to the init function is required but was not passed in. with constructor arguments: {}

That one comes from a Wirebox.getInstance call inside a handler, (which needs to get CFC metadata and only has the entity name).

Removing the mapDirectory calls (and the code that depends on them) makes that issue go away, but obviously I need to make all the code work together.

I realise what I’m writing might not be coherent to others… that’s why I want to understand the lifecycle, so I can figure out where the actual problem is instead of just poking things and seeing what happens. :confused:

Have you seen this:http://wiki.coldbox.org/wiki/Modules.cfm#Module_Lifecycle

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

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

Social: twitter.com/lmajano facebook.com/lmajano

Those error messages appear when ContentBox has not been updated correctly.

http://www.andyscott.id.au/blog/upgrading-contentbox-things-you-should-know

Also there is a ContentBox group so you may wish to post over there for anything ContentBox.

Problem with that Luis, is as I asked there is not one place that shows the entire life cycle of everything. When interceptors get fired in relation to other aspects of the life cycle, when modules are loaded into the life cycle etc.

signature0.jpg

Have you seen this:http://wiki.coldbox.org/wiki/Modules.cfm#Module_Lifecycle

Not yet… but it looks useful, so I’ll check it out. (Can that get added as a if that was linked to from the Request Lifecycles page?)

In the meantime, I’ve just checked and the cms-related error was happening with an older version of the code, so moving stuff to afterConfigurationLoad might have worked… still need to check a few more things to be sure.

Andrew wrote:

Those error messages appear when ContentBox has not been updated correctly.

http://www.andyscott.id.au/blog/upgrading-contentbox-things-you-should-know

Also there is a ContentBox group so you may wish to post over there for anything ContentBox.

Thanks for info… the version we’ve got has been customised to integrate it with the rest of the application, but I’m not sure to what extent, so I guess it could be an incorrect update and/or due to the changes made.

Will need to wait and check details with the developer who did that when they’re back in.

Can you explain what you mean it has been customized to integrate?

I can show you ways that make it so that you DO NOT have to customize ContentBox, in fact there are two blogs on this on my site as well. You can contact me privately if you like, curious what other situations I may not have thought about where you need to customize ContentBox.

The last time I needed help figuring out interceptor orders, I did this: Register an interceptor with a method for every possible interception point that just has a CFLog inside of it. Then hit your app and see what order stuff is happening in.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Brad,

If you guys aren’t wanting to put something like this as a 1 sheet cheat sheet sort off, then thats fine, but I think it will be very helpful on a lot of levels if there was one.

Yes I ended up doing that, by the time you go through all the docs looking for all the configuration loads and what interceptors there are, it would have been quicker to look at an graphic that shows this.

I think one diagram would be a good idea, but I have zero graphic skills. Perhaps someone would like to volunteer to help :slight_smile:

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Yeah, I can’t speak for anyone just learning ColdBox, but I think it will help tremendously and like you I have zero graphics skill.