Class HazelcastUtils
- Since:
- 4.1.6
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanapplyConfiguration(URL url) Applies a configuration file to a Hazelcast instance.static booleanconfigureApplication(ClassLoader classLoader, String appName) Initializes the Hazelcast configuration for the given application.
-
Field Details
-
HAZELCAST_JNDI_NAME_PROP
System property name where an alternative name for Hazelcast JNDI object can be configured.- See Also:
-
HAZELCAST_JNDI_NAME
Name for Hazelcast JNDI object - defaults to "payara/Hazelcast"
-
-
Method Details
-
configureApplication
Initializes the Hazelcast configuration for the given application.The configuration must either be located in the application's working directory as "<appName>-hazelcast.xml" or on the classloader's path as "/META-INF/hazelcast.xml".
If appName is not set then the cache configuration is read by classloader only - i.e. it is fixed and cannot be overridden.
The fallback location of the configuration is in the jar of the application at /META-INF/hazelcast.xml.
If an application specific configuration cannot be found, then the system will fall back to Hazelcast's general defaults from hazelcast-config.xml.
If an application specific configuration xml cannot be parsed or has invalid values then this config wil be ignored and the system will fall back to Hazelcast's general defaults from hazelcast-config.xml.
If the configuration contains elements that already have been set in Hazelcast, they will be silently ignored.
You should call this only once within the applications life cycle, e.g. in static code or in a @Startup @Singleton.
Currently only JCache configurations are handled by this method.
- Parameters:
classLoader- Classloader for the application. Can not be null.appName- (optional) name of the application - used to construct config file name in the working dir for the <appName>-hazelcast.xml- Returns:
- true if the configurations have been made, i.e. if no internal exception was caught.
- Throws:
IllegalArgumentException- if classLoader is null
-
applyConfiguration
Applies a configuration file to a Hazelcast instance.If the configuration contains elements that already have been set in Hazelcast, they will be silently ignored.
You should call this only once within the applications life cycle, e.g. in static code or in a @Startup @Singleton.
Currently only JCache configurations are handled by this method.
- Parameters:
url- configuration file location- Returns:
- false if an exception was raised during the process, e.g. the configuration could not be found or parsed or if Hazelcast instance was not ready. Otherwise true.
-