Wirebox standalone installation

103 views
Skip to first unread message

murphyhg

unread,
Dec 20, 2011, 7:33:27 PM12/20/11
to ColdBox Platform
Hi Guys, can someone please explain how to setup wirebox in a
standalone situation with just application.cfc?
For example, when I create wirebox in the application.cfc does it
inject itself into the application scope? Does the binder.cfc get
called? If so where and how? I want to use mapDirectory. I assume I do
that in the binder.cfc.
Thanks for your help.

Luis Majano

unread,
Dec 20, 2011, 10:17:17 PM12/20/11
to col...@googlegroups.com
Yes George, when you create the injector it automatically sets itself up into application scope for you, you control this via the binder.

injector = createObject("component","wirebox.system.ioc.Injector").init();
If you want a binder then:

injector = createObject("component","wirebox.system.ioc.Injector").init(binder="path.to.binder");
That's it, then you will find the injector automatically in application scope as application.wirebox.  Then you can just use getInstance() from it  Yes, mapDirectory() is all in the binder.


--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

Brad Wood

unread,
Dec 20, 2011, 4:22:47 PM12/20/11
to col...@googlegroups.com
> Hi Guys, can someone please explain how to setup wirebox in a standalone > situation with just application.cfc?

onApplicationStart(), create WireBox with createObject().

> For example, when I create wirebox in the application.cfc does it inject itself into the application scope?

If you set set scope registration in the config, yes it will persist itself in whatever scope using whatever key you specify.

wirebox.scopeRegistration = {
enabled = true,
scope = "application", // server, cluster, session, application
key = "wireBox"
};

You can also manually set it into a scope if you wish.

> Does the binder.cfc get called? If so where and how?

You can create the binder.cfc and pass it in on the init of WireBox or you can tell WireBox where the config is located with an instantiation path and it will create it for you.

> I want to use mapDirectory. I assume I do that in the binder.cfc.

Yep. You can pretty much do the same stuff in a stand-alone WireBox install that you can do within ColdBox. A couple differences are that your ColdBox settings won't be passed in as properties (though you're free to pass in another struct of properties) and any ColdBox DSL obviously can't be built without an attached ColdBox instance.

Check out the docs for some examples of creating WireBox outside of ColdBox:

http://wiki.coldbox.org/wiki/WireBox.cfm

Thanks!

~Brad

Sent from my ASUS Eee Pad

George Murphy

unread,
Dec 21, 2011, 9:06:50 AM12/21/11
to ColdBox Platform
Hi Guys,

Thanks for getting back with me. What would the call be to determine
what wirebox has mapped? Also, when I tried created aliases using the
map function inside the binder that did not seem to work. The only way
I got that to work was to add annotations directly to the components.

Also, I tried injecting some other objects into others. They looked
something like this.

<cfproperty name="ART" inject="model:ART" scope="instance" />

I tried it like this as well and I got the same error.

<cfproperty name="ART" inject="ID:ART" scope="instance" />

Do I have to do something in the binder to use the instance scope?

Thanks,

George Murphy

Curt Gratz

unread,
Dec 21, 2011, 5:18:17 PM12/21/11
to col...@googlegroups.com
How are you calling the object you are looking to wire? You will have to use wirebox to retrieve the object and not createObject or new for it to be wired up for you.

injector = createObject("component","wirebox.system.ioc.Injector").init();

espresso = injector.getInstance("model.CoffeeShop");

Check out these to videos I made a while ago. They are both short and should help you get started.

http://vimeo.com/20937470
http://vimeo.com/20938425

Hope that helps.

Curt Gratz
Computer Know How

Hi Guys,

Thanks,

George Murphy

--

Reply all
Reply to author
Forward
0 new messages