Tie together model namespace
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / netconf / schema / mapping / OSGiBaseNetconfSchemas.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.netconf.sal.connect.netconf.schema.mapping;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
12 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
13 import org.osgi.service.component.annotations.Activate;
14 import org.osgi.service.component.annotations.Component;
15 import org.osgi.service.component.annotations.Deactivate;
16 import org.osgi.service.component.annotations.Reference;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 @Beta
21 @Component(immediate = true)
22 public final class OSGiBaseNetconfSchemas implements BaseNetconfSchemas {
23     private static final Logger LOG = LoggerFactory.getLogger(OSGiBaseNetconfSchemas.class);
24
25     @Reference
26     YangParserFactory parserFactory;
27
28     private DefaultBaseNetconfSchemas delegate;
29
30     @Override
31     public BaseSchema getBaseSchema() {
32         return delegate.getBaseSchema();
33     }
34
35     @Override
36     public BaseSchema getBaseSchemaWithNotifications() {
37         return delegate.getBaseSchemaWithNotifications();
38     }
39
40     @Activate
41     void activate() throws YangParserException {
42         delegate = new DefaultBaseNetconfSchemas(parserFactory);
43         LOG.info("Base NETCONF Schemas started");
44     }
45
46     @Deactivate
47     void deactivate() {
48         delegate = null;
49         LOG.info("Base NETCONF Schemas stopped");
50     }
51 }