Why not simply inject the properties directly? Using an annotation and a
Map<String, String>
Dhanji.

2009/9/19 Olivier Grégoire <[email protected]>

>
> Dears,
>
>
> I'm developing a small Swing application that needs at some points
> JMenuBars. A sample describes more than words:
>
> public class MyWindow extends JFrame {
>  public MyWindow (@Menu("myBar") JMenuBar myBar, @Menu("secondBar")
> JMenuBar secondBar) { ... }
> }
>
> class MenuBarFactory {
>  public JMenuBar createMenuBar(Class<?> forType, String menuName) {
>    // Fetch resources from properties file linked to forType
>    //   in this case MyWindow.class
>    // build menuBar for the menuName
>    // return menuBar
>  }
> }
>
>
> My problem is that I would like to pass automatically two parameters to
> the factory: the forType and the menuName.
>
> I've well thought about injecting the factory, but I'm not very
> convinced because "myBar" and "secondBar" are configuration strings and
> should rather be present in the annotation (instead of in the code), and
> also because the forType will always be the class of the injectee which
> is something already known from Guice.
>
> Is there a way to do this using the SPI, for instance?
>
>
> Regards,
>
> Olivier
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to