2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight;
10 import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeRegistration;
11 import org.opendaylight.controller.config.yang.md.sal.rest.connector.RestConnectorRuntimeRegistrator;
12 import org.opendaylight.controller.sal.core.api.Broker;
13 import org.opendaylight.netconf.sal.rest.api.RestConnector;
14 import org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl;
15 import org.opendaylight.restconf.RestConnectorProvider;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
19 * Wrapping providers from restconf draft02 and draft11.
22 public class RestconfWrapperProviders implements AutoCloseable, RestConnector {
25 private final RestconfProviderImpl providerDraft02;
27 private final RestConnectorProvider providerDraft11;
30 * Init both providers:
32 * <li>draft02 - {@link RestconfProviderImpl}
33 * <li>draft11 - {@link RestConnectorProvider}
37 * - port for web sockets in provider for draft02
39 public RestconfWrapperProviders(final PortNumber port) {
40 // Init draft02 provider
41 this.providerDraft02 = new RestconfProviderImpl();
42 this.providerDraft02.setWebsocketPort(port);
44 // Init draft11 provider
45 this.providerDraft11 = new RestConnectorProvider();
49 * Register both providers, which will use the SAL layer:
51 * <li>draft02 - {@link RestconfProviderImpl}
52 * <li>draft11 - {@link RestConnectorProvider}
58 public void registerProviders(final Broker broker) {
59 // Register draft02 provider
60 broker.registerProvider(this.providerDraft02);
62 // Register draft11 provider
63 broker.registerProvider(this.providerDraft11);
67 * Register runtime beans from restconf draft02 {@link RestconfProviderImpl}
69 * @param runtimeRegistration
70 * - for register runtime beans
71 * @return {@link RestConnectorRuntimeRegistration}
73 public RestConnectorRuntimeRegistration runtimeRegistration(
74 final RestConnectorRuntimeRegistrator runtimeRegistration) {
75 return runtimeRegistration.register(this.providerDraft02);
79 public void close() throws Exception {
80 this.providerDraft02.close();
81 this.providerDraft11.close();