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
11 * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-dispatcher-impl
12 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
13 * Generated at: Wed Nov 06 13:02:32 CET 2013
15 * Do not modify this file unless it is present under src/main directory
17 package org.opendaylight.controller.config.yang.bgp.rib.impl;
19 import com.google.common.reflect.AbstractInvocationHandler;
20 import com.google.common.reflect.Reflection;
21 import java.lang.reflect.Method;
22 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
23 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
24 import org.osgi.framework.BundleContext;
27 * @deprecated Replaced by blueprint wiring but remains for backwards compatibility until downstream users
28 * of the provided config system service are converted to blueprint.
31 public final class BGPDispatcherImplModule extends org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPDispatcherImplModule {
32 private BundleContext bundleContext;
34 public BGPDispatcherImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier name,
35 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
36 super(name, dependencyResolver);
39 public BGPDispatcherImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier name,
40 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final BGPDispatcherImplModule oldModule,
41 final java.lang.AutoCloseable oldInstance) {
42 super(name, dependencyResolver, oldModule, oldInstance);
46 public AutoCloseable createInstance() {
47 // The BGPDispatcher instance is created and advertised as an OSGi service via blueprint
48 // so obtain it here (waiting if necessary).
49 final WaitingServiceTracker<BGPDispatcher> tracker =
50 WaitingServiceTracker.create(BGPDispatcher.class, this.bundleContext);
51 final BGPDispatcher service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
53 // Create a proxy to override close to close the ServiceTracker. The actual BGPDispatcher
54 // instance will be closed via blueprint.
55 return Reflection.newProxy(AutoCloseableBGPDispatcher.class, new AbstractInvocationHandler() {
57 protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
58 if (method.getName().equals("close")) {
63 return method.invoke(service, args);
68 void setBundleContext(final BundleContext bundleContext) {
69 this.bundleContext = bundleContext;
72 private interface AutoCloseableBGPDispatcher extends BGPDispatcher, AutoCloseable {