use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class Felix3680_2Test method test_concurrent_injection_with_bundleContext.
@Test
public void test_concurrent_injection_with_bundleContext() throws Throwable {
for (int i = 0; i < 6; i++) {
final ComponentDescriptionDTO main = findComponentDescriptorByName("org.apache.felix.scr.integration.components.felix3680_2.Main");
enableAndCheck(main);
// run test for 30 seconds
delay(5);
disableAndCheck(main);
// async deactivate
delay();
if (log.getFirstFrameworkThrowable() != null) {
throw log.getFirstFrameworkThrowable();
}
for (Iterator it = log.foundWarnings().iterator(); it.hasNext(); ) {
String message = (String) it.next();
TestCase.fail("unexpected warning or error logged: " + message);
}
}
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class MutablePropertiesTest method test_mutable_properties_consumer.
@Test
public void test_mutable_properties_consumer() throws Exception {
ServiceReference<MutatingServiceConsumer> mscRef = bundleContext.getServiceReference(MutatingServiceConsumer.class);
MutatingServiceConsumer msc = bundleContext.getService(mscRef);
assertMsc(msc, null, null, null);
String componentName = "components.mutable.properties.return2";
ComponentDescriptionDTO cd = findComponentDescriptorByName(componentName);
enableAndCheck(cd);
assertMsc(msc, true, true, null);
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ScrServiceImpl method getComponents.
/**
* @see org.apache.felix.scr.ScrService#getComponents(java.lang.String)
*/
public Component[] getComponents(final String componentName) {
List<Component> result = new ArrayList<Component>();
final Collection<ComponentDescriptionDTO> descriptions = this.runtime.getComponentDescriptionDTOs();
for (final ComponentDescriptionDTO descDTO : descriptions) {
if (descDTO.name.equals(componentName)) {
final Collection<ComponentConfigurationDTO> configs = this.runtime.getComponentConfigurationDTOs(descDTO);
ComponentConfigurationDTO configDTO = null;
if (!configs.isEmpty()) {
configDTO = configs.iterator().next();
}
result.add(new ComponentWrapper(this.context, this.runtime, descDTO, configDTO));
}
}
return result.isEmpty() ? null : result.toArray(new Component[result.size()]);
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ScrServiceImpl method getComponents.
/**
* @see org.apache.felix.scr.ScrService#getComponents(org.osgi.framework.Bundle)
*/
public Component[] getComponents(final Bundle bundle) {
List<Component> result = new ArrayList<Component>();
final Collection<ComponentDescriptionDTO> descriptions = (bundle == null ? this.runtime.getComponentDescriptionDTOs() : this.runtime.getComponentDescriptionDTOs(bundle));
for (final ComponentDescriptionDTO descDTO : descriptions) {
final Collection<ComponentConfigurationDTO> configs = this.runtime.getComponentConfigurationDTOs(descDTO);
ComponentConfigurationDTO configDTO = null;
if (!configs.isEmpty()) {
configDTO = configs.iterator().next();
}
result.add(new ComponentWrapper(this.context, this.runtime, descDTO, configDTO));
}
return result.isEmpty() ? null : result.toArray(new Component[result.size()]);
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ScrCommand method change.
void change(final String componentIdentifier, final PrintWriter out, final boolean enable) {
final Result result = getComponentsFromArg(componentIdentifier, true);
for (final ComponentDescriptionDTO component : result.components) {
if (enable) {
if (!scrService.isComponentEnabled(component)) {
scrService.enableComponent(component);
out.println("Component " + component.name + " enabled");
} else {
out.println("Component " + component.name + " already enabled");
}
} else {
if (scrService.isComponentEnabled(component)) {
scrService.disableComponent(component);
out.println("Component " + component.name + " disabled");
} else {
out.println("Component " + component.name + " already disabled");
}
}
}
out.flush();
}
Aggregations