tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/38-can-i-inject-settings-at-runtimeRobotlegs: Discussion 2018-10-18T16:35:07Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/8672382010-01-17T17:03:57Z2010-01-17T17:03:57ZCan I inject settings at runtime?<div><p>Hi Ruprict,</p>
<p>there's not really any specific place to put such configuration
in<br>
Robotlegs. I think people deal with this quite differently, so
I'll<br>
just state what I normally do:</p>
<p>The short version is: "in the application's override of<br>
Context#startup" - the slightly longer version follows:</p>
<p>For small projects, I do all injector mappings directly in
the<br>
projects' override of Context#startup as can be seen in Joel's<br>
FlickrImageGallery example[1] and simply do the configuration
mappings<br>
before all other mappings so as to verify availability of the<br>
configuration parameters to all services.</p>
<p>For bigger projects, I bind several specialized startup commands
to<br>
the ContextEvent.STARTUP event and make the first one a<br>
ConfigurationCommand that creates all the injection mappings
dealing<br>
with application configuration.</p>
<p>Depending on what kind of configuration settings you have to
apply,<br>
you might either use if/ else clauses (e.g. to map the live or
the<br>
testing version of a service) or simply assign a value contained in
a<br>
variable to a mapping (e.g. to map a URL or an API key).</p>
<p>In most cases, you'll want to have access to the SWF's
LoaderInfo or<br>
at least to the ApplicationParameters to be able to even find
out<br>
which configuration to apply, so your startup method might look<br>
something like:</p>
<p>protected override function startup() : void<br>
{</p>
<pre>
<code>injector.mapValue(LoaderInfo, contextView.stage.loaderInfo);
commandMap.mapCommand(ContextEvent.STARTUP, ConfigCommand,</code>
</pre>
<p>ContextEvent, true);<br>
// further startup command mappings here ... }</p>
<p>That's what I'm using, at least - others might have different/
better recipes.</p>
<p>cheers,<br>
till</p>
<p>[1] <a href=
"http://github.com/robotlegs/robotlegs-demos-Bundle/blob/master/FlickrImageGallery/src/org/robotlegs/demos/imagegallery/ImageGalleryContext.as#L31">
http://github.com/robotlegs/robotlegs-demos-Bundle/blob/master/Flic...</a></p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/8672382010-07-15T14:01:35Z2010-07-16T09:27:28ZCan I inject settings at runtime?<div><p>Hi Till, I have the same question as the original poster and am
not sure if your answer addresses it. So let me ask differently;
for instance, Parsley has <a href=
"http://www.spicefactory.org/parsley/docs/2.1/manual/config.php">these
ActionScript, MXML and XML configuration options</a> where the
first 2 are used at compile time and the last one for runtime
configuration.</p>
<p>Is there a similar option (some kind of textual config that can
be loaded at runtime) available in Robotlegs?</p></div>borekbtag:robotlegs.tenderapp.com,2009-10-18:Comment/8672382010-08-09T07:46:35Z2010-08-09T07:46:35ZCan I inject settings at runtime?<div><p>Still no answer here - does Robotlegs support runtime configuration? If not directly, what would be the best way to implement it?</p></div>borekbtag:robotlegs.tenderapp.com,2009-10-18:Comment/8672382010-08-09T12:47:36Z2010-08-09T12:47:36ZCan I inject settings at runtime?<div><p>Hey borekb,</p>
<p>If you look at the comments at the end of this post (<a href="http://ruprict.net/2010/04/01/robotlegs-and-cairngorm-3-initial-impressions/">http://ruprict.net/2010/04/01/robotlegs-and-cairngorm-3-initial-imp...</a>) odoenet adds a couple of links to how he does it.</p>
<p>Hope this is useful,<br />
Ruprict</p></div>Rupricttag:robotlegs.tenderapp.com,2009-10-18:Comment/8672382010-08-13T16:13:04Z2010-08-13T16:13:04ZCan I inject settings at runtime?<div><p>FMOI why are you moving from spring to RL</p></div>Nikos