2 * Copyright (c) 2016 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.restconf.nb.rfc8040.services.simple.impl;
10 import javax.ws.rs.Path;
11 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
12 import org.opendaylight.restconf.common.schema.SchemaExportContext;
13 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
14 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
15 import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
16 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfSchemaService;
17 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 * Implementation of {@link RestconfSchemaService}.
25 public class RestconfSchemaServiceImpl implements RestconfSchemaService {
27 private SchemaContextHandler schemaContextHandler;
28 private DOMMountPointServiceHandler domMountPointServiceHandler;
29 private DOMYangTextSourceProvider sourceProvider;
32 * Set {@link SchemaContextHandler} for getting actual {@link SchemaContext}
35 * @param schemaContextHandler
36 * handling schema context
37 * @param domMountPointServiceHandler
38 * handling dom mount point service
40 public RestconfSchemaServiceImpl(final SchemaContextHandler schemaContextHandler,
41 final DOMMountPointServiceHandler domMountPointServiceHandler,
42 final DOMYangTextSourceProvider sourceProvider) {
43 this.schemaContextHandler = schemaContextHandler;
44 this.domMountPointServiceHandler = domMountPointServiceHandler;
45 this.sourceProvider = sourceProvider;
49 public SchemaExportContext getSchema(final String identifier) {
50 final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get());
51 return ParserIdentifier.toSchemaExportContextFromIdentifier(schemaContextRef.get(), identifier,
52 this.domMountPointServiceHandler.get(), sourceProvider);
56 public synchronized void updateHandlers(final Object... handlers) {
57 for (final Object object : handlers) {
58 if (object instanceof SchemaContextHandler) {
59 schemaContextHandler = (SchemaContextHandler) object;
60 } else if (object instanceof DOMMountPointServiceHandler) {
61 domMountPointServiceHandler = (DOMMountPointServiceHandler) object;
62 } else if (object instanceof DOMYangTextSourceProvider) {
63 sourceProvider = (DOMYangTextSourceProvider) object;