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 org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
11 import org.opendaylight.restconf.common.schema.SchemaExportContext;
12 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
13 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
14 import org.opendaylight.restconf.nb.rfc8040.references.SchemaContextRef;
15 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfSchemaService;
16 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 * Implementation of {@link RestconfSchemaService}.
23 public class RestconfSchemaServiceImpl implements RestconfSchemaService {
25 private SchemaContextHandler schemaContextHandler;
26 private DOMMountPointServiceHandler domMountPointServiceHandler;
27 private DOMYangTextSourceProvider sourceProvider;
30 * Set {@link SchemaContextHandler} for getting actual {@link SchemaContext}
33 * @param schemaContextHandler
34 * handling schema context
35 * @param domMountPointServiceHandler
36 * handling dom mount point service
38 public RestconfSchemaServiceImpl(final SchemaContextHandler schemaContextHandler,
39 final DOMMountPointServiceHandler domMountPointServiceHandler,
40 final DOMYangTextSourceProvider sourceProvider) {
41 this.schemaContextHandler = schemaContextHandler;
42 this.domMountPointServiceHandler = domMountPointServiceHandler;
43 this.sourceProvider = sourceProvider;
47 public SchemaExportContext getSchema(final String identifier) {
48 final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get());
49 return ParserIdentifier.toSchemaExportContextFromIdentifier(schemaContextRef.get(), identifier,
50 this.domMountPointServiceHandler.get(), sourceProvider);
54 public synchronized void updateHandlers(final Object... handlers) {
55 for (final Object object : handlers) {
56 if (object instanceof SchemaContextHandler) {
57 schemaContextHandler = (SchemaContextHandler) object;
58 } else if (object instanceof DOMMountPointServiceHandler) {
59 domMountPointServiceHandler = (DOMMountPointServiceHandler) object;
60 } else if (object instanceof DOMYangTextSourceProvider) {
61 sourceProvider = (DOMYangTextSourceProvider) object;