08c903ae825b6f77619968144f049a6193fabe25
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / restconf / base / services / impl / RestconfSchemaServiceImpl.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.restconf.base.services.impl;
9
10 import org.opendaylight.restconf.base.services.api.RestconfSchemaService;
11 import org.opendaylight.restconf.common.references.SchemaContextRef;
12 import org.opendaylight.restconf.common.schema.SchemaExportContext;
13 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
14 import org.opendaylight.restconf.handlers.SchemaContextHandler;
15 import org.opendaylight.restconf.utils.parser.ParserIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17
18 /**
19  * Implementation of {@link RestconfSchemaService}.
20  *
21  */
22 public class RestconfSchemaServiceImpl implements RestconfSchemaService {
23
24     private final SchemaContextHandler schemaContextHandler;
25     private final DOMMountPointServiceHandler domMountPointServiceHandler;
26
27     /**
28      * Set {@link SchemaContextHandler} for getting actual {@link SchemaContext}
29      * .
30      *
31      * @param schemaContextHandler
32      *             handling schema context
33      * @param domMountPointServiceHandler
34      *             handling dom mount point service
35      */
36     public RestconfSchemaServiceImpl(final SchemaContextHandler schemaContextHandler,
37             final DOMMountPointServiceHandler domMountPointServiceHandler) {
38         this.schemaContextHandler = schemaContextHandler;
39         this.domMountPointServiceHandler = domMountPointServiceHandler;
40     }
41
42     @Override
43     public SchemaExportContext getSchema(final String identifier) {
44         final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get());
45         return ParserIdentifier.toSchemaExportContextFromIdentifier(schemaContextRef.get(), identifier,
46                 this.domMountPointServiceHandler.get());
47     }
48 }