org.osgi.service.cm.ConfigurationAdmin Java Examples

The following examples show how to use org.osgi.service.cm.ConfigurationAdmin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InterpretCommandTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException, InterruptedException {
    ttsService = new TTSServiceStub();
    hliStub = new HumanLanguageInterpreterStub();
    voice = new VoiceStub();

    registerService(voice);
    registerService(hliStub);
    registerService(ttsService);

    Dictionary<String, Object> config = new Hashtable<String, Object>();
    config.put(CONFIG_DEFAULT_TTS, ttsService.getId());
    config.put(CONFIG_DEFAULT_HLI, hliStub.getId());
    config.put(CONFIG_DEFAULT_VOICE, voice.getUID());
    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    String pid = "org.eclipse.smarthome.voice";
    Configuration configuration = configAdmin.getConfiguration(pid);
    configuration.update(config);
}
 
Example #2
Source File: DirDeployerImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public DirDeployerImpl()
  {
//    logTracker =
//      new ServiceTracker<LogService, LogService>(Activator.bc,
//                                                 LogService.class, null);
//    logTracker.open();

    caTracker =
      new ServiceTracker<ConfigurationAdmin, ConfigurationAdmin>(
                                                                 Activator.bc,
                                                                 ConfigurationAdmin.class,
                                                                 null);
    caTracker.open();

    // create and register the configuration class
    config = new Config();
  }
 
Example #3
Source File: CMCommands.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void serviceChanged(ServiceEvent event)
{
  switch (event.getType()) {
  case ServiceEvent.REGISTERED:
    @SuppressWarnings("unchecked")
    final ServiceReference<ConfigurationAdmin> sr =
      (ServiceReference<ConfigurationAdmin>) event.getServiceReference();
    if (refCA != sr) {
      refCA = sr;
    }
    break;
  case ServiceEvent.MODIFIED:
    break;
  case ServiceEvent.UNREGISTERING:
    if (refCA != null) {
      refCA = null;
    }
    break;
  default:
    break;
  }
}
 
Example #4
Source File: VoiceManagerTest.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException {
    voiceManager = getService(VoiceManager.class, VoiceManagerImpl.class);
    assertNotNull(voiceManager);

    BundleContext context = bundleContext;
    ttsService = new TTSServiceStub(context);
    sink = new SinkStub();
    voice = new VoiceStub();
    source = new AudioSourceStub();

    registerService(sink);
    registerService(voice);

    Dictionary<String, Object> voiceConfig = new Hashtable<>();
    voiceConfig.put(CONFIG_DEFAULT_TTS, ttsService.getId());
    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    Configuration configuration = configAdmin.getConfiguration(VoiceManagerImpl.CONFIGURATION_PID);
    configuration.update(voiceConfig);

    audioManager = new AudioManagerStub();
    registerService(audioManager);
}
 
Example #5
Source File: DirDeployerImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public DirDeployerImpl()
  {
//    logTracker =
//      new ServiceTracker<LogService, LogService>(Activator.bc,
//                                                 LogService.class, null);
//    logTracker.open();

    caTracker =
      new ServiceTracker<ConfigurationAdmin, ConfigurationAdmin>(
                                                                 Activator.bc,
                                                                 ConfigurationAdmin.class,
                                                                 null);
    caTracker.open();

    // create and register the configuration class
    config = new Config();
  }
 
Example #6
Source File: VoiceManagerTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException {
    voiceManager = getService(VoiceManager.class, VoiceManagerImpl.class);
    assertNotNull(voiceManager);

    BundleContext context = bundleContext;
    ttsService = new TTSServiceStub(context);
    sink = new SinkStub();
    voice = new VoiceStub();
    source = new AudioSourceStub();

    registerService(sink);
    registerService(voice);

    Dictionary<String, Object> voiceConfig = new Hashtable<String, Object>();
    voiceConfig.put(CONFIG_DEFAULT_TTS, ttsService.getId());
    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    Configuration configuration = configAdmin.getConfiguration(PID);
    configuration.update(voiceConfig);

    audioManager = new AudioManagerStub();
    registerService(audioManager);
}
 
Example #7
Source File: VoiceManagerTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void interpretSomethingWhenTheDefaultHliIsSetAndItIsARegisteredService()
        throws IOException, InterpretationException {
    stubConsole = new ConsoleStub();
    hliStub = new HumanLanguageInterpreterStub();
    registerService(hliStub);

    Dictionary<String, Object> voiceConfig = new Hashtable<String, Object>();
    voiceConfig.put("defaultHLI", hliStub.getId());
    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    String pid = "org.eclipse.smarthome.voice";
    Configuration configuration = configAdmin.getConfiguration(pid);
    configuration.update(voiceConfig);

    String result = voiceManager.interpret("something", hliStub.getId());
    assertThat(result, is("Interpreted text"));
}
 
