int localSize = 0;
Collection policyTypes = PolicyType.getPolicyTypes();
for (Iterator i = policyTypes.iterator();
i.hasNext() && localSize < Integer.MAX_VALUE;) {
PolicyType policyType = (PolicyType) i.next();
PolicyCacheConfiguration groupConfiguration =
getPolicyCacheConfiguration(policyType);
if (groupConfiguration != null) {
Integer integer = groupConfiguration.getMaxEntries();
if (integer != null) {
if (integer.intValue() != -1) {
localSize += integer.intValue();
} else {
localSize = Integer.MAX_VALUE;
}
} else {
localSize = Integer.MAX_VALUE;
}
}
}
// If the local size is still 0 then set it to one so that the cache
// can be built.
if (localSize == 0) {
localSize = 1;
}
RemotePoliciesConfiguration remotePolicies =
marinerConfig.getRemotePolicies();
RemotePolicyCacheConfiguration policyCacheConfiguration =
remotePolicies.getPolicyCache();
if (policyCacheConfiguration == null) {
policyCacheConfiguration = new RemotePolicyCacheConfiguration();
}
int remoteSize;
remoteSize = getInteger(policyCacheConfiguration.getMaxCacheSize(),
DEFAULT_REMOTE_GROUP_SIZE);
PolicyCacheBuilder builder = new PolicyCacheBuilder(
localSize, remoteSize);
CacheControlConstraints localConstraints = createLocalCacheConstraints(
Boolean.TRUE, null);
PolicyCachePartitionConstraints localPartitionConstraints =
createPartitionConstraints(localSize, localConstraints);
builder.setLocalPartitionConstraints(localPartitionConstraints);
PolicyCachePartitionConstraints remotePartitionConstraints =
createPartitionConstraints(remoteSize, remoteConstraints);
builder.setRemotePartitionConstraints(remotePartitionConstraints);
// Now build the policy specific groups to the local group.
for (Iterator i = policyTypes.iterator(); i.hasNext();) {
PolicyType policyType = (PolicyType) i.next();
PolicyCacheConfiguration groupConfiguration =
getPolicyCacheConfiguration(policyType);
int maxCount;
if (groupConfiguration == null) {
// Allow some entries in the group to ensure that when a policy