/** * Validates and sets the Data Policy on the RegionFactory used to create and configure the Region * from this FactoryBean. * * @param regionFactory the RegionFactory used by this FactoryBean to create and configure the * Region. * @param persistent a boolean value indicating whether the Region should be persistent and * persist it's data to disk. * @param dataPolicy the configured Data Policy for the Region. * @see #resolveDataPolicy(com.gemstone.gemfire.cache.RegionFactory, Boolean, String) * @see com.gemstone.gemfire.cache.DataPolicy * @see com.gemstone.gemfire.cache.RegionFactory */ protected void resolveDataPolicy( RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy != null) { assertDataPolicyAndPersistentAttributesAreCompatible(dataPolicy); regionFactory.setDataPolicy(dataPolicy); setDataPolicy(dataPolicy); } else { resolveDataPolicy(regionFactory, persistent, (String) null); } }
/** * Validates the configured Data Policy and may override it, taking into account the 'persistent' * attribute and constraints for the Region type. * * @param regionFactory the GemFire RegionFactory used to create the desired Region. * @param persistent a boolean value indicating whether the Region should persist it's data to * disk. * @param dataPolicy requested Data Policy as set by the user in the Spring GemFire configuration * meta-data. * @see com.gemstone.gemfire.cache.DataPolicy * @see com.gemstone.gemfire.cache.RegionFactory */ protected void resolveDataPolicy( RegionFactory<K, V> regionFactory, Boolean persistent, String dataPolicy) { if (dataPolicy != null) { DataPolicy resolvedDataPolicy = new DataPolicyConverter().convert(dataPolicy); Assert.notNull( resolvedDataPolicy, String.format("Data Policy '%1$s' is invalid.", dataPolicy)); assertDataPolicyAndPersistentAttributesAreCompatible(resolvedDataPolicy); regionFactory.setDataPolicy(resolvedDataPolicy); setDataPolicy(resolvedDataPolicy); } else { DataPolicy regionAttributesDataPolicy = getDataPolicy(getAttributes(), DataPolicy.DEFAULT); DataPolicy resolvedDataPolicy = (isPersistent() && DataPolicy.DEFAULT.equals(regionAttributesDataPolicy) ? DataPolicy.PERSISTENT_REPLICATE : regionAttributesDataPolicy); assertDataPolicyAndPersistentAttributesAreCompatible(resolvedDataPolicy); regionFactory.setDataPolicy(resolvedDataPolicy); setDataPolicy(resolvedDataPolicy); } }