Example #8
Source File: ConfigurableServiceResourceOSGiTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    Configuration configuration = mock(Configuration.class);
    doAnswer(answer -> propertiesWrapper.getWrappedObject()).when(configuration).getProperties();
    doAnswer(answer -> {
        propertiesWrapper.set(answer.getArgument(0));
        return null;
    }).when(configuration).update(any(Dictionary.class));
    doAnswer(answer -> {
        propertiesWrapper.reset();
        return null;
    }).when(configuration).delete();

    propertiesWrapper.reset();

    ConfigurationAdmin configAdmin = mock(ConfigurationAdmin.class);
    when(configAdmin.getConfiguration(any())).thenReturn(configuration);
    when(configAdmin.getConfiguration(any(), nullable(String.class))).thenReturn(configuration);

    registerService(configAdmin);

    configurableServiceResource = getService(ConfigurableServiceResource.class);
    assertThat(configurableServiceResource, is(notNullValue()));
}
 
Example #9
Source File: InterpretCommandTest.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException, InterruptedException {
    ttsService = new TTSServiceStub();
    hliStub = new HumanLanguageInterpreterStub();
    voice = new VoiceStub();

    registerService(voice);
    registerService(hliStub);
    registerService(ttsService);

    Dictionary<String, Object> config = new Hashtable<>();
    config.put(CONFIG_DEFAULT_TTS, ttsService.getId());
    config.put(CONFIG_DEFAULT_HLI, hliStub.getId());
    config.put(CONFIG_DEFAULT_VOICE, voice.getUID());
    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    Configuration configuration = configAdmin.getConfiguration(VoiceManagerImpl.CONFIGURATION_PID);
    configuration.update(config);
}
 
Example #10
Source File: LogConfigImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * *************** Called from set methods *********************
 */

private void updateConfig() {
  try {
    final ServiceReference<ConfigurationAdmin> sr = bc
        .getServiceReference(ConfigurationAdmin.class);
    if (sr != null) {
      final ConfigurationAdmin ca = bc.getService(sr);
      if (ca != null) {
        final Configuration conf = ca.getConfiguration(pid);
        if (conf != null) {
          conf.update(configCollection);
        }
      }
      bc.ungetService(sr);
    }
  } catch (final IOException io) {
  } catch (final java.lang.IllegalArgumentException iae) {
  } catch (final java.lang.IllegalStateException ise) {
  }
}
 
Example #11
Source File: SystemMetatypeProvider.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
Set<String> getCMServicePIDs()
{
  final Set<String> pids = new HashSet<String>();
  final ConfigurationAdmin ca = cmTracker.getService();
  if (ca != null) {
    try {
      final Configuration[] configs = ca.listConfigurations("(service.pid=*)");
      for (int i = 0; configs != null && i < configs.length; i++) {
        if (configs[i].getFactoryPid() == null) {
          pids.add(configs[i].getPid());
        }
      }
    } catch (final Exception e) {
      log.error("Failed to get service pids", e);
    }
  }
  return pids;
}
 
Example #12
Source File: FirmwareRegistryOSGiTest.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
    LocaleProvider localeProvider = getService(LocaleProvider.class);
    assertThat(localeProvider, is(notNullValue()));
    defaultLocale = localeProvider.getLocale();

    new DefaultLocaleSetter(getService(ConfigurationAdmin.class)).setDefaultLocale(Locale.ENGLISH);
    waitForAssert(() -> assertThat(localeProvider.getLocale(), is(Locale.ENGLISH)));

    firmwareRegistry = getService(FirmwareRegistry.class);
    assertThat(firmwareRegistry, is(notNullValue()));

    registerService(basicFirmwareProviderMock);

    thing1 = ThingBuilder.create(THING_TYPE_UID1, THING1_ID).build();
    thing2 = ThingBuilder.create(THING_TYPE_UID1, THING2_ID).build();
    thing3 = ThingBuilder.create(THING_TYPE_UID2, THING3_ID).build();
}
 
Example #13
Source File: SystemMetatypeProvider.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
Set<String> getCMFactoryPIDs()
{
  final Set<String> pids = new HashSet<String>();
  final ConfigurationAdmin ca = cmTracker.getService();
  if (ca != null) {
    try {
      final Configuration[] configs = ca.listConfigurations("(service.pid=*)");
      for (int i = 0; configs != null && i < configs.length; i++) {
        if (configs[i].getFactoryPid() != null) {
          pids.add(configs[i].getFactoryPid());
        }
      }
    } catch (final Exception e) {
      log.error("Failed to get service pids", e);
    }
  }
  return pids;
}
 
