use of org.apache.felix.scr.Component in project karaf by apache.
the class ScrServiceMBeanImpl method componentState.
public int componentState(String componentName) {
int state = -1;
final Component component = findComponent(componentName);
if (component != null)
state = component.getState();
else
LOGGER.warn("No component found for name: " + componentName);
return state;
}
use of org.apache.felix.scr.Component 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.apache.felix.scr.Component 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.apache.felix.scr.Component in project fabric8 by fabric8io.
the class ScrState method checkBundle.
@Override
protected Check checkBundle(Bundle bundle) {
if (bundle.getHeaders().get("Service-Component") == null) {
return null;
}
ScrService svc = tracker.getService();
if (svc == null) {
return new Check("scr-state", "No ScrService found");
}
Component[] components = svc.getComponents(bundle);
if (components != null) {
for (Component component : components) {
int state = component.getState();
if (state != Component.STATE_ACTIVE && state != Component.STATE_REGISTERED && state != Component.STATE_FACTORY) {
return new Check("scr-state", "SCR bundle " + bundle.getBundleId() + " is in state " + getState(state));
}
}
}
return null;
}
Aggregations