Many thanks for your answer, appreciated. 

Although i might have forgot to mention that i'm new to guice and what you 
wrote does not make much sense in my body of knowledge. 

I personally come up with a solution in the mean time that i do not like so 
much but still work. I use the assisted inject framework. 

I saw that this is what is recommended because with provider you can only 
set information that you know in advance, not things that you get at 
runtime. In the faq of google guice they seem to recommand the use of 
assisted inject as well. But i find it so cumbersome. The only advantage is 
that the factory is generated for you. It feels like an over kills

With respect to your exemple, please do you mind assisting me a bit further 
by connecting the dots please: I don't see any provider created, the 
corresponding module that will contain it, how you will initialize the 
module and call for your instance and etc.... 





On Saturday, November 16, 2013 4:43:06 AM UTC+1, Cédric Beust ♔ wrote:
>
> I suggest using a provider and the awesome (obviously) JCommander 
> library<http://jcommander.org>
> .
>
>   class Main {
>     private Arg arg = new Arg();
>
>    public static void main(String[] args) throws Exception {
>     class Arg {
>       @Parameter(names = "-long")
>       public long l;
>     }
>
>     new JCommander(arg).parse("-lon", "32");
>
>   }
>
>    @Provider
>     public Arg getArg() {
>       return arg;
>     }
> }
>
> then simply
>
> @Injectprivate Arg arg;
>
> -- 
> Cédric
>
>
>
> -- 
> Cédric
>
>
>
> On Fri, Nov 15, 2013 at 6:21 PM, Maatary Okouya 
> <[email protected]<javascript:>
> > wrote:
>
>> I have an object in my application that need to be created with parameter 
>> from the command line. 
>>
>> E.g. I have the object Infrastructure service which is a singleton 
>> object. When i need to create it, i have to supply it with a concurrent 
>> hashmap and paramters either coming from the the command line or the GUI. 
>> The hasmap is provided by the Gui, it shares it with the infrastructure. 
>>
>>
>> I was wondering what would be the best approach for such case. The 
>> immediate approach i have in mind, is a factory to which those parameter 
>> are passed, and will be used to create the infrastructure let say from the 
>> Gui. 
>>
>>
>> Any suggestion, am i seeing the problem the wrong way ? Is guice useful 
>> in that case, if yes how. 
>>
>>
>> Many thanks, 
>>
>> Maatary
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "google-guice" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/google-guice.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to