App interceptor locations

I'm working on my first interceptor, wondering if Ipaths'm missing
something obvious about where it goes and how to configure ColdBox to
see it.

There's an interceptors directory in the stock app. If I put my
interceptor in there, how to I configure that path in coldbox.xml? The
only way I could get it to work was to hard code the name of my app
onto the front of the interceptor path, like this:
   <Interceptor class="NameOfMyApp.interceptors.NameOfMyInterceptor">

I tried "interceptors.NameOfMyInterceptor" and "NameOfMyInterceptor"
by itself, no go.

It looks like the config path is used directly as a cfc instantiation
path. If it's really that simple, it make things less portable than if
there was a way to say, "in the interceptors directory for this app".
If the app moves to a different directory, or gets renamed, I'll need
to change that config.

Is there some convention or other magic move that accomplishes what
I'm after here?

Thanks,
Dave

Assuming your CF engine supports it, set a dynamic mapping for your app’s location like so in application.cfc:

<cfset this.mappings["/my_app_directory"] = getDirectoryFromPath(getCurrentTemplatePath())>

Then in your config, you’ll be able to do something like:

So if your app is ever moved, the dynamic mapping automatically changes and everything else works as it references “my_app_directory”

  • Gabriel

Thanks for the idea, may go that way.

But before I do, is it officially true that there's no ColdBox
syntax/alias/something to specify a named interceptor in the app's
interceptors directory? You have to provide a full cf-resolvable path?

Seems kind of odd that that'd be true, a missing convention I'd say.

Dave

If you are in the CFC approach you have the appMapping injected in the variables scope so you can say:

class="#appMapping#.interceptors.class.MyInterceptor"

If you are in the xml approach (why, why why!!) then you can use the ${} setting replacements

This is in the settings documentation by the way.

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

Thanks Louis, missed that. As usual, you've been there and done
something we can use (:-).

Still a little curious why nothing seems to honor the convention-based
interceptors directory directly, but it doesn't matter, I'm good.

Thanks again,
Dave