Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2018 PANTHEON.tech s.r.o. All Rights Reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at https://www.eclipse.org/legal/epl-v10.html
*/
package io.lighty.modules.northbound.restconf.community.impl;
import com.google.common.base.Stopwatch;
import com.google.common.base.Throwables;
import io.lighty.core.controller.api.AbstractLightyModule;
import io.lighty.modules.northbound.restconf.community.impl.root.resource.discovery.RootFoundApplication;
import io.lighty.modules.northbound.restconf.community.impl.util.RestConfConfigUtils;
import io.lighty.server.LightyServerBuilder;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Set;
import javax.ws.rs.core.Application;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.api.query.PrettyPrintParam;
import org.opendaylight.restconf.nb.jaxrs.JaxRsRestconf;
import org.opendaylight.restconf.nb.jaxrs.JsonJaxRsFormattableBodyWriter;
import org.opendaylight.restconf.nb.jaxrs.XmlJaxRsFormattableBodyWriter;
import org.opendaylight.restconf.nb.rfc8040.ErrorTagMapping;
import org.opendaylight.restconf.nb.rfc8040.legacy.RestconfDocumentedExceptionMapper;
import org.opendaylight.restconf.nb.rfc8040.streams.StreamsConfiguration;
import org.opendaylight.restconf.server.mdsal.MdsalDatabindProvider;
import org.opendaylight.restconf.server.mdsal.MdsalRestconfServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CommunityRestConf extends AbstractLightyModule {
private static final Logger LOG = LoggerFactory.getLogger(CommunityRestConf.class);
private final DOMDataBroker domDataBroker;
private final DOMRpcService domRpcService;
private final DOMNotificationService domNotificationService;
private final DOMMountPointService domMountPointService;
private final DOMActionService domActionService;
private final DOMSchemaService domSchemaService;
private final int httpPort;
private final InetAddress inetAddress;
private final String restconfServletContextPath;
private Server jettyServer;
private LightyServerBuilder lightyServerBuilder;
public CommunityRestConf(final DOMDataBroker domDataBroker, final DOMRpcService domRpcService,
final DOMActionService domActionService, final DOMNotificationService domNotificationService,
final DOMMountPointService domMountPointService,
final DOMSchemaService domSchemaService, final InetAddress inetAddress,
final int httpPort, final String restconfServletContextPath,
final LightyServerBuilder serverBuilder) {
this.domDataBroker = domDataBroker;
this.domRpcService = domRpcService;
this.domActionService = domActionService;
this.domNotificationService = domNotificationService;
this.domMountPointService = domMountPointService;
this.lightyServerBuilder = serverBuilder;
this.domSchemaService = domSchemaService;
this.httpPort = httpPort;
this.inetAddress = inetAddress;
this.restconfServletContextPath = restconfServletContextPath;
}
public CommunityRestConf(final DOMDataBroker domDataBroker,
final DOMRpcService domRpcService, final DOMActionService domActionService,
final DOMNotificationService domNotificationService, final DOMMountPointService domMountPointService,
final DOMSchemaService domSchemaService, final InetAddress inetAddress, final int httpPort,
final String restconfServletContextPath) {
this(domDataBroker, domRpcService, domActionService, domNotificationService,
domMountPointService, domSchemaService, inetAddress, httpPort,
restconfServletContextPath, null);
}
@Override
protected boolean initProcedure() {
final Stopwatch stopwatch = Stopwatch.createStarted();
final StreamsConfiguration streamsConfiguration = RestConfConfigUtils.getStreamsConfiguration();
LOG.info("Starting RestconfApplication with configuration {}", streamsConfiguration);
final MdsalDatabindProvider databindProvider = new MdsalDatabindProvider(domSchemaService);
final var server = new MdsalRestconfServer(databindProvider, domDataBroker, domRpcService, domActionService,
domMountPointService);
final ServletContainer servletContainer8040 = new ServletContainer(ResourceConfig
.forApplication(new Application() {
@Override
public Set