[ColdBox 4.0] Cannot register my aspect

I’m trying to register this aspect:

`

/**

  • @classMatcher any
  • @methodMatcher annotatedWith:secure
    */
    component name=“securityAspect” {

property name=“coldbox” inject=“coldbox”;

function invokeMethod( invocation ) {

// Enforce our security check
if( !isUserLoggedIn() ) {

// Kick out people who aren’t logged in
coldbox.setNextEvent( ‘security.login’ );
}

return arguments.invocation.proceed();
}

}

`

In my moduleConfig I have this:

`

binder.mapAspect(aspect=“secure”).to("#moduleMapping#.aspects.securityAspect");

`

Then I try to add it to an handler:

`

function getSettings( event, rc, prc ) secure{

`

I’m expecting to be redirect, but handler seems to ignore the aspect and process the action.

Any thoughts?

Without digging too much int-- have you reinitted and what if you put a dump/abort in the aspect to see if it’s running? I bet there’s some logging you can enable as well for coldbox.system.aop.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

I have tried with autobinding true without success:

`

binder.mapAspect( aspect=“cacheIt”, autoBinding=true ).to( “#moduleMapping#.aspects.cacheIt” );

`

However adding the bindAspect it works:

`

binder.bindAspect(classes=binder.match().regex(“api.*”),
methods=binder.match().annotatedWith(“cacheIt”),
aspects=“cacheIt”);

`

So the question is: what is syntax for autobinding?

Have you compared it to the code in this Runnable?

http://code.runnable.com/UxAPnxLIPPQRijiK/wirebox-aop-for-security-for-coldbox-coldfusion-cfml-mvc-and-railo

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

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

The code I posted is the same, the only difference is that I map my aspect in moduleconfig and not in wirebox. I have the same annotation on my aspect, however autobinding does not seems to work…

Is the CFC you’re trying to bind to getting created prior to the aspect registration?

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,

I raised this issue back in the 3.0 days with Luis, I have no idea if this is a ColdFusion issue or a ColdBox issue as Luis made no more comments on it. But yeah, Annotations in components sometimes doesn’t work. In fact my experience has been 99% of the time it doesn’t work.

Sorry I should also add, with Comment Annotations and not normal component attributes.

Andrew I’ve tried also with component attributes and aspect is not binding.

I’m on latest commandbox on windows…