2 * Copyright (c) 2015 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
9 package org.opendaylight.controller.config.yang.bmp.impl;
11 import com.google.common.reflect.AbstractInvocationHandler;
12 import com.google.common.reflect.Reflection;
13 import java.lang.reflect.Method;
14 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
15 import org.opendaylight.protocol.bmp.api.BmpDispatcher;
16 import org.osgi.framework.BundleContext;
19 * @deprecated Replaced by blueprint wiring but remains for backwards compatibility until downstream users
20 * of the provided config system service are converted to blueprint.
23 public class BmpDispatcherImplModule extends AbstractBmpDispatcherImplModule {
24 private BundleContext bundleContext;
26 public BmpDispatcherImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
27 super(identifier, dependencyResolver);
30 public BmpDispatcherImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.bmp.impl.BmpDispatcherImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
31 super(identifier, dependencyResolver, oldModule, oldInstance);
35 public void customValidation() {
36 // add custom validation form module attributes here.
40 public AutoCloseable createInstance() {
41 // The BmpDispatcher instance is created and advertised as an OSGi service via blueprint
42 // so obtain it here (waiting if necessary).
43 final WaitingServiceTracker<BmpDispatcher> tracker =
44 WaitingServiceTracker.create(BmpDispatcher.class, this.bundleContext);
45 final BmpDispatcher service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
47 // Create a proxy to override close to close the ServiceTracker. The actual BmpDispatcher
48 // instance will be closed via blueprint.
49 return Reflection.newProxy(BmpDispatcher.class, new AbstractInvocationHandler() {
51 protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
52 if (method.getName().equals("close")) {
56 return method.invoke(service, args);
62 void setBundleContext(BundleContext bundleContext) {
63 this.bundleContext = bundleContext;