2 * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.applications.reconciliation.cli;
10 import static java.util.Objects.requireNonNull;
12 import java.util.List;
13 import org.apache.karaf.shell.commands.Command;
14 import org.apache.karaf.shell.console.OsgiCommandSupport;
15 import org.opendaylight.openflowplugin.applications.reconciliation.ReconciliationManager;
16 import org.opendaylight.openflowplugin.applications.reconciliation.ReconciliationNotificationListener;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 @Command(scope = "reconciliation", name = "getRegisteredServices", description = "displaying services registered to "
21 + "Reconciliation Framework")
23 * CLI to display the service priority, service name and service status TODO
26 public class GetRegisteredServices extends OsgiCommandSupport {
27 private static final Logger LOG = LoggerFactory.getLogger(GetRegisteredServices.class);
28 private static final String CLI_FORMAT = "%d %-20s ";
30 private ReconciliationManager reconciliationManager;
32 public void setReconciliationManager(final ReconciliationManager reconciliationManager) {
33 this.reconciliationManager = requireNonNull(reconciliationManager, "ReconciliationManager can not be null!");
37 protected Object doExecute() {
38 LOG.debug("Executing getRegisteredServices to Reconciliation Framework command");
39 if (reconciliationManager.getRegisteredServices().isEmpty()) {
40 session.getConsole().println("No Services have registered to Reconciliation Framework");
42 for (List<ReconciliationNotificationListener> services : reconciliationManager.getRegisteredServices()
44 for (ReconciliationNotificationListener service : services) {
45 session.getConsole().println(String.format(CLI_FORMAT, service.getPriority(), service.getName()));