Luis Majano Forums Notification: Post to Accessing plugins from beans

Title: Accessing plugins from beans
Thread: Accessing plugins from beans
Forum: Need Help?
Conference: ColdBox
User: AndrewClarke

Hi. I'm new to ColdBox, and am doing my first project with ColdBox and
ColdSpring. So far so good, but I'm wondering how to acces plugins from within
a bean?

I've created a custom plugin called Messager.cfc, and I have a Person
bean. I'm trying to log some messages in my person.validate() method, err
function, but I guess I can't access the getPlugin() method directly from there.
I can do createObject("component", "plugins.messager") but that seems contrary
to the whole IOC ethos.

Actually it doesn't seem wise for me to have my beans
reliant on the ColdBox framework, period, by calling a plugin directly. Which
is why I suppose it doesn't work.

So what's the preferred method of doing
this? Should I inject a MessagerService into my Person bean and use that? But
then how do I get the Messager Plugin from the MessagerService? Just use
createObject()?

Thanks for any tips on the best practices here.

- Andrew.

http://www.luismajano.com/forums/index.cfm?event=ehMessages.dspMessages&threadid=936DB453-123F-6116-4278AAEDE505752E