RE: [coldbox:18309] [coldbox-3.6.0] AOP aspect and custom messagebox plugin

So does that mean it’s working?

I tried to set up a test locally. I registered the aspect and when I injected the messageBox plugin directly it would error when I tried to use it, but when I injected it via a provider it worked without issue.

If you look in the base plugin class, you’ll see this in the init:

variables.flash = arguments.controller.getRequestService().getFlashScope();

If that code is run too soon when the framework is booting up, the request service won’t have actually created the flash and it will set variables.flash equal to a zero “0”. (Not sure why it doesn’t just error or something) This is the order it happens in:

  • Framework starts booting up
  • request service is created with a “0” placeholder value for the flash scope
  • ColdBox configuration is loaded
  • Aspects are created
  • messageBox dependency is created for your aspect which prematurely gets the flash scope from the request service before it’s been properly set- onConfigurationLoad is fired which triggers request service to actually create flash scope. This can’t happen until config is loaded since your config controls how the flash scope is stored
  • You try to use your message box plugin, but it has a corrupted value for its flash scope and therefore errors.

Using a provider pushes the creation of the message box plugin back until after configuration has been loaded and the request service has properly had a chance to initialize the flash scope.

If you’re receiving the error still and you’re “providing” the message box plugin, something must be firing the aspect before the request service is finished initializing the flash scope.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

Something is wrong with how my plugin extending Messagebox is working (or not working). I know the plugin has worked in the past but the conditions under which I have been testing it changed when I introduced it into the aspect. I swapped out my plugin and switched back to the packaged messagebox and everything works exactly how you have outlined.

So, for now, I am going to just abandon the custom plugin and make that a challenge for another day.

Thank you so much for sticking with this…while it ultimately did not solve my problem, it taught me a great deal in what to look for when something is not quite working the way I expect.

Mike