Problem with Interceptor and applicationStorage plugin

I have an interceptor in my modules that is loading and use the following DI.

property name=“applicationStorage” inject=‘coldbox:plugin:ApplicationStorage’;

If I change the application name or reboot the ColdFusion server, I have no problems with this line of code. However if I do a fwreinit on my application, the moment I try to use the applicationStorage I get an undefined variable. The interceptor that is being fired is the preProcess(), so I am a little confused as to why this is the case.

I am assuming that something is being bypassed here, that some things aren’t running in the order they should be running in.

Regards,

Andrew Scott

http://www.andyscott.id.au/

Sorry Andrew,

I cannot reproduce.

I created a new module, added an interceptor definition to my test interceptor that executes in preprocess and uses the injection you mentioned. ON preprocess I dump it and always get it correctly wired even when reiniting and with or without module auto reload.

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

Ok I think it might be because I don’t write the interceptor definitions, and I do it this way in my module onLoad().

var moduleRoot = expandPath(interceptorPath);

var files = DirectoryList(moduleRoot, false, “query”, “*.cfc”);

for(var count=1; count <= files.recordCount; count++) {

var interceptorName = listGetAt(files[‘name’][count], 1, ‘.’);

var interceptorClass = right(interceptorPath, len(interceptorPath)-1);

var interceptorClass = reReplace(interceptorClass & ‘/’ & interceptorName, ‘/’, ‘.’, ‘ALL’);

arrayAppend(instance.interceptors, interceptorName);

controller.getInterceptorService().registerInterceptor(interceptorClass=interceptorClass, interceptorName=interceptorName);

}

I then have an interceptor that has this, and this is setup with the above code.

property name=“applicationStorage” inject=‘coldbox:plugin:ApplicationStorage’;

property name=“logger” inject=‘logbox’;

public void function preProcess(event, interceptorData) {

applicationStorage.setVar(‘andyscotttest’, ‘something for everyone’);

log = logger.getLogger(this);

log.info(‘aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa’);

}

If I do a fwreinit on the application I find that I get an error on the applicationStorage.setVar() line above.

P.S. I find this way of just dropping an interceptor in much easier to maintain, than searching for config options or where it is etc. I am alos in the process of when loading this to do then load the metadata and see if the annotations are present. This would hopefully mimic manually creating it via the Config.cfc definition.

Especially when they aren’t complex and require no passed arguments on instantiation.

Regards,

Andrew Scott

http://www.andyscott.id.au/

Then you need to autowire them manually, as the module service does this for you automatically. You are taking responsibility here, so it would be up to you do autowire your interceptorts. Lok in the module service when activating.

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

That doesn’t make sense to me, the application works fine until you do a fwreinit.

Regards,

Andrew Scott

http://www.andyscott.id.au/

The other issue I see with this approach is that you can't control the order in which your interceptors are registered, which granted, doesn't matter most of the time, but might be a need at some point.

Curt