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.binding.api;
10 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
11 import org.osgi.framework.BundleActivator;
12 import org.osgi.framework.BundleContext;
13 import org.osgi.framework.ServiceReference;
15 public abstract class AbstractBindingAwareConsumer implements BindingAwareConsumer,BundleActivator {
18 public final void start(BundleContext context) throws Exception {
20 ServiceReference<BindingAwareBroker> brokerRef = context.getServiceReference(BindingAwareBroker.class);
21 BindingAwareBroker broker = context.getService(brokerRef);
22 broker.registerConsumer(this, context);
23 //context.ungetService(brokerRef);
27 * Called when this bundle is started (before
28 * {@link #onSessionInitiated(ProviderContext)} so the Framework can perform
29 * the bundle-specific activities necessary to start this bundle. This
30 * method can be used to register services or to allocate any resources that
34 * This method must complete and return to its caller in a timely manner.
37 * The execution context of the bundle being started.
39 * If this method throws an exception, this bundle is marked as
40 * stopped and the Framework will remove this bundle's
41 * listeners, unregister all services registered by this bundle,
42 * and release all services used by this bundle.
44 protected void startImpl(BundleContext context) {
49 * Called when this bundle is stopped so the Framework can perform the
50 * bundle-specific activities necessary to stop the bundle. In general, this
51 * method should undo the work that the {@code BundleActivator.start} method
52 * started. There should be no active threads that were started by this
53 * bundle when this bundle returns. A stopped bundle must not call any
57 * This method must complete and return to its caller in a timely manner.
59 * @param context The execution context of the bundle being stopped.
60 * @throws Exception If this method throws an exception, the bundle is still
61 * marked as stopped, and the Framework will remove the bundle's
62 * listeners, unregister all services registered by the bundle, and
63 * release all services used by the bundle.
65 protected void stopImpl(BundleContext context) {
70 public final void stop(BundleContext context) throws Exception {