use of org.osgi.service.component.runtime.dto.ReferenceDTO 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;
}
Aggregations