5ed25ebe3fb3f0548fed77ac5900ffddf5935323
[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.RestconfWrapperProviders;
12 import org.opendaylight.aaa.api.AAAService;
13 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
14 import org.osgi.framework.BundleContext;
15
16
17 public class RestConnectorModule
18         extends org.opendaylight.controller.config.yang.md.sal.rest.connector.AbstractRestConnectorModule {
19
20     private static RestConnectorRuntimeRegistration runtimeRegistration;
21
22     private BundleContext bundleContext;
23
24     public RestConnectorModule(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 RestConnectorModule(
30             final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
31             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
32             final org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorModule oldModule,
33             final java.lang.AutoCloseable oldInstance) {
34         super(identifier, dependencyResolver, oldModule, oldInstance);
35     }
36
37     @Override
38     public void customValidation() {
39         // add custom validation form module attributes here.
40     }
41
42     @Override
43     public java.lang.AutoCloseable createInstance() {
44
45         final WaitingServiceTracker<AAAService> aaaServiceWaitingServiceTracker =
46                 WaitingServiceTracker.create(AAAService.class, bundleContext);
47         aaaServiceWaitingServiceTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
48
49         final RestconfWrapperProviders wrapperProviders = new RestconfWrapperProviders(getWebsocketPort());
50         wrapperProviders.registerProviders(getDomBrokerDependency());
51
52         if (runtimeRegistration != null) {
53             runtimeRegistration.close();
54         }
55
56         runtimeRegistration = wrapperProviders.runtimeRegistration(getRootRuntimeBeanRegistratorWrapper());
57
58         return wrapperProviders;
59     }
60
61     public void setBundleContext(final BundleContext bundleContext) {
62         this.bundleContext = bundleContext;
63     }
64 }
65