public final class CacheUtil extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getDistributedObjectName(String cacheName)
Convenience method to obtain the name of Hazelcast distributed object corresponding to the cache identified
by the given
cacheName , assuming null URI and ClassLoader prefixes. |
static String |
getDistributedObjectName(String cacheName,
URI uri,
ClassLoader classLoader)
Convenience method to obtain the name of Hazelcast distributed object corresponding to the cache identified
by the given arguments.
|
static String |
getPrefix(URI uri,
ClassLoader classLoader)
Gets the prefix of cache name without Hazelcast's
CacheManager
specific prefix HazelcastCacheManager.CACHE_MANAGER_PREFIX . |
static String |
getPrefixedCacheName(String name,
URI uri,
ClassLoader classLoader)
Gets the cache name with prefix but without Hazelcast's
CacheManager
specific prefix HazelcastCacheManager.CACHE_MANAGER_PREFIX . |
public static String getPrefix(URI uri, ClassLoader classLoader)
CacheManager
specific prefix HazelcastCacheManager.CACHE_MANAGER_PREFIX
.uri
- an implementation specific URI for the
Hazelcast's CacheManager
(null means use
Hazelcast's CachingProvider.getDefaultURI()
)classLoader
- the ClassLoader
to use for the
Hazelcast's CacheManager
(null means use
Hazelcast's CachingProvider.getDefaultClassLoader()
)CacheManager
specific prefix HazelcastCacheManager.CACHE_MANAGER_PREFIX
public static String getPrefixedCacheName(String name, URI uri, ClassLoader classLoader)
CacheManager
specific prefix HazelcastCacheManager.CACHE_MANAGER_PREFIX
.name
- the simple name of the cache without any prefixuri
- an implementation specific URI for the
Hazelcast's CacheManager
(null means use
Hazelcast's CachingProvider.getDefaultURI()
)classLoader
- the ClassLoader
to use for the
Hazelcast's CacheManager
(null means use
Hazelcast's CachingProvider.getDefaultClassLoader()
)CacheManager
specific prefix HazelcastCacheManager.CACHE_MANAGER_PREFIX
.public static String getDistributedObjectName(String cacheName)
cacheName
, assuming null URI
and ClassLoader
prefixes. This is equivalent to
invoking getDistributedObjectName(String, URI, ClassLoader)
with null
passed as URI
and
ClassLoader
arguments.cacheName
- the simple name of the cache without any prefixICache
distributed object corresponding to given cacheName, assuming
null URI & class loader prefixes.getDistributedObjectName(String, URI, ClassLoader)
public static String getDistributedObjectName(String cacheName, URI uri, ClassLoader classLoader)
ICache
as shown in this example:
HazelcastInstance hz = Hazelcast.newHazelcastInstance(); // Obtain Cache via JSR-107 API CachingProvider hazelcastCachingProvider = Caching.getCachingProvider( "com.hazelcast.cache.HazelcastCachingProvider", HazelcastCachingProvider.class.getClassLoader()); CacheManager cacheManager = hazelcastCachingProvider.getCacheManager(); Cache testCache = cacheManager.createCache("test", new MutableConfiguration<String, String>()); // URI and ClassLoader are null, since we created this cache with the default CacheManager, // otherwise we should pass the owning CacheManager's URI & ClassLoader as arguments. String distributedObjectName = CacheUtil.asDistributedObjectName("test", null, null); // Obtain a reference to the backing ICache via HazelcastInstance.getDistributedObject. // You may invoke this on any member of the cluster. ICache<String, String> distributedObjectCache = (ICache) hz.getDistributedObject( ICacheService.SERVICE_NAME, distributedObjectName);
cacheName
- the simple name of the cache without any prefixuri
- an implementation specific URI for the
Hazelcast's CacheManager
(null means use
Hazelcast's CachingProvider.getDefaultURI()
)classLoader
- the ClassLoader
to use for the
Hazelcast's CacheManager
(null means use
Hazelcast's CachingProvider.getDefaultClassLoader()
)ICache
distributed object corresponding to given arguments.Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.