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