Can I add an Object to a bean provider manually?

51 views
Skip to first unread message

Asking Dumbquestions

unread,
Dec 13, 2012, 12:56:10 PM12/13/12
to swiz-fr...@googlegroups.com
Is there any way to map an object for injection not using a bean provider class? I have a command that instantiates and initializes an object and I want that object to be available by injection: this object needs some server data for initializing, and requires the loaderInfo object of the application. So, I don't have that server data when swiz initializes the bean providers, and there seems no way to have access to the loaderInfo in a bean provider anyway...

I know I could map the object, inject it into the command, then call some setters on it, but that seems lame: constructor params are my preference for initializing an object, either manually or by injection.

Any advice?
Thanks for your time!

Brian Kotek

unread,
Dec 13, 2012, 1:41:30 PM12/13/12
to swiz-fr...@googlegroups.com
You can add new Beans using the ADD_BEAN event: http://swizframework.jira.com/wiki/display/SWIZ/Bean+Life+Cycle+Management


--
You received this message because you are subscribed to the Google Groups "Swiz Framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swiz-framework/-/j7MfObeUu9oJ.
To post to this group, send email to swiz-fr...@googlegroups.com.
To unsubscribe from this group, send email to swiz-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swiz-framework?hl=en.

Asking Dumbquestions

unread,
Dec 13, 2012, 2:17:41 PM12/13/12
to swiz-fr...@googlegroups.com
Hmm, ok.  I wouldn't think to use an event for this process, it's not really event-driven per say. I'd much rather use an API on the injector directly, seeing as I'm in a configuration point in the application, where knowledge of the framework/injector is ok. Would be cool if there was an API for this instead of the use of an event, perhaps making the API available by an injection tag or something like that.

Anyway, thanks!

Brian Kotek

unread,
Dec 13, 2012, 2:42:01 PM12/13/12
to swiz-fr...@googlegroups.com
You're free to inject the BeanFactory and call whatever methods you need to on it to manually add a Bean as well.

To view this discussion on the web visit https://groups.google.com/d/msg/swiz-framework/-/5BA4eJFXapQJ.

Asking Dumbquestions

unread,
Dec 13, 2012, 2:49:44 PM12/13/12
to swiz-fr...@googlegroups.com
Oh, that's perfect, that's what I want, thanks!
Reply all
Reply to author
Forward
0 new messages