coldfusion - How do I inject a Coldbox plugin into every handler? -
we have plugins used throughout coldbox application.
is there way globally inject these without having manually specify property each one?
i've looked through wirebox docs, can't see relevant. (entirely possible i'm overlooking something; it's long , dense page.)
it seem decorating frameworksupertype might way this, can't find mention of doing that.
i'll point out stack overflow requires logging in , typing subject :)
there several ways accomplish , way works.
the first call getplugin("myplugin") everywhere want use since getplugin() method available in every handler, view, , layout.
the second use mixin injection , place following @ top of every handler , access plugin variables scope: property name="myplugin" inject="coldbox:plugin:myplugin";
the third have handlers extend base handler joel suggested , place di property in base handler.
the fourth, mentioned, use aop aspect , bind init() method every cfc in handlers directory , set plugin variables scope "after" advice.
a fifth option, use interceptor listen afterhandlercreation announcement, , manually inject plugin ohandler object.
and sixth possibility use requeststarthandler or preprocess interception point , place reference plugin in private request collection (prc) available in views , layouts.
so lots of options, , isn't of them. personally, i'd use afterhandlercreation interceptor, should find 1 works best , run it!
Comments
Post a Comment