2 * Copyright (c) 2013 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.config.threadpool.util;
11 import java.io.Closeable;
13 import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeMXBean;
14 import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeRegistration;
15 import org.opendaylight.controller.config.yang.threadpool.impl.EventBusRuntimeRegistrator;
17 import com.google.common.eventbus.DeadEvent;
18 import com.google.common.eventbus.EventBus;
19 import com.google.common.eventbus.Subscribe;
22 * Closeable {@link EventBus}.
24 public class CloseableEventBus extends EventBus implements Closeable {
26 private final EventBusRuntimeRegistration rootRegistration;
28 public CloseableEventBus(String identifier, EventBusRuntimeRegistrator rootRegistrator) {
30 rootRegistration = rootRegistrator.register(new EventBusRuntimeMXBean() {
31 private long deadEventsCounter = 0;
34 public void increaseDeadEvents(DeadEvent deadEvent) {
39 public Long countDeadEvents() {
40 return deadEventsCounter;
48 rootRegistration.close();