2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.node.utils;
10 import com.google.common.cache.CacheBuilder;
11 import com.google.common.cache.CacheLoader;
12 import com.google.common.cache.LoadingCache;
13 import org.opendaylight.yangtools.yang.common.QName;
15 public final class QNameFactory {
16 private static final int MAX_QNAME_CACHE_SIZE = Integer.getInteger(
17 "org.opendaylight.controller.cluster.datastore.node.utils.qname-cache.max-size", 10000);
19 private static final LoadingCache<String, QName> CACHE = CacheBuilder.newBuilder().maximumSize(MAX_QNAME_CACHE_SIZE)
20 .weakValues().build(new CacheLoader<String, QName>() {
22 public QName load(final String key) {
23 return QName.create(key).intern();
27 private QNameFactory() {
31 public static QName create(final String name) {
32 return CACHE.getUnchecked(name);