use of org.opennms.features.topology.api.Operation in project opennms by OpenNMS.
the class OperationListShellCommand method doExecute.
@Override
protected Object doExecute() throws Exception {
final List<Operation> operations = Lists.newArrayList();
final Map<Operation, Map<String, Object>> properties = new HashMap<>();
final Collection<ServiceReference<Operation>> services = this.bundleContext.getServiceReferences(Operation.class, null);
if (services == null)
return null;
for (final ServiceReference<Operation> sr : services) {
final Operation operation = this.bundleContext.getService(sr);
if (operation == null)
continue;
operations.add(operation);
final Map<String, Object> props = new TreeMap<>();
for (final String key : sr.getPropertyKeys()) {
props.put(key, sr.getProperty(key));
}
properties.put(operation, props);
}
// Output
for (final Operation operation : operations) {
final String operationClass = operation.getClass().getName();
System.out.println(" " + makeLine(operationClass));
System.out.println(" Class: " + operationClass);
System.out.println(" ID: " + operation.getId());
final Map<String, Object> props = properties.get(operation);
if (!props.isEmpty()) {
System.out.println(" Service Properties:");
for (final String key : props.keySet()) {
final Object object = props.get(key);
final String value = (object instanceof Object[]) ? Arrays.toString((Object[]) object) : object.toString();
System.out.println(" " + key + "=" + value);
}
}
}
return null;
}
use of org.opennms.features.topology.api.Operation in project opennms by OpenNMS.
the class OperationListShellCommand method execute.
@Override
public Object execute() throws Exception {
final List<Operation> operations = Lists.newArrayList();
final Map<Operation, Map<String, Object>> properties = new HashMap<>();
final Collection<ServiceReference<Operation>> services = this.bundleContext.getServiceReferences(Operation.class, null);
if (services == null)
return null;
for (final ServiceReference<Operation> sr : services) {
final Operation operation = this.bundleContext.getService(sr);
if (operation == null)
continue;
operations.add(operation);
final Map<String, Object> props = new TreeMap<>();
for (final String key : sr.getPropertyKeys()) {
props.put(key, sr.getProperty(key));
}
properties.put(operation, props);
}
// Output
for (final Operation operation : operations) {
final String operationClass = operation.getClass().getName();
System.out.println(" " + makeLine(operationClass));
System.out.println(" Class: " + operationClass);
System.out.println(" ID: " + operation.getId());
final Map<String, Object> props = properties.get(operation);
if (!props.isEmpty()) {
System.out.println(" Service Properties:");
for (final String key : props.keySet()) {
final Object object = props.get(key);
final String value = (object instanceof Object[]) ? Arrays.toString((Object[]) object) : object.toString();
System.out.println(" " + key + "=" + value);
}
}
}
return null;
}
Aggregations