ColdBox 3.6 - HTMLHelper via Interception Point

Hi folks,

This is sort of a continuation of a previous thread with Andy Scott. Andy so kindly put together this blog post demonstrating how to create custom HTML Helpers using Interception Points. - http://www.andyscott.id.au/blog/using-interceptors-in-coldbox-for-greater-scalabaility

So essentially I’m trying to use this technique to Add New Relic’s “Real User Monitoring” to all of my apps. See - https://newrelic.com/docs/java/real-user-monitoring-in-java

Here is a Gist I put together with my interceptor and plugin code: https://gist.github.com/nolandubeau/057b94e0df24231d0d8c

In my layout I have added the following before the HEAD tag closes - #cr.event(“custom_beforeHeadEnd”)#

The issue is that nothing seems to be happening. I have logging in place for the interception points and I have registered the interceptor in my Coldbox config - ,{class=“platform.common.interceptors.NewRelic”}, yet nothing is logged to logbox or rendered to the HTML.

Can anyone see what i’m doing wrong? Have I missed something?

Thanks.

Nolan

Hi Nolan,

You don’t say this, but is that custom interception point also registered?


//Interceptor Settings
interceptorSettings = {
	throwOnInvalidStates = false,
	customInterceptionPoints = "onLogin,onWikiTranslation,onAppClose"
};

I think I made the assumption that people might already know you have to do that.

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+: http://plus.google.com/113032480415921517411

Hi Andrew,

Yes it is. Sorry I should have mentioned that as well. I do know to declare them there :wink:

I checked again through all of the “steps” and can’t figure out why it’s not announcing correctly. Appreciate any insight.

Thanks.

Nolan

Can you try either a cfdump and abort in the plugin when the event is being called, so that it dumps something to the screen. Either that or logging will tell you for sure if the event is actually being fired.

I did not see the interceptor there, is there something in the interceptor that might be not right?

If the dump is not firing or being displayed, stopped by the abort, then we can determine that the plugin is not getting registered correctly for the renderer.

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+: http://plus.google.com/113032480415921517411

Hi Andrew,

For some reason the interceptor didn’t save. It’s updated now - https://gist.github.com/nolandubeau/057b94e0df24231d0d8c

I did a dump/abort in the plugin and I see this:
structDATA

struct [empty] |

  • |

STATEcustom_beforeHeadEnd

Thanks,

Nolan

Ok so that means it got registered all ok then.

Now the next question is that I am taking it, the logs you have in the interceptor are they actually appearing in the logs?

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+: http://plus.google.com/113032480415921517411

No, they are not showing in the logs. I do see the module exclusions being logged, which I’m not sure if I saw before (see below). I also have an abort in the interception point which is not firing. It’s as if announceInterception is being called but it’s not hitting the interception point.

Here is my coldbox interceptor config:

//Interceptor Settings

interceptorSettings =

{

throwOnInvalidStates = false,

customInterceptors = “custom_beforeHeadEnd,custom_beforeBodyEnd,onUserCreate,onContactCreate,onContactOptIn,onContactOptOut,onIncidentCreate,onForgotPassword,onDownload,onDemoRequest”

};

//Register interceptors as an array, we need order

interceptors =

[

//Deploy

{class=“platform.common.interceptors.Deploy”,properties={tagFile = ‘config/_deploy.tag’}}

,{class=“platform.common.interceptors.Constructor”}

//Autowire

,{class=“coldbox.system.interceptors.Autowire”,properties={entityInjection = true}}

//SES

,{class=“coldbox.system.interceptors.SES”,properties={configfile="/config/routes.cfm",loosematching=“false”}}

,{class=“platform.common.interceptors.NewRelic”}

,{class=“platform.common.interceptors.Dispatcher”}

];

Module: system excluded from loading.
3/12/13 11:00:38 PM Module: status excluded from loading.
3/12/13 11:00:38 PM Module: reports excluded from loading.
3/12/13 11:00:38 PM Module: realtime excluded from loading.

Well I can’t spot anything that might stick out. However the module, I assume this is a Module called realtime which seems like you have it set to exclude the loading somehow.

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+: http://plus.google.com/113032480415921517411

well, the new relic code is not running within a module. the one thing I excluded from your example is the module declaration in the afterPluginCreation() function

arguments.interceptData.oPlugin.cr = getMyPlugin(plugin=“NewRelic”);

In your example you have something like:

arguments.interceptData.oPlugin.cr = getMyPlugin(plugin=“NewRelic”, module=“myModule”);

I don’t think the module exclusion logging has anything to do with this. I may have not noticed that it was logging the exclusions before.

Thoughts? Luis, feel free to chime in here :wink: This is very puzzling.

Thanks.

Also, just to point out, this is not a ContentBox app. Just a regular ColdBox app.

