Fix checkstyle violations in sal-dom-broker-config and sal-binding-config
[controller.git] / opendaylight / md-sal / sal-binding-config / src / main / java / org / opendaylight / controller / config / yang / md / sal / binding / impl / RuntimeMappingModule.java
1 /*
2  * Copyright (c) 2014 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 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
12 import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
13 import org.osgi.framework.BundleContext;
14
15 /**
16  * Deprecated.
17  *
18  * @deprecated Replaced by blueprint wiring
19  */
20 @Deprecated
21 public final class RuntimeMappingModule extends AbstractRuntimeMappingModule {
22     private BundleContext bundleContext;
23
24     public RuntimeMappingModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
25             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
26         super(identifier, dependencyResolver);
27     }
28
29     public RuntimeMappingModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
30             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
31             final RuntimeMappingModule oldModule, final java.lang.AutoCloseable oldInstance) {
32         super(identifier, dependencyResolver, oldModule, oldInstance);
33     }
34
35     @Override
36     public void validate() {
37         super.validate();
38         Preconditions.checkNotNull(bundleContext);
39         // Add custom validation for module attributes here.
40     }
41
42     @Override
43     public boolean canReuseInstance(final AbstractRuntimeMappingModule oldModule) {
44         return true;
45     }
46
47     @Override
48     public AutoCloseable createInstance() {
49         // We need to return the concrete BindingToNormalizedNodeCodec instance for backwards compatibility
50         // for CSS users that inject the binding-dom-mapping-service.
51         final WaitingServiceTracker<BindingToNormalizedNodeCodec> tracker =
52                 WaitingServiceTracker.create(BindingToNormalizedNodeCodec.class, bundleContext);
53         final BindingToNormalizedNodeCodec service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
54
55         // Ideally we would close the ServiceTracker via the returned AutoCloseable but then we'd have to
56         // proxy the BindingToNormalizedNodeCodec instance which is problematic. It's OK to close the
57         // ServiceTracker here.
58         tracker.close();
59         return service;
60     }
61
62     public void setBundleContext(final BundleContext bundleContext) {
63         this.bundleContext = bundleContext;
64     }
65 }