Convert sal-netconf-connector to OSGi DS
[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.model.parser.api.YangParserFactory;
12 import org.osgi.service.component.annotations.Activate;
13 import org.osgi.service.component.annotations.Component;
14 import org.osgi.service.component.annotations.Deactivate;
15 import org.osgi.service.component.annotations.Reference;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 @Beta
20 @Component(immediate = true)
21 public final class OSGiBaseNetconfSchemas implements BaseNetconfSchemas {
22     private static final Logger LOG = LoggerFactory.getLogger(OSGiBaseNetconfSchemas.class);
23
24     @Reference
25     YangParserFactory parserFactory;
26
27     private DefaultBaseNetconfSchemas delegate;
28
29     @Override
30     public BaseSchema getBaseSchema() {
31         return delegate.getBaseSchema();
32     }
33
34     @Override
35     public BaseSchema getBaseSchemaWithNotifications() {
36         return delegate.getBaseSchemaWithNotifications();
37     }
38
39     @Activate
40     void activate() {
41         delegate = new DefaultBaseNetconfSchemas(parserFactory);
42         LOG.info("Base NETCONF Schemas started");
43     }
44
45     @Deactivate
46     void deactivate() {
47         delegate = null;
48         LOG.info("Base NETCONF Schemas stopped");
49     }
50 }