use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentCommands method findComponents.
private List<ComponentDescriptionDTO> findComponents(String name) {
String lowerName = name.toLowerCase();
List<ComponentDescriptionDTO> matches = new LinkedList<>();
for (ComponentDescriptionDTO dto : scr.getComponentDescriptionDTOs()) {
if (dto.name.equalsIgnoreCase(name)) {
// Exact match, return only this component.
return Collections.singletonList(dto);
}
if (dto.name.toLowerCase().contains(lowerName))
matches.add(dto);
}
return matches;
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentCommands method disable.
@Descriptor("Disable an enabled component")
public boolean disable(@Descriptor("Name of the component") final String name) {
boolean changed = false;
for (ComponentDescriptionDTO comp : findComponents(name)) {
if (scr.isComponentEnabled(comp)) {
scr.disableComponent(comp);
changed = true;
}
}
return changed;
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ServiceComponentRuntimeImpl method getComponentDescriptionDTOs.
/**
* @see org.osgi.service.component.runtime.ServiceComponentRuntime#getComponentDescriptionDTOs(org.osgi.framework.Bundle[])
*/
public Collection<ComponentDescriptionDTO> getComponentDescriptionDTOs(Bundle... bundles) {
List<ComponentHolder<?>> holders;
if (bundles == null || bundles.length == 0) {
holders = componentRegistry.getComponentHolders();
} else {
holders = componentRegistry.getComponentHolders(bundles);
}
List<ComponentDescriptionDTO> result = new ArrayList<ComponentDescriptionDTO>(holders.size());
for (ComponentHolder<?> holder : holders) {
ComponentDescriptionDTO dto = holderToDescription(holder);
if (dto != null) {
result.add(dto);
}
}
return result;
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ServiceComponentRuntimeImpl method holderToDescription.
private ComponentDescriptionDTO holderToDescription(ComponentHolder<?> holder) {
ComponentDescriptionDTO dto = new ComponentDescriptionDTO();
ComponentMetadata m = holder.getComponentMetadata();
dto.activate = m.getActivate();
dto.bundle = bundleToDTO(holder.getActivator().getBundleContext());
// immediately return if bundle is not active anymore
if (dto.bundle == null) {
return null;
}
dto.configurationPid = m.getConfigurationPid().toArray(new String[m.getConfigurationPid().size()]);
dto.configurationPolicy = m.getConfigurationPolicy();
dto.deactivate = m.getDeactivate();
dto.defaultEnabled = m.isEnabled();
dto.factory = m.getFactoryIdentifier();
dto.immediate = m.isImmediate();
dto.implementationClass = m.getImplementationClassName();
dto.modified = m.getModified();
dto.name = m.getName();
dto.properties = deepCopy(m.getProperties());
dto.references = refsToDTO(m.getDependencies());
dto.scope = m.getServiceMetadata() == null ? null : m.getServiceMetadata().getScope().name();
dto.serviceInterfaces = m.getServiceMetadata() == null ? EMPTY : m.getServiceMetadata().getProvides();
return dto;
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentConfigurationPidTest method test_configurationpid_use_other_pid.
@Test
public void test_configurationpid_use_other_pid() throws Exception {
final String pid = "ConfigurationPid.otherPid";
final String name = "ConfigurationPid.componentName";
deleteConfig(pid);
delay();
TestCase.assertNull(SimpleComponent.INSTANCE);
getConfigurationsDisabledThenEnable(name, 0, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
TestCase.assertNull(SimpleComponent.INSTANCE);
configure(pid);
delay();
findComponentConfigurationByName(name, ComponentConfigurationDTO.ACTIVE);
TestCase.assertNotNull(SimpleComponent.INSTANCE);
TestCase.assertEquals(PROP_NAME, SimpleComponent.INSTANCE.getProperty(PROP_NAME));
deleteConfig(pid);
delay();
ComponentDescriptionDTO cd = checkConfigurationCount(name, 0, -1);
TestCase.assertNull(SimpleComponent.INSTANCE);
disableAndCheck(cd);
TestCase.assertNull(SimpleComponent.INSTANCE);
}
Aggregations