Example #14
Source File: ConfigurationAdminFactory.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public ConfigurationAdmin getService(Bundle bundle,
                                     ServiceRegistration<ConfigurationAdmin> registration)
{
  // For now we don't keep track of the services returned internally
  return new ConfigurationAdminImpl(bundle);
}
 
Example #15
Source File: ComponentTestSuite.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void deleteConfig(ConfigurationAdmin ca, String location) throws IOException, InvalidSyntaxException {
  Configuration [] cs = ca.listConfigurations("(" + ConfigurationAdmin.SERVICE_BUNDLELOCATION + "=" + location + ")");
  if (cs != null) {
    for (Configuration c : cs) {
      c.delete();
    }
  }
}
 
Example #16
Source File: ConfigurationAdminFactory.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private <C> ConfigurationDictionary bindLocationIfNecessary(ServiceReference<C> sr,
                                                            ConfigurationDictionary d)
    throws IOException
{
  if (d == null) {
    return null;
  }
  if (sr == null) {
    return d;
  }
  String configLocation = d.getLocation();

  if (isNonExistingBundleLocation(configLocation)) {
    final Boolean dynamicLocation = (Boolean) d.get(DYNAMIC_BUNDLE_LOCATION);
    if (dynamicLocation != null && dynamicLocation.booleanValue()) {
      configLocation = null;
      d.remove(ConfigurationAdmin.SERVICE_BUNDLELOCATION);
      d.remove(DYNAMIC_BUNDLE_LOCATION);
    }
  }

  if (configLocation == null) {
    final String fpid = d.getFactoryPid();
    final String pid = d.getPid();
    final String serviceLocation = sr.getBundle().getLocation();
    final ConfigurationDictionary copy = d.createCopy();
    copy.put(ConfigurationAdmin.SERVICE_BUNDLELOCATION, serviceLocation);
    copy.put(DYNAMIC_BUNDLE_LOCATION, Boolean.TRUE);

    store.store(pid, fpid, copy, false);
    return copy;
  }
  return d;
}
 
Example #17
Source File: ConfigurationAdminFactory.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ServiceReference<ConfigurationAdmin> getServiceReference()
{
  if (serviceReference == null) {
    ServiceReference<?> [] refs = Activator.bc.getBundle().getRegisteredServices();
    if (refs == null || !ConfigurationAdmin.class.getName().equals(((String [])refs[0].getProperty(Constants.OBJECTCLASS))[0])){
      Activator.log.error("Could not get configuration admin service reference for configuration event creation.");
    } else {
      serviceReference = (ServiceReference<ConfigurationAdmin>)refs[0];
    }
  }
  return serviceReference;
}
 
Example #18
Source File: ConfigurableServiceResource.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private List<ConfigurableServiceDTO> getServicesByFilter(String filter) {
    List<ConfigurableServiceDTO> services = new ArrayList<>();
    ServiceReference<?>[] serviceReferences = null;
    try {
        serviceReferences = RESTCoreActivator.getBundleContext().getServiceReferences((String) null, filter);
    } catch (InvalidSyntaxException ex) {
        logger.error("Cannot get service references because the syntax of the filter '{}' is invalid.", filter);
    }

    if (serviceReferences != null) {
        for (ServiceReference<?> serviceReference : serviceReferences) {
            String id = getServiceId(serviceReference);
            String label = (String) serviceReference.getProperty(ConfigurableService.SERVICE_PROPERTY_LABEL);
            if (label == null) { // for multi context services the label can be changed and must be read from config
                                 // admin.
                label = configurationService.getProperty(id, ConfigConstants.SERVICE_CONTEXT);
            }
            String category = (String) serviceReference.getProperty(ConfigurableService.SERVICE_PROPERTY_CATEGORY);
            String configDescriptionURI = (String) serviceReference
                    .getProperty(ConfigurableService.SERVICE_PROPERTY_DESCRIPTION_URI);

            if (configDescriptionURI == null) {
                String factoryPid = (String) serviceReference.getProperty(ConfigurationAdmin.SERVICE_FACTORYPID);
                configDescriptionURI = getConfigDescriptionByFactoryPid(factoryPid);
            }

            boolean multiple = Boolean.parseBoolean(
                    (String) serviceReference.getProperty(ConfigurableService.SERVICE_PROPERTY_FACTORY_SERVICE));

            services.add(new ConfigurableServiceDTO(id, label, category, configDescriptionURI, multiple));
        }
    }
    return services;
}
 
