2163449b66dd0f2370e4de29322b3a34c094f6df
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / config / yang / config / distributed_datastore_provider / DistributedConfigDataStoreProviderModule.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
10
11 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
12 import org.opendaylight.controller.cluster.datastore.compat.LegacyDOMStoreAdapter;
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.osgi.framework.BundleContext;
17
18 @Deprecated
19 public class DistributedConfigDataStoreProviderModule extends AbstractDistributedConfigDataStoreProviderModule {
20     private BundleContext bundleContext;
21
22     public DistributedConfigDataStoreProviderModule(
23         final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
24         final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
25         super(identifier, dependencyResolver);
26     }
27
28     public DistributedConfigDataStoreProviderModule(final ModuleIdentifier identifier,
29             final DependencyResolver dependencyResolver, final DistributedConfigDataStoreProviderModule oldModule,
30             final AutoCloseable oldInstance) {
31         super(identifier, dependencyResolver, oldModule, oldInstance);
32     }
33
34     @Override
35     public void customValidation() {
36         // add custom validation form module attributes here.
37     }
38
39     @Override
40     public boolean canReuseInstance(final AbstractDistributedConfigDataStoreProviderModule oldModule) {
41         return true;
42     }
43
44     @Override
45     public AutoCloseable createInstance() {
46         // The DistributedConfigDataStore is provided via blueprint so wait for and return it here for
47         // backwards compatibility.
48         WaitingServiceTracker<DistributedDataStoreInterface> tracker = WaitingServiceTracker.create(
49                 DistributedDataStoreInterface.class, bundleContext, "(type=distributed-config)");
50         DistributedDataStoreInterface delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
51         return new LegacyDOMStoreAdapter(delegate) {
52             @Override
53             public void close() {
54                 tracker.close();
55             }
56         };
57     }
58
59     public void setBundleContext(final BundleContext bundleContext) {
60         this.bundleContext = bundleContext;
61     }
62 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.