2 * Copyright (c) 2016 Brocade Communications 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.config.yang.config.legacy_entity_ownership_service_provider;
10 import com.google.common.reflect.AbstractInvocationHandler;
11 import com.google.common.reflect.Reflection;
12 import java.lang.reflect.Method;
13 import org.opendaylight.controller.config.api.DependencyResolver;
14 import org.opendaylight.controller.config.api.ModuleIdentifier;
15 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
16 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
17 import org.osgi.framework.BundleContext;
20 * @deprecated Replaced by blueprint wiring
23 public class LegacyEntityOwnershipServiceProviderModule extends AbstractLegacyEntityOwnershipServiceProviderModule {
24 private BundleContext bundleContext;
26 public LegacyEntityOwnershipServiceProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
27 super(identifier, dependencyResolver);
30 public LegacyEntityOwnershipServiceProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
31 LegacyEntityOwnershipServiceProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
32 super(identifier, dependencyResolver, oldModule, oldInstance);
36 public void customValidation() {
37 // add custom validation form module attributes here.
41 public AutoCloseable createInstance() {
42 final WaitingServiceTracker<EntityOwnershipService> tracker = WaitingServiceTracker.create(
43 EntityOwnershipService.class, bundleContext);
44 final EntityOwnershipService service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
46 return Reflection.newProxy(AutoCloseableEntityOwnershipService.class, new AbstractInvocationHandler() {
48 protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
49 if (method.getName().equals("close")) {
53 return method.invoke(service, args);
59 public void setBundleContext(final BundleContext bundleContext) {
60 this.bundleContext = bundleContext;
63 private interface AutoCloseableEntityOwnershipService extends EntityOwnershipService, AutoCloseable {