Example #19
Source File: ConfigurationAdminFactory.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void ensureAutoPropertiesAreWritten()
{
  if (this.properties == null) {
    return;
  }
  this.properties.put(Constants.SERVICE_PID, getPid());
  if (getFactoryPid() != null) {
    this.properties.put(ConfigurationAdmin.SERVICE_FACTORYPID,
                        getFactoryPid());
  } else {
    this.properties.remove(ConfigurationAdmin.SERVICE_FACTORYPID);
  }
}
 
Example #20
Source File: ServletReregistrationService.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private Dictionary obtainProperties(){
    Dictionary properties = null;
    ServiceReference reference = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
    ConfigurationAdmin admin = (ConfigurationAdmin) bundleContext.getService(reference);
    try {
        Configuration configuration = admin.getConfiguration("org.apache.cxf.osgi");
        properties = configuration.getProperties();
    } catch (Exception e){
        log.warn("Unable to obtain cxf osgi configadmin reference.", e);
    }
    return properties;
}
 
Example #21
Source File: CMConfig.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Register Component as a subscriber of CM events which have
 * component name as CM pid.
 *
 * @param comp Component which config needs to be tracked
 * @return true if all pids are available, otherwise false
 */
boolean subscribe() {
  if (ComponentDescription.POLICY_IGNORE != policy) {
    for (int i = 0; i < pids.length; i++) {
      String[] cs = pids[i].getTargetedPIDs();
      Configuration [] conf = null;
      for (int j = cs.length - 1; j >= 0; j--) {
        handler.addSubscriberCMPid(cs[j], pids[i]);
        if (conf == null) {
          conf = handler.listConfigurations(ConfigurationAdmin.SERVICE_FACTORYPID, cs[j]);
          if (conf != null) {
            for (Configuration c : conf) {
              pids[i].configSet(pids[i].pid, c.getPid(), c, false);
            }
          }
        }
        if (conf == null) {
          conf = handler.listConfigurations(Constants.SERVICE_PID, cs[j]);
          if (conf != null) {
            pids[i].configSet(null, pids[i].pid, conf[0], false);
          }
        }
      }
    }
  }
  return isSatisfied();
}
 
