public final class HazelcastCachingProvider extends Object implements javax.cache.spi.CachingProvider
CachingProvider.
 
 This provider class is registered as a CachingProvider implementation.
 When Hazelcast is the only CachingProvider on the classpath,
 using Caching.getCachingProvider() will instantiate and return
 an instance of this class.
 
 This provider implementation delegates to a CachingProvider backed
 by either a member- or a client-side HazelcastInstance:
 
HazelcastMemberCachingProvider is the
 member-side CachingProvider implementationHazelcastClientCachingProvider is the
 client-side CachingProvider implementationWhen using Caching.getCachingProvider() without a class name argument,
 this provider is instantiated. The choice between member- or client-side provider
 is made by inspecting the value of system property
 hazelcast.jcache.provider.type:
 
member selects the member-side caching
     provider, while value client selects the client-side provider. Legacy value
     server is also accepted as an alias for member for backwards compatibility,
     however its usage is discouraged and will be removed in a future version.
     Other values result in a CacheException being thrown.When using one of Caching#getCachingProvider variants with an explicit
 class name argument, then:
 
com.hazelcast.cache.HazelcastCachingProvider as class name
     is identical to using Caching.getCachingProvider(); choice between
     member- or client-side caching provider is performed via system property
     hazelcast.jcache.provider.type as described above.MEMBER_CACHING_PROVIDER as
     class name will return a member-side caching providerCLIENT_CACHING_PROVIDER as
     class name will return a client-side caching providerCachingProvider.getCacheManager(URI, ClassLoader, Properties)
 and its variants control whether a HazelcastInstance will be created or reused
 to back the CacheManager being created:
 hazelcast.config.location specifies a URI to locate a Hazelcast
     member or client configuration file. Supports classpath:, file:,
     http: and https: URI schemes.
     Examples: classpath:com/acme/hazelcast.xml
     will locate hazelcast.xml in package com.acme,
     http://internal.acme.com/hazelcast.xml will locate the configuration from
     the given HTTP URL.hazelcast.instance.name specifies the instance name of a running
     HazelcastInstance. If no instance is found running by that name, then a new
     HazelcastInstance is started with a default configuration and the given
     instance name.CachingProvider#getCacheManager variant that accepts a
     URI as argument, and if no properties were provided or properties did not result
     in resolving a specific HazelcastInstance, then the URI argument is
     interpreted as a Hazelcast config location as follows:
      URI starts with one of supported schemes (classpath:, http:,
          https:, file:), then a Hazelcast XML configuration is loaded from that location.URI is interpreted as a system property. If System.getProperty(URI) returns a value that starts with one of supported schemes above, then
          a Hazelcast XML configuration is loaded from that location.URI or its resolved value as a system property does not start with a supported
          URI scheme, a default HazelcastInstance named "_hzinstance_jcache_shared" is
          created or used, if it already exists.propertiesByLocation(String) and propertiesByInstanceName(String)
 will create an appropriate Properties instance for use with
 getCacheManager(URI, ClassLoader, Properties).
 Obtain a member-side caching provider backed by an existing HazelcastInstance.
 In this example the member-side caching provider is selected by setting the value of
 system property hazelcast.jcache.provider.type to value "member". An existing
 HazelcastInstance is referenced by instance name in the Properties provided as
 argument to CachingProvider.getCacheManager(URI, ClassLoader, Properties).
 
 Config config = new Config();
 config.setInstanceName("hz-jcache");
 HazelcastInstance member = Hazelcast.newHazelcastInstance(config);
 System.setProperty("hazelcast.jcache.provider.type", "member");
 CachingProvider provider = Caching.getCachingProvider();
 CacheManager manager = provider.getCacheManager(null, null, HazelcastCachingProvider.propertiesByInstanceName("hz-jcache"));
 Cache cache = manager.createCache("sessions", new MutableConfiguration());
 cache.put("a", "b");
 
 Obtain a client-side caching provider, starting a default client HazelcastInstance
 In this example the client-side caching provider is selected as default option. A new
 client-side HazelcastInstance is created with default configuration once
 CachingProvider.getCacheManager() is called.
 
 // start a Hazelcast member for the client to connect to
 HazelcastInstance member = Hazelcast.newHazelcastInstance();
 // obtain a client-side (default) CachingProvider
 CachingProvider provider = Caching.getCachingProvider();
 // obtain the default CacheManager; since there is no JCache-backing client-side
 // HazelcastInstance started, this will start a new instance
 CacheManager manager = provider.getCacheManager();
 Cache cache = manager.createCache("sessions", new MutableConfiguration());
 cache.put("a", "b");
 
 | Modifier and Type | Field and Description | 
