RE: [coldbox:9842] Re: Warning message using Wirebox standalone

Is there a particular reason to avoid the application scope? (I can think of a couple, but I just want to hear your response)

If you don’t want to reference the application scope directly, do you have an application facade object at least to talk to it?

You must have some mechanism for persisting objects or data in memory for the life of your application. Be it an in-memory cache, or some persistance service, it doesn’t really matter. Just create the WireBox injector once, persist it however you wish, and then just get that reference whenever you need to ask it for something. It is completely thread safe and can be used concurrently by as many threads as you need. I would say there’s little to no reason to go through the trouble of re-creating it every request.

Thanks!

~Brad

In regard the reference to the application scope - our website
actually has multiple applications (admin/webservice APIs etc.) and
I'd prefer not to have to maintain a reference to wirebox in all of
them.

But if a wirebox reference is taken from the application scope only in
a controller then I am happy enough to go with this if it has a
performance benefit.

However, when I created it in the app scope like so:

<cfset var wb =
createObject("wirebox.config.WireboxFactory").init().getInstance() />

<!--- Register it into the application scope --->
<cfset wb.scopeRegistration = {
  enabled = true,
  scope = "application",
  key = "wirebox"
} />

And then call it like so form a controller:

<cfset srv = APPLICATION.wirebox.getInstance("my.service") />

However in my CF debug it seems I still see the same debug even though
wirebox is persisted to my application scope - is there a way to ask
Wirebox to autowire *once* for an object but still get a new instance
of it each time I call getInstance()? I'm not sure if that makes
sense.

I thought about using cachebox:

<cfset
map("xpro.service").to("com.casino.xpro.XProService").inCacheBox(timeout=1,
provider="ehCache") />

But it didn't seem to make a difference.

Thanks in advance.