2 * Copyright (c) 2014, 2017 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.netconf.sal.rest.doc;
10 import java.util.LinkedList;
11 import java.util.List;
12 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
13 import org.opendaylight.controller.sal.core.api.model.SchemaService;
14 import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
15 import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocGenerator;
16 import org.opendaylight.netconf.sal.rest.doc.mountpoints.MountPointSwagger;
17 import org.opendaylight.yangtools.concepts.ListenerRegistration;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class DocProvider {
23 private static final Logger LOG = LoggerFactory.getLogger(DocProvider.class);
25 private final List<AutoCloseable> toClose = new LinkedList<>();
27 public DocProvider(final SchemaService schemaService, final DOMMountPointService mountService) {
29 ApiDocGenerator.getInstance().setSchemaService(schemaService);
31 final ListenerRegistration<MountProvisionListener> registration = mountService
32 .registerProvisionListener(MountPointSwagger.getInstance());
33 MountPointSwagger.getInstance().setGlobalSchema(schemaService);
34 synchronized (toClose) {
35 toClose.add(registration);
37 MountPointSwagger.getInstance().setMountService(mountService);
39 LOG.debug("Restconf API Explorer started");
42 public void close() throws Exception {
43 synchronized (toClose) {
44 for (final AutoCloseable close : toClose) {