use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class InfoProvider method getBundleInfo.
/**
* @see org.apache.felix.webconsole.bundleinfo.BundleInfoProvider#getBundleInfo(org.osgi.framework.Bundle,
* java.lang.String, java.util.Locale)
*/
public BundleInfo[] getBundleInfo(Bundle bundle, String webConsoleRoot, Locale locale) {
final List<ComponentDescriptionDTO> disabled = new ArrayList<ComponentDescriptionDTO>();
final List<ComponentConfigurationDTO> configurations = new ArrayList<ComponentConfigurationDTO>();
final Collection<ComponentDescriptionDTO> descs = scrService.getComponentDescriptionDTOs(bundle);
for (final ComponentDescriptionDTO d : descs) {
if (!scrService.isComponentEnabled(d)) {
disabled.add(d);
} else {
final Collection<ComponentConfigurationDTO> configs = scrService.getComponentConfigurationDTOs(d);
if (configs.isEmpty()) {
disabled.add(d);
} else {
configurations.addAll(configs);
}
}
}
Collections.sort(configurations, Util.COMPONENT_COMPARATOR);
if (configurations.isEmpty()) {
return NO_INFO;
}
BundleInfo[] ret = new BundleInfo[configurations.size() + disabled.size()];
int i = 0;
for (final ComponentDescriptionDTO cfg : disabled) {
ret[i] = toInfo(cfg, webConsoleRoot, locale);
i++;
}
for (final ComponentConfigurationDTO cfg : configurations) {
ret[i] = toInfo(cfg, webConsoleRoot, locale);
i++;
}
return ret;
}
use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentActivationTest method test_deactivate_fail.
@Test
public void test_deactivate_fail() throws Exception {
final String componentname = "ActivatorComponent.deactivate.fail";
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.ACTIVE);
disableAndCheck(cc);
}
use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentActivationTest method test_activate_service_factory_register_service.
@Test
public void test_activate_service_factory_register_service() throws Exception {
final String componentname = "ActivatorComponent.activate.service.factory.with.bind";
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
getServiceFromConfiguration(cc, ActivatorComponent.class);
findComponentConfigurationByName(componentname, ComponentConfigurationDTO.ACTIVE);
disableAndCheck(cc);
}
use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentActivationTest method test_activator_not_declared.
@Test
public void test_activator_not_declared() throws Exception {
final String componentname = "ActivatorComponent.no.decl";
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.ACTIVE);
disableAndCheck(cc);
}
use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentConfigurationTest method test_SimpleComponent_dynamic_optional_configuration_with_required_service.
@Test
public void test_SimpleComponent_dynamic_optional_configuration_with_required_service() throws Exception {
final String targetProp = "ref.target";
final String filterProp = "required";
final SimpleServiceImpl service = SimpleServiceImpl.create(bundleContext, "sample").setFilterProperty(filterProp);
try {
final String pid = "DynamicConfigurationComponentWithRequiredReference";
deleteConfig(pid);
delay();
// mandatory ref missing --> component unsatisfied
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
// dynamically configure without the correct target
configure(pid);
delay();
// mandatory ref missing --> component unsatisfied
findComponentConfigurationByName(pid, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
// dynamically configure with correct target
theConfig.put(targetProp, "(filterprop=" + filterProp + ")");
configure(pid);
delay();
findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertNotNull(SimpleComponent.INSTANCE);
TestCase.assertEquals(PROP_NAME, SimpleComponent.INSTANCE.getProperty(PROP_NAME));
TestCase.assertEquals(pid, SimpleComponent.INSTANCE.getProperty(Constants.SERVICE_PID));
final SimpleComponent instance = SimpleComponent.INSTANCE;
configure(pid);
delay();
// same instance after reconfiguration
findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertEquals(instance, SimpleComponent.INSTANCE);
TestCase.assertEquals(PROP_NAME, SimpleComponent.INSTANCE.getProperty(PROP_NAME));
TestCase.assertEquals(pid, SimpleComponent.INSTANCE.getProperty(Constants.SERVICE_PID));
TestCase.assertNotNull(SimpleComponent.INSTANCE.m_singleRef);
// reconfigure without target --> unsatisifed
theConfig.remove(targetProp);
configure(pid);
delay();
// mandatory ref missing --> component unsatisfied
findComponentConfigurationByName(pid, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
deleteConfig(pid);
delay();
// mandatory ref missing --> component unsatisfied
findComponentConfigurationByName(pid, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
disableAndCheck(cc);
TestCase.assertNull(SimpleComponent.INSTANCE);
} finally {
theConfig.remove(targetProp);
if (service != null) {
service.drop();
}
}
}
Aggregations