2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.northbound.restconf;
19 import com.google.inject.Singleton;
20 import com.google.inject.name.Names;
21 import io.fd.honeycomb.northbound.NorthboundAbstractModule;
22 import io.fd.honeycomb.northbound.restconf.JettyServerStarter.ServerInit;
23 import org.eclipse.jetty.server.Server;
24 import org.eclipse.jetty.server.ServerConnector;
25 import org.opendaylight.netconf.sal.rest.api.RestConnector;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 public class RestconfModule extends NorthboundAbstractModule<RestconfConfiguration> {
31 private static final Logger LOG = LoggerFactory.getLogger(RestconfModule.class);
33 public static final String RESTCONF_HTTP = "restconf-http";
34 public static final String RESTCONF_HTTPS = "restconf-https";
36 public RestconfModule() {
37 super(new RestconfConfigurationModule(), RestconfConfiguration.class);
41 protected void configure() {
42 if (!getConfiguration().isRestconfEnabled()) {
43 LOG.info("Restconf is disabled, skipping configuration");
47 LOG.info("Starting RESTCONF Northbound");
48 install(new RestconfConfigurationModule());
49 bind(Server.class).toProvider(JettyServerProvider.class).in(Singleton.class);
50 bind(ServerConnector.class).annotatedWith(Names.named(RESTCONF_HTTP))
51 .toProvider(HttpConnectorProvider.class)
53 bind(ServerConnector.class).annotatedWith(Names.named(RESTCONF_HTTPS))
54 .toProvider(HttpsConnectorProvider.class)
56 bind(RestConnector.class).toProvider(RestconfProvider.class).in(Singleton.class);
57 bind(ServerInit.class).toProvider(JettyServerStarter.class).asEagerSingleton();