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;
12 import org.osgi.framework.BundleActivator;
13 import org.osgi.framework.BundleContext;
14 import org.osgi.framework.ServiceReference;
15 import org.osgi.util.tracker.ServiceTracker;
16 import org.osgi.util.tracker.ServiceTrackerCustomizer;
18 public abstract class AbstractConsumer implements Consumer, BundleActivator,ServiceTrackerCustomizer<Broker, Broker> {
20 private BundleContext context;
21 private ServiceTracker<Broker, Broker> tracker;
22 private Broker broker;
25 public final void start(final BundleContext context) throws Exception {
26 this.context = context;
27 this.startImpl(context);
28 tracker = new ServiceTracker<>(context, Broker.class, this);
35 public final void stop(final BundleContext context) throws Exception {
41 protected void startImpl(final BundleContext context) {
44 protected void stopImpl(final BundleContext context) {
49 public Collection<ConsumerFunctionality> getConsumerFunctionality() {
50 return Collections.emptySet();
55 public Broker addingService(final ServiceReference<Broker> reference) {
57 broker = context.getService(reference);
58 broker.registerConsumer(this, context);
66 public void modifiedService(final ServiceReference<Broker> reference, final Broker service) {
71 public void removedService(final ServiceReference<Broker> reference, final Broker service) {