fix tracing ping-pong DataBroker wiring bug in trace blueprint XML
[controller.git] / opendaylight / md-sal / mdsal-trace / cli / src / main / java / org / opendaylight / controller / md / sal / trace / cli / PrintOpenTransactionsCommand.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.trace.cli;
9
10 import java.util.List;
11 import org.apache.karaf.shell.api.action.Action;
12 import org.apache.karaf.shell.api.action.Command;
13 import org.apache.karaf.shell.api.action.lifecycle.Reference;
14 import org.apache.karaf.shell.api.action.lifecycle.Service;
15 import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker;
16
17 /**
18  * Karaf CLI command to dump all open transactions.
19  *
20  * @author Michael Vorburger.ch
21  */
22 @Service
23 @Command(scope = "trace", name = "transactions",
24     description = "Show all (still) open transactions; including stack trace of creator, "
25     + "if transaction-debug-context-enabled is true in mdsaltrace_config.xml")
26 public class PrintOpenTransactionsCommand implements Action {
27
28     @Reference
29     private List<TracingDOMDataBroker> tracingDOMDataBrokers;
30
31     // NB: Do NOT have a non-default constructor for injection of @Reference
32     // Karaf needs a default constructor to create the command - and it works as is.
33
34     @Override
35     @SuppressWarnings("checkstyle:RegexpSingleLineJava")
36     public Object execute() throws Exception {
37         for (TracingDOMDataBroker tracingDOMDataBroker : tracingDOMDataBrokers) {
38             tracingDOMDataBroker.printOpenTransactions(System.out);
39         }
40         return null;
41     }
42
43 }