Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 1 | package org.apache.felix.dm.lambda.samples.hello; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | import java.util.Dictionary; |
| 5 | import java.util.Hashtable; |
| 6 | |
| 7 | import org.osgi.service.cm.Configuration; |
| 8 | import org.osgi.service.cm.ConfigurationAdmin; |
| 9 | |
| 10 | public class Configurator { |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame^] | 11 | ConfigurationAdmin m_cm; |
| 12 | final String m_pid; |
| 13 | |
| 14 | Configurator(String pid) { |
| 15 | m_pid = pid; |
| 16 | } |
Pierre De Rop | 643674c | 2016-02-01 10:05:32 +0000 | [diff] [blame] | 17 | |
| 18 | void bind(ConfigurationAdmin cm) { |
| 19 | m_cm = cm; |
| 20 | } |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 21 | |
| 22 | void start() throws IOException { |
| 23 | // Configure the ServiceConsumer component |
Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame^] | 24 | Configuration c = m_cm.getConfiguration(m_pid, null); |
Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 25 | Dictionary<String, Object> props = new Hashtable<>(); |
| 26 | props.put("foo", "bar"); |
| 27 | c.update(props); |
| 28 | } |
| 29 | } |