2 * Copyright (c) 2014 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.yangtools.objcache;
10 import javax.annotation.Nonnull;
12 import org.opendaylight.yangtools.objcache.impl.StaticObjectCacheBinder;
13 import org.opendaylight.yangtools.objcache.spi.IObjectCacheFactory;
15 import com.google.common.base.Preconditions;
18 * Point of entry for acquiring an {@link ObjectCache} instance.
20 public final class ObjectCacheFactory {
21 private static IObjectCacheFactory FACTORY;
23 private static synchronized IObjectCacheFactory initialize() {
24 // Double-check under lock
25 if (FACTORY != null) {
29 final IObjectCacheFactory f = StaticObjectCacheBinder.getInstance().getProductCacheFactory();
34 public static synchronized void reset() {
39 * Get an ObjectCache for caching a particular object class. Note
40 * that it may be shared for multiple classes.
42 * @param objClass Class of objects which are to be cached
43 * @return Object cache instance.
45 public static ObjectCache getObjectCache(@Nonnull final Class<?> objClass) {
46 IObjectCacheFactory f = FACTORY;
51 return f.getObjectCache(Preconditions.checkNotNull(objClass));