Hello, I managed to access the map. It seems I either misunderstood a documentation or something else happened because I thought I had to inject MappedConfiguration into my constructor.
But instead I have to inject Map which is of course accessible using the usual methods. Regards, Daniel P. -----Ursprüngliche Nachricht----- Von: Nathan Quirynen [mailto:[email protected]] Gesendet: Freitag, 4. September 2015 11:25 An: [email protected] Betreff: Re: MappedConfiguration for my service - how to access the map Hey, I'm not sure what you mean. As you say it is injected into your service constructor, so you already have access to it no? You can inject your service wherever you want (pages, components, other services, ...) which holds the configuration you contributed in your module class. A simple example: |public| |class| |MyAppModule { | |public| |static| |void| |contributeMyService(|||MappedConfiguration<String, String> configuration|) {| |||configuration.add(||"first"||, "contribution"); |||| configuration.add(||"second"||, "contribution");| ||| } } | |public class| |MyService { private Map<String, String> config; ||| |public| |MyService||(Map<String, String> configuration) {| |||config = configuration;|| | |} public String getConfigValue(String key) { return config.get(key); } } | |public class| |MyPage||{ @Inject private MyService myService; public getFirstConfigValue() { return myService.getConfigValue("first"); } } | Nathan On 03/09/15 19:44, Poggenpohl, Daniel wrote: > Hi everyone, > > I'm trying to add some configuration to my self-implemented service. How do I > access the configuration properties? I can add to the configuration, override > it, and inject it per IOC into the constructor of the service. > > But how do I access the configuration? > > Regards, > Daniel P. > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