|---|---|
| static String | CLIENT_CACHING_PROVIDERClass name of the client-side Caching Provider | 
| static String | HAZELCAST_CONFIG_LOCATIONHazelcast config location property | 
| static String | HAZELCAST_INSTANCE_ITSELFHazelcast instance itself property | 
| static String | HAZELCAST_INSTANCE_NAMEHazelcast instance name property | 
| static String | MEMBER_CACHING_PROVIDERClass name of the member-side Caching Provider | 
| static String | SERVER_CACHING_PROVIDERDeprecated.  | 
| static String | SHARED_JCACHE_INSTANCE_NAMEName of default  HazelcastInstancewhich may be started when
 obtaining the defaultCachingProvider. | 
| Constructor and Description | 
|---|
| HazelcastCachingProvider() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close() | 
| void | close(ClassLoader classLoader) | 
| void | close(URI uri,
     ClassLoader classLoader) | 
| javax.cache.CacheManager | getCacheManager() | 
| javax.cache.CacheManager | getCacheManager(URI uri,
               ClassLoader classLoader) | 
| javax.cache.CacheManager | getCacheManager(URI uri,
               ClassLoader classLoader,
               Properties properties) | 
| ClassLoader | getDefaultClassLoader() | 
| Properties | getDefaultProperties() | 
| URI | getDefaultURI() | 
| boolean | isSupported(javax.cache.configuration.OptionalFeature optionalFeature) | 
| static Properties | propertiesByInstanceItself(HazelcastInstance instance)Create the  Propertieswith the provided instance itself. | 
| static Properties | propertiesByInstanceName(String instanceName)Create the  Propertieswith the provided instance name. | 
| static Properties | propertiesByLocation(String configFileLocation)Create the  Propertieswith the provided config file location. | 
| String | toString() | 
public static final String HAZELCAST_CONFIG_LOCATION
public static final String HAZELCAST_INSTANCE_NAME
public static final String HAZELCAST_INSTANCE_ITSELF
public static final String MEMBER_CACHING_PROVIDER
@Deprecated public static final String SERVER_CACHING_PROVIDER
MEMBER_CACHING_PROVIDER. This field is maintained for backwards compatibility.
 Its use is discouraged and will be removed in a future version.public static final String CLIENT_CACHING_PROVIDER
public static final String SHARED_JCACHE_INSTANCE_NAME
HazelcastInstance which may be started when
 obtaining the default CachingProvider.public static Properties propertiesByLocation(String configFileLocation)
Properties with the provided config file location.configFileLocation - the location of the config file to configurepublic static Properties propertiesByInstanceName(String instanceName)
Properties with the provided instance name.instanceName - the instance name to configurepublic static Properties propertiesByInstanceItself(HazelcastInstance instance)
Properties with the provided instance itself.instance - the instance itself to be usedpublic javax.cache.CacheManager getCacheManager(URI uri, ClassLoader classLoader, Properties properties)
getCacheManager in interface javax.cache.spi.CachingProviderpublic ClassLoader getDefaultClassLoader()
getDefaultClassLoader in interface javax.cache.spi.CachingProviderpublic URI getDefaultURI()
getDefaultURI in interface javax.cache.spi.CachingProviderpublic Properties getDefaultProperties()
getDefaultProperties in interface javax.cache.spi.CachingProviderpublic javax.cache.CacheManager getCacheManager(URI uri, ClassLoader classLoader)
getCacheManager in interface javax.cache.spi.CachingProviderpublic javax.cache.CacheManager getCacheManager()
getCacheManager in interface javax.cache.spi.CachingProviderpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface javax.cache.spi.CachingProviderpublic void close(ClassLoader classLoader)
close in interface javax.cache.spi.CachingProviderpublic void close(URI uri, ClassLoader classLoader)
close in interface javax.cache.spi.CachingProviderpublic boolean isSupported(javax.cache.configuration.OptionalFeature optionalFeature)
isSupported in interface javax.cache.spi.CachingProviderCopyright © 2021 Hazelcast, Inc.. All rights reserved.