Add blueprint wiring for restconf connector
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / controller / config / yang / md / sal / rest / connector / RestConnectorModule.java
1 /*
2  * Copyright (c) 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.md.sal.rest.connector;
10
11 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
12 import org.opendaylight.netconf.sal.rest.api.RestConnector;
13 import org.osgi.framework.BundleContext;
14
15 @Deprecated
16 public class RestConnectorModule
17         extends org.opendaylight.controller.config.yang.md.sal.rest.connector.AbstractRestConnectorModule {
18
19     private BundleContext bundleContext;
20
21     public RestConnectorModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
22                                final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
23         super(identifier, dependencyResolver);
24     }
25
26     public RestConnectorModule(
27             final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
28             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
29             final org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorModule oldModule,
30             final java.lang.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 java.lang.AutoCloseable createInstance() {
41         final WaitingServiceTracker<RestConnector> tracker =
42                 WaitingServiceTracker.create(RestConnector.class, bundleContext);
43         tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
44
45         final class AutoCloseableRestConnector implements RestConnector, AutoCloseable {
46             @Override
47             public void close() {
48                 tracker.close();
49             }
50         }
51
52         return new AutoCloseableRestConnector();
53     }
54
55     public void setBundleContext(final BundleContext bundleContext) {
56         this.bundleContext = bundleContext;
57     }
58 }
59