Example #22
Source File: SymmetricKeyCipher.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Activate will try to load the encryption key. If an existing encryption key does not exists,
 * it will generate a new one and save to {@code org.osgi.service.cm.ConfigurationAdmin}
 *
 * @throws NoSuchAlgorithmException When encryption algorithm is not available {@code #ENCRYPTION_ALGO}
 * @throws IOException if access to persistent storage fails (@code org.osgi.service.cm.ConfigurationAdmin)
 */
@Activate
public SymmetricKeyCipher(final @Reference ConfigurationAdmin configurationAdmin)
        throws NoSuchAlgorithmException, IOException {
    this.configurationAdmin = configurationAdmin;
    // load or generate the encryption key
    encryptionKey = getOrGenerateEncryptionKey();
}
 
Example #23
Source File: ConfigurationAdminFactory.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void ungetService(Bundle bundle,
                         ServiceRegistration<ConfigurationAdmin> registration,
                         ConfigurationAdmin service)
{
  // For now we do nothing here
}
 
Example #24
Source File: CMCommands.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Configuration[] getConfigurations(PrintWriter out,
                                          Session session,
                                          ConfigurationAdmin cm,
                                          String selection)
    throws Exception
{
  return getConfigurations(out, session, cm, new String[] { selection });
}
 
Example #25
Source File: MDNSDiscoveryServiceOSGiTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
private void setBackgroundDiscoveryViaConfigAdmin(boolean status) throws IOException {
    ConfigurationAdmin configAdmin = getService(ConfigurationAdmin.class);
    assertThat(configAdmin, is(notNullValue()));

    Configuration configuration = configAdmin.getConfiguration("discovery.mdns");
    Hashtable<String, Object> properties = new Hashtable<>();
    properties.put(CONFIG_PROPERTY_BACKGROUND_DISCOVERY, Boolean.valueOf(status));

    configuration.update(properties);
}
 
Example #26
Source File: ConfigurationAdminFactory.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void setBundleLocationAndPersist(String bundleLocation, boolean dynamic)
{
  if (properties == null) {
    properties = new ConfigurationDictionary();
  }
  Object oldLoc = properties.get(ConfigurationAdmin.SERVICE_BUNDLELOCATION);
  boolean newLoc = bundleLocation == null ? oldLoc != null : !bundleLocation.equals(oldLoc);
  if (dynamic) {
    properties.put(DYNAMIC_BUNDLE_LOCATION, Boolean.TRUE);
  } else {
    properties.remove(DYNAMIC_BUNDLE_LOCATION);
  }
  if (newLoc) {
    if (bundleLocation == null) {
      properties.remove(ConfigurationAdmin.SERVICE_BUNDLELOCATION);
    } else {
      putLocation(bundleLocation);
    }
  }
  try {
    update(false, false);
  } catch (final IOException e) {
    Activator.log.error("Property save failed", e);
  }
  if (newLoc) {
    ConfigurationAdminFactory.this
    .sendEvent(createEvent(ConfigurationEvent.CM_LOCATION_CHANGED));
  }
}
 
Example #27
Source File: VoiceManagerTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void startDialogWithoutPassingAnyParameters() throws IOException, InterruptedException {
    sttService = new STTServiceStub();
    ksService = new KSServiceStub();
    ttsService = new TTSServiceStub();
    hliStub = new HumanLanguageInterpreterStub();
    source = new AudioSourceStub();

    registerService(sttService);
    registerService(ksService);
    registerService(ttsService);
    registerService(hliStub);
    registerService(source);

    Dictionary<String, Object> config = new Hashtable<>();
    config.put(CONFIG_KEYWORD, "word");
    config.put(CONFIG_DEFAULT_STT, sttService.getId());
    config.put(CONFIG_DEFAULT_KS, ksService.getId());
    config.put(CONFIG_DEFAULT_HLI, hliStub.getId());
    config.put(CONFIG_DEFAULT_VOICE, voice.getUID());

    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    Configuration configuration = configAdmin.getConfiguration(VoiceManagerImpl.CONFIGURATION_PID);
    configuration.update(config);

    waitForAssert(() -> {
        try {
            voiceManager.startDialog();
        } catch (Exception ex) {
            // if the configuration is not updated yet the startDialog method will throw and exception which will
            // break the test
        }

        assertTrue(ksService.isWordSpotted());
    });
}
 
Example #28
Source File: VoiceManagerTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void interpretSomethingWhenTheDefaultHliIsSetAndItIsARegisteredService()
        throws IOException, InterpretationException {
    hliStub = new HumanLanguageInterpreterStub();
    registerService(hliStub);

    Dictionary<String, Object> voiceConfig = new Hashtable<>();
    voiceConfig.put("defaultHLI", hliStub.getId());
    ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class);
    Configuration configuration = configAdmin.getConfiguration(VoiceManagerImpl.CONFIGURATION_PID);
    configuration.update(voiceConfig);

    String result = voiceManager.interpret("something", hliStub.getId());
    assertThat(result, is("Interpreted text"));
}
 
Example #29
Source File: BindingInfoI18nTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void assertUsingDefaultLocale() throws Exception {
    // Set german locale
    ConfigurationAdmin configAdmin = getService(ConfigurationAdmin.class);
    assertThat(configAdmin, is(notNullValue()));

    Configuration config = configAdmin.getConfiguration(I18nProviderImpl.CONFIGURATION_PID, null);
    assertThat(config, is(notNullValue()));

    Dictionary<String, Object> properties = config.getProperties();
    if (properties == null) {
        properties = new Hashtable<>();
    }

    properties.put("language", "de");
    properties.put("region", "DE");

    config.update(properties);

    // before running the test with a default locale make sure the locale has been set
    LocaleProvider localeProvider = getService(LocaleProvider.class);
    assertThat(localeProvider, is(notNullValue()));

    waitForAssert(() -> assertThat(localeProvider.getLocale().toString(), is("de_DE")));

    bindingInstaller.exec(TEST_BUNDLE_NAME, () -> {
        // use default locale
        Set<BindingInfo> bindingInfos = bindingInfoRegistry.getBindingInfos(null);
        BindingInfo bindingInfo = bindingInfos.iterator().next();
        assertThat(bindingInfo, is(notNullValue()));
        assertThat(bindingInfo.getName(), is("Yahoo Wetter Binding"));
        assertThat(bindingInfo.getDescription(), is(
                "Das Yahoo Wetter Binding stellt verschiedene Wetterdaten wie die Temperatur, die Luftfeuchtigkeit und den Luftdruck für konfigurierbare Orte vom yahoo Wetterdienst bereit"));
    });
}
 
Example #30
Source File: ServiceBusInitializer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Reference(name = "osgi.configadmin.service",
        service = ConfigurationAdmin.class,
        unbind = "unsetConfigAdminService",
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC)
public void setConfigAdminService(ConfigurationAdmin configAdminService) {
    log.debug("Setting ConfigurationAdmin Service");
    ConfigurationHolder.getInstance().setConfigAdminService(configAdminService);
}