summaryrefslogtreecommitdiffstats
path: root/infra/northbound/restconf/src
diff options
context:
space:
mode:
Diffstat (limited to 'infra/northbound/restconf/src')
-rw-r--r--infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/BrokerFacadeProvider.java47
-rw-r--r--infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/ControllerContextProvider.java38
-rw-r--r--infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java40
-rw-r--r--infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfApplicationProvider.java37
-rw-r--r--infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java12
-rw-r--r--infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfProvider.java28
-rw-r--r--infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfServiceProvider.java37
-rw-r--r--infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/StatisticsRestconfServiceWrapperProvider.java34
8 files changed, 250 insertions, 23 deletions
diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/BrokerFacadeProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/BrokerFacadeProvider.java
new file mode 100644
index 000000000..f6a7e5e81
--- /dev/null
+++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/BrokerFacadeProvider.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.northbound.restconf;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import io.fd.honeycomb.binding.init.ProviderTrait;
+import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter;
+import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
+import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
+
+final class BrokerFacadeProvider extends ProviderTrait<BrokerFacade> {
+
+ @Inject
+ @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG)
+ private DOMDataBroker domDataBroker;
+ @Inject
+ private DOMRpcService rpcService;
+ @Inject
+ private DOMNotificationRouter notificationService;
+ @Inject
+ private ControllerContext controllerContext;
+
+ @Override
+ protected BrokerFacade create() {
+ BrokerFacade brokerFacade =
+ BrokerFacade.newInstance(rpcService, domDataBroker, notificationService, controllerContext);
+ return brokerFacade;
+ }
+}
diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/ControllerContextProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/ControllerContextProvider.java
new file mode 100644
index 000000000..909f063d1
--- /dev/null
+++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/ControllerContextProvider.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.northbound.restconf;
+
+import com.google.inject.Inject;
+import io.fd.honeycomb.binding.init.ProviderTrait;
+import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
+
+final class ControllerContextProvider extends ProviderTrait<ControllerContext> {
+
+ @Inject
+ private DOMSchemaService schemaService;
+ @Inject
+ private DOMMountPointService mountPointService;
+
+ @Override
+ protected ControllerContext create() {
+ ControllerContext controllerCtx =
+ ControllerContext.newInstance(schemaService, mountPointService, schemaService);
+ return controllerCtx;
+ }
+}
diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java
index a87459560..8a3ee62f6 100644
--- a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java
+++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/JettyServerProvider.java
@@ -27,10 +27,21 @@ import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Password;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.WebAppContext;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletContainer;
+import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
+import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
+import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter;
+import org.opendaylight.netconf.sal.rest.impl.RestconfApplication;
+import org.opendaylight.netconf.sal.rest.impl.RestconfDocumentedExceptionMapper;
+import org.opendaylight.netconf.sal.rest.impl.XmlNormalizedNodeBodyReader;
+import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
+import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
final class JettyServerProvider extends ProviderTrait<Server> {
@@ -41,6 +52,7 @@ final class JettyServerProvider extends ProviderTrait<Server> {
"application/yang.data+xml",
"application/json",
"application/yang.data+json"};
+ public static final String RESTCONF_APP_NAME = "JAXRSRestconf";
@Inject
private RestconfConfiguration cfg;
@@ -48,6 +60,15 @@ final class JettyServerProvider extends ProviderTrait<Server> {
@Inject
private CredentialsConfiguration credentialsCfg;
+ @Inject
+ private RestconfApplication restconfApplication;
+
+ @Inject
+ private RestconfImpl restconf;
+
+ @Inject
+ private ControllerContext controllerContext;
+
@Override
protected Server create() {
Server server = new Server(new QueuedThreadPool(cfg.restPoolMaxSize.get(), cfg.restPoolMinSize.get()));
@@ -62,7 +83,26 @@ final class JettyServerProvider extends ProviderTrait<Server> {
final URL resource = getClass().getResource("/");
WebAppContext webapp = new WebAppContext(resource.getPath(), cfg.restconfRootPath.get());
+ // Create Restconf application implementation for server
+ ResourceConfig resourceConfig = new ResourceConfig();
+ resourceConfig.setApplicationName(RESTCONF_APP_NAME);
+ resourceConfig = resourceConfig.registerInstances(restconf, new NormalizedNodeJsonBodyWriter(),
+ new NormalizedNodeXmlBodyWriter(), new XmlNormalizedNodeBodyReader(controllerContext),
+ new JsonNormalizedNodeBodyReader(controllerContext),
+ new RestconfDocumentedExceptionMapper(controllerContext));
+ // register Restconf Application classes
+ resourceConfig.registerClasses(restconfApplication.getClasses());
+
+ // Create Servlet container which holds configured application
+ ServletContainer servlet = new ServletContainer(resourceConfig);
+ ServletHolder servletHolder = new ServletHolder(RESTCONF_APP_NAME, servlet);
+ // init on startup
+ servletHolder.setInitOrder(1);
+ // set service handler
server.setHandler(getGzip(service, webapp));
+
+ //add servlet with "/*" mapping
+ webapp.addServlet(servletHolder, "/*");
return server;
}
diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfApplicationProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfApplicationProvider.java
new file mode 100644
index 000000000..0f55b4947
--- /dev/null
+++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfApplicationProvider.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package io.fd.honeycomb.northbound.restconf;
+
+import com.google.inject.Inject;
+import io.fd.honeycomb.binding.init.ProviderTrait;
+import org.opendaylight.netconf.sal.rest.impl.RestconfApplication;
+import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
+import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
+
+public class RestconfApplicationProvider extends ProviderTrait<RestconfApplication> {
+
+ @Inject
+ private ControllerContext controllerContext;
+ @Inject
+ private StatisticsRestconfServiceWrapper statisticsRestconfServiceWrapper;
+
+ @Override
+ protected RestconfApplication create() {
+ return new RestconfApplication(controllerContext, statisticsRestconfServiceWrapper);
+ }
+}
diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java
index 1a59b7298..d2841baef 100644
--- a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java
+++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfModule.java
@@ -23,6 +23,11 @@ import io.fd.honeycomb.northbound.restconf.JettyServerStarter.RestconfJettyServe
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.opendaylight.netconf.sal.rest.api.RestConnector;
+import org.opendaylight.netconf.sal.rest.impl.RestconfApplication;
+import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
+import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
+import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
+import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,6 +35,7 @@ public class RestconfModule extends NorthboundAbstractModule<RestconfConfigurati
private static final Logger LOG = LoggerFactory.getLogger(RestconfModule.class);
+ public static final String HONEYCOMB_RESTCONF = "honeycomb-restconf";
public static final String RESTCONF_HTTP = "restconf-http";
public static final String RESTCONF_HTTPS = "restconf-https";
@@ -46,6 +52,12 @@ public class RestconfModule extends NorthboundAbstractModule<RestconfConfigurati
LOG.info("Starting RESTCONF Northbound");
install(new RestconfConfigurationModule());
+ bind(ControllerContext.class).toProvider(ControllerContextProvider.class).in(Singleton.class);
+ bind(BrokerFacade.class).toProvider(BrokerFacadeProvider.class).in(Singleton.class);
+ bind(RestconfImpl.class).toProvider(RestconfServiceProvider.class).in(Singleton.class);
+ bind(StatisticsRestconfServiceWrapper.class)
+ .toProvider(StatisticsRestconfServiceWrapperProvider.class).in(Singleton.class);
+ bind(RestconfApplication.class).toProvider(RestconfApplicationProvider.class).in(Singleton.class);
bind(Server.class).toProvider(JettyServerProvider.class).in(Singleton.class);
bind(ServerConnector.class).annotatedWith(Names.named(RESTCONF_HTTP))
.toProvider(HttpConnectorProvider.class)
diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfProvider.java
index a3b3fe902..85caf6621 100644
--- a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfProvider.java
+++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfProvider.java
@@ -17,17 +17,11 @@
package io.fd.honeycomb.northbound.restconf;
import com.google.inject.Inject;
-import com.google.inject.name.Named;
import io.fd.honeycomb.binding.init.ProviderTrait;
import io.fd.honeycomb.data.init.ShutdownHandler;
-import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.netconf.sal.rest.api.RestConnector;
import org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl;
+import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
@@ -36,27 +30,15 @@ final class RestconfProvider extends ProviderTrait<RestConnector> {
@Inject
private RestconfConfiguration cfg;
@Inject
- @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG)
- private DOMDataBroker domDataBroker;
- @Inject
- private SchemaService schemaService;
- @Inject
- private DOMRpcService rpcService;
- @Inject
- private DOMNotificationRouter notificationService;
- @Inject
private ShutdownHandler shutdownHandler;
@Inject
- private DOMMountPointService mountPointService;
+ private StatisticsRestconfServiceWrapper statsServiceWrapper;
@Override
protected RestconfProviderImpl create() {
- final RestconfProviderImpl instance = new RestconfProviderImpl(domDataBroker, schemaService, rpcService,
- notificationService, mountPointService,
- schemaService,
- IpAddressBuilder.getDefaultInstance(cfg.restconfWebsocketAddress.get()),
- new PortNumber(cfg.restconfWebsocketPort.get()));
-
+ final RestconfProviderImpl instance = new RestconfProviderImpl(statsServiceWrapper,
+ IpAddressBuilder.getDefaultInstance(cfg.restconfWebsocketAddress.get()),
+ new PortNumber(cfg.restconfWebsocketPort.get()));
// Required to properly initialize restconf (broker, schema ctx, etc.).
// Without that restconf would fail with 503 (service not available).
instance.start();
diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfServiceProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfServiceProvider.java
new file mode 100644
index 000000000..20dcc28ad
--- /dev/null
+++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/RestconfServiceProvider.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package io.fd.honeycomb.northbound.restconf;
+
+import com.google.inject.Inject;
+import io.fd.honeycomb.binding.init.ProviderTrait;
+import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
+import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
+import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
+
+public class RestconfServiceProvider extends ProviderTrait<RestconfImpl> {
+
+ @Inject
+ private ControllerContext controllerContext;
+ @Inject
+ private BrokerFacade brokerFacade;
+
+ @Override
+ protected RestconfImpl create() {
+ return RestconfImpl.newInstance(brokerFacade, controllerContext);
+ }
+}
diff --git a/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/StatisticsRestconfServiceWrapperProvider.java b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/StatisticsRestconfServiceWrapperProvider.java
new file mode 100644
index 000000000..f3a4c3b73
--- /dev/null
+++ b/infra/northbound/restconf/src/main/java/io/fd/honeycomb/northbound/restconf/StatisticsRestconfServiceWrapperProvider.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package io.fd.honeycomb.northbound.restconf;
+
+import com.google.inject.Inject;
+import io.fd.honeycomb.binding.init.ProviderTrait;
+import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
+import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
+
+public class StatisticsRestconfServiceWrapperProvider extends ProviderTrait<StatisticsRestconfServiceWrapper> {
+
+ @Inject
+ RestconfImpl restconfService;
+
+ @Override
+ protected StatisticsRestconfServiceWrapper create() {
+ return StatisticsRestconfServiceWrapper.newInstance(restconfService);
+ }
+}