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 javax.naming.Context;
15 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
16 import org.osgi.framework.BundleActivator;
17 import org.osgi.framework.BundleContext;
18 import org.osgi.framework.ServiceReference;
19 import org.osgi.util.tracker.ServiceTracker;
20 import org.osgi.util.tracker.ServiceTrackerCustomizer;
22 public abstract class AbstractProvider implements BundleActivator, Provider,ServiceTrackerCustomizer<Broker, Broker> {
24 private Broker broker;
25 private BundleContext context;
26 private ServiceTracker<Broker, Broker> tracker;
28 public Collection<ProviderFunctionality> getProviderFunctionality() {
29 return Collections.emptySet();
33 public final void start(BundleContext context) throws Exception {
34 this.context = context;
35 this.startImpl(context);
36 tracker = new ServiceTracker<>(context, Broker.class, this);
40 protected void startImpl(BundleContext context) {
43 protected void stopImpl(BundleContext context) {
48 public final void stop(BundleContext context) throws Exception {
56 public Broker addingService(ServiceReference<Broker> reference) {
58 broker = context.getService(reference);
59 broker.registerProvider(this, context);
67 public void modifiedService(ServiceReference<Broker> reference, Broker service) {
72 public void removedService(ServiceReference<Broker> reference, Broker service) {