Out of curiosity before I go looking further, what if you place the logging after the actual announce?

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+: http://plus.google.com/113032480415921517411

logging after the announcement works fine, but the logging in the interception point never fires. when I dump this in my layout it dumps as undefined

<cfdump var="#cr.event(“custom_beforeHeadEnd”)#">

If I dump out just cr I do get an object.

Thanks.

N

Hmm, maybe Luis might need to chip in here. This should work, the only difference that I am aware with interceptors is that ColdBox3.6 now runs these in threads.

Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+: http://plus.google.com/113032480415921517411

Hi guys,

Attached is a sample app. I set throwOnInvalidStates = true in my ColdBox config to see if an error was produced and there was:


Application Execution Exception
Error Type: InterceptorService.InvalidInterceptionState : [N/A]
Error Messages: The interception state sent in to process is not valid: custom_beforeHeadEnd
Valid states are [afterConfigurationLoad, afterAspectsLoad, preReinit, onException, onRequestCapture, onInvalidEvent, afterHandlerCreation, afterInstanceCreation, afterPluginCreation, applicationEnd, sessionStart, sessionEnd, preProcess, preEvent, postEvent, postProcess, preProxyResults, preLayout, preRender, postRender, preViewRender, postViewRender, preLayoutRender, postLayoutRender, preModuleLoad, postModuleLoad, preModuleUnload, postModuleUnload, beforeDebuggerPanel, afterDebuggerPanel, ORMPostNew, ORMPreLoad, ORMPostLoad, ORMPostDelete, ORMPreDelete, ORMPreUpdate, ORMPostUpdate, ORMPreInsert, ORMPostInsert, ORMPreSave, ORMPostSave, afterCacheElementInsert, afterCacheElementRemoved, afterCacheElementExpired, afterCacheElementUpdated, afterCacheClearAll, afterCacheRegistration, afterCacheRemoval, beforeCacheRemoval, beforeCacheReplacement, afterCacheFactoryConfiguration, beforeCacheFactoryShutdown, afterCacheFactoryShutdown, beforeCacheShutdown, afterCacheShutdown, afterInjectorConfiguration, beforeInstanceCreation, afterInstanceInitialized, beforeInstanceInspection, afterInstanceInspection, beforeInjectorShutdown, afterInjectorShutdown, beforeInstanceAutowire, afterInstanceAutowire]

So it looks like coldbox isn't liking my customInterception point.

Hopefully this sheds more light on the issue.

Thanks.

N

newrelic.zip (263 KB)

Hi guys,

Just checking to see if anyone has had a chance to look at this. Is it a bug?

Thanks.

Nolan

I just saw this Nolan,

Can you summarize it for me

signature0.jpg

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

Hi Luis,

The first item in the thread pretty much sums it up -

This is sort of a continuation of a previous thread with Andy Scott. Andy so kindly put together this blog post demonstrating how to create custom HTML Helpers using Interception Points. - http://www.andyscott.id.au/blog/using-interceptors-in-coldbox-for-greater-scalabaility

So essentially I’m trying to use this technique to Add New Relic’s “Real User Monitoring” to all of my apps. See - https://newrelic.com/docs/java/real-user-monitoring-in-java

Here is a Gist I put together with my interceptor and plugin code: https://gist.github.com/nolandubeau/057b94e0df24231d0d8c

In my layout I have added the following before the HEAD tag closes - #cr.event(“custom_beforeHeadEnd”)#

The issue is that nothing seems to be happening. I have logging in place for the interception points and I have registered the interceptor in my Coldbox config - ,{class=“platform.common.interceptors.NewRelic”}, yet nothing is logged to logbox or rendered to the HTML.

Basically the custom interception points are failing. You can see in the test app (NewRelic.zip) that ColdBox says the interceptor state is invalid.

Thanks.

signature0.jpg

So where are you registering the custom points?

signature0.jpg

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

signature0.jpg

In my coldbox config:

//Interceptor Settings

interceptorSettings =

{

throwOnInvalidStates = false,

customInterceptors = “custom_beforeHeadEnd,custom_beforeBodyEnd”

};

//Register interceptors as an array, we need order

interceptors =

[

//Deploy

{class=“platform.common.interceptors.Deploy”,properties={tagFile = ‘config/_deploy.tag’}}

,{class=“platform.common.interceptors.Constructor”}

//Autowire

,{class=“coldbox.system.interceptors.Autowire”,properties={entityInjection = true}}

//SES

,{class=“coldbox.system.interceptors.SES”,properties={configfile="/config/routes.cfm",loosematching=“false”}}

,{class=“platform.common.interceptors.NewRelic”}

];

signature0.jpg

signature0.jpg

It would help if you name it right :slight_smile:

//Interceptor Settings

interceptorSettings = {

throwOnInvalidStates = false,

customInterceptionPoints = “”

};

signature0.jpg

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

signature0.jpg

signature0.jpg