Where can I find a list of all my event handlers?

6 views
Skip to first unread message

Joel Tobey

unread,
Jan 10, 2012, 12:52:19 AM1/10/12
to model...@googlegroups.com
I'm doing some fancy SES URL magic and I'm trying to determine what event name I want to use. It's fun because '/foo' is a different event than '/foo/bar'. (Where one might think the later is still the '/foo' event with the variable 'bar')

My first thought to do this is to run some logic against the full list of event handler names, but I'm having trouble finding where to do that. The _mg.hasEventHandler() method seems to be the one, but it only checks for loaded event handler objects. Since MG lazy inits, not all of the event handlers load during the init.

Can someone help me with accessing the list of event handlers from my XML file? Or if you have another solution to what I'm trying to do?

Thanks!

Dan Wilson

unread,
Jan 10, 2012, 8:31:26 AM1/10/12
to model...@googlegroups.com
The XMLModuleLoader.cfc is probably where you want to look.

If you want a list of event handlers, you can look at the method, listEventHandlers. This is designed to deal only with a single XML config, but you can simply expand the logic to read in all of your files and list them. 

The method, hasEventHandlerDefinition, will look through all of the MG config files and try to find instances of a specific event name. You may be able to copy this logic to print out all of the Event Handler names.

This CFC is not available in the public Model Glue namespace. You can get access to the loaded XML files though by injecting the bean modelglue.ModelGlue into your own CFC and calling: getModuleLoaderArray().


DW



--
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog
 
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en



--
Plutarch - "The mind is not a vessel to be filled but a fire to be kindled."

Ezra Parker

unread,
Jan 10, 2012, 11:00:52 PM1/10/12
to model...@googlegroups.com
As Dan indicated, there are ways to get at the entire set of event
handlers, but this isn't exposed directly. Do you actually need a
list/array of all the event names, or would checking to see if a
particular event name exists be sufficient?

If the latter is the case, then the hasEventHandler() method *should*
work, as it turns around and calls hasEventHandlerDefinition() on the
module loader array, and therefore it shouldn't matter whether the
event handler in question has been loaded yet.

--
Ezra Parker

Joel Tobey

unread,
Jan 11, 2012, 11:18:18 AM1/11/12
to model-glue
Ah, I think I figured it out. I was trying to do this logic in my
SesUrlManager and that seems to be too early in the life cycle. When I
was in a Controller, the hasEventHandler() method works as expected.
For my situation, I believe the best way to go is to hit the same
"event" for all requests, do my event resolving logic in the
Controller and then execute the "real" event.

Thanks for your help and input.

On Jan 10, 9:00 pm, Ezra Parker <e...@cfgrok.com> wrote:
> As Dan indicated, there are ways to get at the entire set of event
> handlers, but this isn't exposed directly. Do you actually need a
> list/array of all the event names, or would checking to see if a
> particular event name exists be sufficient?
>
> If the latter is the case, then the hasEventHandler() method *should*
> work, as it turns around and calls hasEventHandlerDefinition() on the
> module loader array, and therefore it shouldn't matter whether the
> event handler in question has been loaded yet.
>
> --
> Ezra Parker
>
>
>
> On Tue, Jan 10, 2012 at 5:31 AM, Dan Wilson <sipac...@gmail.com> wrote:
> > The XMLModuleLoader.cfc is probably where you want to look.
>
> > If you want a list of event handlers, you can look at the
> > method, listEventHandlers. This is designed to deal only with a single XML
> > config, but you can simply expand the logic to read in all of your files and
> > list them.
>
> > The method, hasEventHandlerDefinition, will look through all of the MG
> > config files and try to find instances of a specific event name. You may be
> > able to copy this logic to print out all of the Event Handler names.
>
> > This CFC is not available in the public Model Glue namespace. You can get
> > access to the loaded XML files though by injecting the bean
> > modelglue.ModelGlue into your own CFC and calling: getModuleLoaderArray().
>
> > DW
>

Chris Blackwell

unread,
Jan 11, 2012, 12:57:23 PM1/11/12
to model...@googlegroups.com

Joel,

It should be possible to do what you want by inserting your own phase into the request lifecycle. I do this in my apps to provide url routing.

eg. /user/{username}

The code is on github - https://github.com/d1rtym0nk3y/ModelGlue-Url-Router

The trick is to override url.event before the MG gets to the invocation phase, so you can do this during population.

I'm on my mobile atm and there no docs apart from the example but if you have any questions I'll take a look when I'm back in the office and try to help

Chris

Reply all
Reply to author
Forward
0 new messages