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.servlet.ServletException;
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.aaa.filterchain.configuration.impl.CustomFilterAdapterConfigurationImpl;
import org.opendaylight.aaa.web.WebContext;
import org.opendaylight.aaa.web.WebContextSecurer;
import org.opendaylight.aaa.web.jetty.JettyWebServer;
import org.opendaylight.aaa.web.servlet.jersey2.JerseyServletSupport;
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.server.jaxrs.JaxRsEndpoint;
import org.opendaylight.restconf.server.jaxrs.JaxRsEndpointConfiguration;
import org.opendaylight.restconf.server.jaxrs.JaxRsLocationProvider;
import org.opendaylight.restconf.server.jaxrs.JaxRsRestconf;
import org.opendaylight.restconf.server.jaxrs.JsonJaxRsFormattableBodyWriter;
import org.opendaylight.restconf.server.jaxrs.XmlJaxRsFormattableBodyWriter;
import org.opendaylight.restconf.server.mdsal.MdsalDatabindProvider;
import org.opendaylight.restconf.server.mdsal.MdsalRestconfServer;
import org.opendaylight.restconf.server.mdsal.MdsalRestconfStreamRegistry;
import org.opendaylight.restconf.server.spi.ErrorTagMapping;
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;
private JaxRsEndpoint jaxRsEndpoint;
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() throws ServletException {
final Stopwatch stopwatch = Stopwatch.createStarted();
final JaxRsEndpointConfiguration 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);
this.jaxRsEndpoint = new JaxRsEndpoint(new JettyWebServer(httpPort), new LightyWebContextSecurer(),
new JerseyServletSupport(), new CustomFilterAdapterConfigurationImpl(), server,
new MdsalRestconfStreamRegistry(new JaxRsLocationProvider(), domDataBroker),
JaxRsEndpoint.props(streamsConfiguration));
final ServletContainer servletContainer8040 = new ServletContainer(ResourceConfig
.forApplication(new Application() {
@Override
public Set