Class HazelcastUtils
- java.lang.Object
-
- com.priint.pubserver.util.HazelcastUtils
-
public class HazelcastUtils extends java.lang.ObjectTools to configure Hazelcast datagrid.- Since:
- 4.1.6
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringHAZELCAST_JNDI_NAMEName for Hazelcast JNDI object - defaults to "payara/Hazelcast"static java.lang.StringHAZELCAST_JNDI_NAME_PROPSystem property name where an alternative name for Hazelcast JNDI object can be configured.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanapplyConfiguration(java.net.URL url)Applies a configuration file to a Hazelcast instance.static booleanconfigureApplication(java.lang.ClassLoader classLoader, java.lang.String appName)Initializes the Hazelcast configuration for the given application.
-
-
-
Field Detail
-
HAZELCAST_JNDI_NAME_PROP
public static final java.lang.String HAZELCAST_JNDI_NAME_PROP
System property name where an alternative name for Hazelcast JNDI object can be configured.- See Also:
- Constant Field Values
-
HAZELCAST_JNDI_NAME
public static final java.lang.String HAZELCAST_JNDI_NAME
Name for Hazelcast JNDI object - defaults to "payara/Hazelcast"
-
-
Method Detail
-
configureApplication
public static boolean configureApplication(java.lang.ClassLoader classLoader, java.lang.String appName)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:
java.lang.IllegalArgumentException- if classLoader is null
-
applyConfiguration
public static boolean applyConfiguration(java.net.URL url)
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.
-
-