Merge "Fixed the problem in which different containers could have different mac addre...
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / osgi / YangStoreServiceImpl.java
1 /*
2  * Copyright (c) 2013 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
9 package org.opendaylight.controller.netconf.confignetconfconnector.osgi;
10
11 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
12
13 import javax.annotation.concurrent.GuardedBy;
14
15 public class YangStoreServiceImpl implements YangStoreService {
16     private final SchemaContextProvider service;
17     @GuardedBy("this")
18     private YangStoreSnapshotImpl cache = null;
19
20     public YangStoreServiceImpl(SchemaContextProvider service) {
21         this.service = service;
22     }
23
24     @Override
25     public synchronized YangStoreSnapshotImpl getYangStoreSnapshot() throws YangStoreException {
26         if (cache == null) {
27             cache = new YangStoreSnapshotImpl(service.getSchemaContext());
28         }
29         return cache;
30     }
31
32     /**
33      * Called when schema context changes, invalidates cache.
34      */
35     public synchronized void refresh() {
36         cache = null;
37     }
38 }