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
8 package org.opendaylight.controller.sal.core.api;
10 import java.util.Collection;
11 import java.util.Collections;
13 import org.osgi.framework.BundleActivator;
14 import org.osgi.framework.BundleContext;
15 import org.osgi.framework.ServiceReference;
16 import org.osgi.util.tracker.ServiceTracker;
17 import org.osgi.util.tracker.ServiceTrackerCustomizer;
19 public abstract class AbstractConsumer implements Consumer, BundleActivator,ServiceTrackerCustomizer<Broker, Broker> {
24 private BundleContext context;
25 private ServiceTracker<Broker, Broker> tracker;
26 private Broker broker;
29 public final void start(BundleContext context) throws Exception {
30 this.context = context;
31 this.startImpl(context);
32 tracker = new ServiceTracker<>(context, Broker.class, this);
39 public final void stop(BundleContext context) throws Exception {
45 protected void startImpl(BundleContext context) {
48 protected void stopImpl(BundleContext context) {
53 public Collection<ConsumerFunctionality> getConsumerFunctionality() {
54 return Collections.emptySet();
59 public Broker addingService(ServiceReference<Broker> reference) {
61 broker = context.getService(reference);
62 broker.registerConsumer(this, context);
70 public void modifiedService(ServiceReference<Broker> reference, Broker service) {
75 public void removedService(ServiceReference<Broker> reference, Broker service) {