1 22 package org.jboss.cache.config; 23 24 import org.apache.commons.logging.LogFactory; 25 import org.jboss.cache.Fqn; 26 import org.jboss.cache.eviction.EvictionPolicyConfig; 27 28 public class EvictionRegionConfig extends ConfigurationComponent 29 { 30 33 private static final long serialVersionUID = -5482474634995601400L; 34 35 public static final String NAME = "name"; 36 public static final String REGION = "region"; 37 public static final String REGION_POLICY_CLASS = "policyClass"; 38 public static final String EVENT_QUEUE_SIZE = "eventQueueSize"; 39 40 private Fqn regionFqn; 41 @Dynamic 42 private Integer eventQueueSize; 43 private EvictionPolicyConfig evictionPolicyConfig; 44 45 public EvictionRegionConfig() 46 { 47 } 48 49 public EvictionPolicyConfig getEvictionPolicyConfig() 50 { 51 return evictionPolicyConfig; 52 } 53 54 public void setEvictionPolicyConfig(EvictionPolicyConfig config) 55 { 56 testImmutability("evictionPolicyConfig"); 57 if (this.evictionPolicyConfig instanceof ConfigurationComponent) 58 { 59 removeChildConfig((ConfigurationComponent) this.evictionPolicyConfig); 60 } 61 if (config instanceof ConfigurationComponent) 62 { 63 addChildConfig((ConfigurationComponent) config); 64 } 65 if (config != null) 66 config.validate(); 67 68 this.evictionPolicyConfig = config; 69 } 70 71 public Fqn getRegionFqn() 72 { 73 return regionFqn; 74 } 75 76 public void setRegionFqn(Fqn regionFqn) 77 { 78 testImmutability("regionFqn"); 79 this.regionFqn = regionFqn; 80 } 81 82 public String getRegionName() 83 { 84 return regionFqn == null ? null : regionFqn.toString(); 85 } 86 87 public void setRegionName(String name) 88 { 89 setRegionFqn(name == null ? null : Fqn.fromString(name)); 90 } 91 92 public int getEventQueueSize() 93 { 94 return eventQueueSize == null ? EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT : eventQueueSize; 95 } 96 97 public void setEventQueueSize(int queueSize) 98 { 99 testImmutability("eventQueueSize"); 100 if (queueSize <= 0) 101 { 102 LogFactory.getLog(EvictionRegionConfig.class).warn("Ignoring invalid queue capacity " + 103 queueSize + " -- using " + 104 EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT); 105 queueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT; 106 } 107 this.eventQueueSize = queueSize; 108 } 109 110 public void setDefaultEventQueueSize(int queueSize) 111 { 112 if (eventQueueSize == null) 113 setEventQueueSize(queueSize); 114 } 115 116 117 @Override 118 public boolean equals(Object obj) 119 { 120 if (this == obj) 121 return true; 122 123 if (obj instanceof EvictionRegionConfig) 124 { 125 EvictionRegionConfig other = (EvictionRegionConfig) obj; 126 return safeEquals(this.regionFqn, other.regionFqn); 127 } 128 return false; 129 } 130 131 @Override 132 public int hashCode() 133 { 134 int result = 17; 135 result = 31 * result + (regionFqn == null ? 0 : regionFqn.hashCode()); 136 137 return result; 138 } 139 140 141 } | Popular Tags |