WireBox: Bind aspect to eager-inited objects

Hi,

I am trying to bind an apect to an object in wirebox, like this:

    mapAspect("sdkSessionInjector").to("aop.WebAPISessionInjector")
      .initArg(name="sessionStorageKey", value="SDKSession")
      .asSingleton();

    bindAspect(
      classes = match().instanceOf('model.service.SDKService'),
      methods =
match().annotatedWith('mobidm:required_arg','webAPISession'),
      aspects = "sdkSessionInjector"
    );

An example of an object to be wired like this is:

    map("entityService").to("model.service.SDKService")
      .initArg(name="entityType", value="model.bean.Entity")
      .initArg(name="queryBuilder", ref="queryBuilder")
      .initArg(name='serviceProvider', ref='serviceProvider')
      .asEagerInit()
      .asSingleton();

In my case, it seems that the entityService object does nog get wired
with the aspect. When I remove the .asEagerInit() call from the
entityService mapping, I see two properties appear when I dump the
object:
- $WBAOPTARGETS
- $WBAOPMIXED
and the aspect works as expected

When I re-add the asEagerInit() call, the two properties mentioned
above are not present when I dump the object, and the aspect appears
to be ignored.

Is there any way to bind AOP aspects to eager-inited objects, and if
yes, what am I doing wrong?

Best regards,
Martijn van der Woud

Ok, I think I might now why. Because of the chicken and the egg problem. The eager init’s are created, but the event manager in ColdBox might not be ready to serve events yet and the mixer is ignored. Where do you declare the AOP Mixer?

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

I beleive I have a fix for this. Can you try with our development branch.

That would be awesome Luis, I Will try today as soon as I get to the
office. Thanks for the quick response!

Hi Luis,

Your fix works for me. I tested against ColdBox-coldbox-
platform-3.5.0-15-gd9b331f (developement branch). Again, thank you for
your swift response!

Best regards,
Martijn van der Woud

Excellent Marijn, this bug has eluded me for almost a year and I can say that I was divinely shown the way to fix this! PG

Thanks!

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