e6056778c9327413e48011e83c7aa736dca0ceb7
[netconf.git] / netconf / sal-netconf-connector / src / main / java / org / opendaylight / netconf / sal / connect / impl / OSGiSchemaResourceManager.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.impl;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.netconf.sal.connect.api.SchemaResourceManager;
12 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
14 import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
15 import org.osgi.service.component.annotations.Activate;
16 import org.osgi.service.component.annotations.Component;
17 import org.osgi.service.component.annotations.Deactivate;
18 import org.osgi.service.component.annotations.Reference;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 @Beta
23 @Component(immediate = true)
24 public final class OSGiSchemaResourceManager implements SchemaResourceManager {
25     private static final Logger LOG = LoggerFactory.getLogger(OSGiSchemaResourceManager.class);
26
27     @Reference
28     YangParserFactory parserFactory;
29
30     private DefaultSchemaResourceManager delegate;
31
32     @Override
33     public SchemaResourcesDTO getSchemaResources(final NetconfNode node, final Object nodeId) {
34         return delegate.getSchemaResources(node, nodeId);
35     }
36
37     @Activate
38     void activate() {
39         delegate = new DefaultSchemaResourceManager(parserFactory);
40         LOG.info("Schema Resource Manager started");
41     }
42
43     @Deactivate
44     void deactivate() {
45         delegate = null;
46         LOG.info("Schema Resource Manager stopped");
47     }
48 }