use of org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO in project karaf by apache.
the class DetailsAction method doScrAction.
@SuppressWarnings("rawtypes")
@Override
protected Object doScrAction(ServiceComponentRuntime serviceComponentRuntime) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Executing the Details Action");
}
System.out.println(SimpleAnsi.INTENSITY_BOLD + "Component Details" + SimpleAnsi.INTENSITY_NORMAL);
for (ComponentDescriptionDTO component : serviceComponentRuntime.getComponentDescriptionDTOs()) {
for (ComponentConfigurationDTO config : serviceComponentRuntime.getComponentConfigurationDTOs(component)) {
if (name.equals(component.name)) {
printDetail(" Name : ", component.name);
printDetail(" State : ", ScrUtils.getState(config.state));
Map<String, Object> map = new TreeMap<>(component.properties);
if (!map.isEmpty()) {
System.out.println(SimpleAnsi.INTENSITY_BOLD + " Properties : " + SimpleAnsi.INTENSITY_NORMAL);
for (Object key : map.keySet()) {
Object value = map.get(key);
printDetail(" ", key + "=" + value);
}
}
ReferenceDTO[] references = component.references;
System.out.println(SimpleAnsi.INTENSITY_BOLD + "References" + SimpleAnsi.INTENSITY_NORMAL);
for (ReferenceDTO reference : ScrUtils.emptyIfNull(ReferenceDTO.class, references)) {
ServiceReferenceDTO[] boundServices = null;
boolean satisfied = true;
for (SatisfiedReferenceDTO satRef : config.satisfiedReferences) {
if (satRef.name.equals(reference.name)) {
boundServices = satRef.boundServices;
satisfied = true;
}
}
for (UnsatisfiedReferenceDTO satRef : config.unsatisfiedReferences) {
if (satRef.name.equals(reference.name)) {
boundServices = satRef.targetServices;
satisfied = false;
}
}
printDetail(" Reference : ", reference.name);
printDetail(" State : ", satisfied ? "satisfied" : "unsatisfied");
printDetail(" Cardinality : ", reference.cardinality);
printDetail(" Policy : ", reference.policy);
printDetail(" PolicyOption : ", reference.policyOption);
// list bound services
for (ServiceReferenceDTO serviceReference : ScrUtils.emptyIfNull(ServiceReferenceDTO.class, boundServices)) {
final StringBuffer b = new StringBuffer();
b.append("Bound Service ID ");
b.append(serviceReference.properties.get(Constants.SERVICE_ID));
String componentName = (String) serviceReference.properties.get(ComponentConstants.COMPONENT_NAME);
if (componentName == null) {
componentName = (String) serviceReference.properties.get(Constants.SERVICE_PID);
if (componentName == null) {
componentName = (String) serviceReference.properties.get(Constants.SERVICE_DESCRIPTION);
}
}
if (componentName != null) {
b.append(" (");
b.append(componentName);
b.append(")");
}
printDetail(" Service Reference : ", b.toString());
}
if (ScrUtils.emptyIfNull(ServiceReferenceDTO.class, boundServices).length == 0) {
printDetail(" Service Reference : ", "No Services bound");
}
}
}
}
}
return null;
}
use of org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO in project karaf by apache.
the class ScrBundleStateService method getDiag.
@Override
public String getDiag(Bundle bundle) {
StringBuilder sb = new StringBuilder();
for (ComponentDescriptionDTO desc : scr.getComponentDescriptionDTOs(bundle)) {
for (ComponentConfigurationDTO cfg : scr.getComponentConfigurationDTOs(desc)) {
if (cfg.state != ComponentConfigurationDTO.ACTIVE && cfg.state != ComponentConfigurationDTO.SATISFIED) {
sb.append(cfg.description.name).append(" (").append(cfg.id).append(")\n");
if ((cfg.state & ComponentConfigurationDTO.UNSATISFIED_CONFIGURATION) != 0) {
sb.append(" missing configurations: ");
boolean first = true;
for (String s : cfg.description.configurationPid) {
if (!first) {
sb.append(", ");
}
sb.append(s);
first = false;
}
sb.append("\n");
}
if ((cfg.state & ComponentConfigurationDTO.UNSATISFIED_REFERENCE) != 0) {
sb.append(" missing references: ");
boolean first = true;
for (UnsatisfiedReferenceDTO ur : cfg.unsatisfiedReferences) {
if (!first) {
sb.append(", ");
}
sb.append(ur.name);
first = false;
}
sb.append("\n");
}
}
}
}
return sb.toString();
}
Aggregations