}
@SuppressWarnings("unchecked")
public static EvictionConfig parseEvictionConfig(Element element)
{
EvictionConfig evictionConfig = new EvictionConfig();
if (element != null)
{
// If they set the default eviction policy in the element, use that
// in preference to the external attribute
String temp = XmlConfigHelper.getTagContents(element, "policyClass", ATTR, NAME);
String defaultEvPolicyClassName = null;
if (temp != null && temp.length() > 0)
{
defaultEvPolicyClassName = temp;
EvictionAlgorithmConfig eac = getEvictionAlgorithmConfig(temp);
evictionConfig.getDefaultEvictionRegionConfig().setEvictionAlgorithmConfig(eac);
}
temp = XmlConfigHelper.getTagContents(element, "wakeUpIntervalSeconds", ATTR, NAME);
int wakeupIntervalSeconds = 0;
if (temp != null)
{
wakeupIntervalSeconds = Integer.parseInt(temp);
}
if (wakeupIntervalSeconds <= 0)
{
wakeupIntervalSeconds = EvictionConfig.WAKEUP_DEFAULT;
}
evictionConfig.setWakeupInterval(wakeupIntervalSeconds * 1000);
int eventQueueSize = 0;
temp = XmlConfigHelper.getTagContents(element, "eventQueueSize", ATTR, NAME);
if (temp != null)
{
eventQueueSize = Integer.parseInt(temp);
}
if (eventQueueSize <= 0)
{
eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
}
evictionConfig.getDefaultEvictionRegionConfig().setEventQueueSize(eventQueueSize);
NodeList list = element.getElementsByTagName(EvictionRegionConfig.REGION);
if (list != null && list.getLength() > 0)
{
List regionConfigs = new ArrayList(list.getLength());
for (int i = 0; i < list.getLength(); i++)
{
org.w3c.dom.Node node = list.item(i);
if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
{
continue;
}
try
{
EvictionRegionConfig evictionRegionConfig = parseEvictionRegionConfig((Element) node, defaultEvPolicyClassName, eventQueueSize);
if (!evictionRegionConfig.getRegionFqn().equals(RegionManagerImpl.DEFAULT_REGION))
{
regionConfigs.add(evictionRegionConfig);
}
else
{
evictionConfig.getDefaultEvictionRegionConfig().setEventQueueSize(evictionRegionConfig.getEventQueueSize());
evictionConfig.getDefaultEvictionRegionConfig().setEvictionAlgorithmConfig(evictionRegionConfig.getEvictionAlgorithmConfig());
}
}
catch (MissingPolicyException missingPolicy)
{
LogFactory.getLog(EvictionConfig.class).warn(missingPolicy.getLocalizedMessage());
throw missingPolicy;
}
}
evictionConfig.setEvictionRegionConfigs(regionConfigs);
}
}
return evictionConfig;