1 7 package org.jboss.ejb3.mdb; 8 9 import java.beans.BeanInfo ; 10 import java.beans.Introspector ; 11 import java.beans.IntrospectionException ; 12 import java.beans.PropertyDescriptor ; 13 import java.beans.PropertyEditor ; 14 import java.beans.PropertyEditorManager ; 15 16 22 public class MDBConfig 23 { 24 protected int minPoolSize = 1; 25 protected int maxPoolSize = 15; 26 protected int keepAlive = 30000; 27 protected int maxMessages = 1; 28 protected String serverSessionPoolFactoryJNDI = "java:/StdJMSPool"; 29 protected String providerAdapterJNDI = "java:/DefaultJMSProvider"; 30 protected long reconnectInterval = 10000; 31 32 protected boolean useDLQ = true; 33 protected String dlq = "queue/DLQ"; 34 protected int dlqMaxTimesRedelivered = 10; 35 protected int dlqTimeToLive = 0; 36 protected String dlqUser; 37 protected String dlqPassword; 38 39 protected String messageSelector; 40 protected String destinationType; 41 protected String user; 42 protected String password; 43 protected String destination; 44 protected String acknowledgeMode; 45 protected String clientID; 46 protected String durability; 47 protected String subscriptionName; 48 49 public String getDlqUser() 50 { 51 return dlqUser; 52 } 53 54 public void setDlqUser(String dlqUser) 55 { 56 this.dlqUser = dlqUser; 57 } 58 59 public String getDlqPassword() 60 { 61 return dlqPassword; 62 } 63 64 public void setDlqPassword(String dlqPassword) 65 { 66 this.dlqPassword = dlqPassword; 67 } 68 69 73 public boolean isUseDLQ() 74 { 75 return useDLQ; 76 } 77 78 public void setUseDLQ(boolean useDLQ) 79 { 80 this.useDLQ = useDLQ; 81 } 82 83 88 public String getDlq() 89 { 90 return dlq; 91 } 92 93 public void setDlq(String dlq) 94 { 95 this.dlq = dlq; 96 } 97 98 103 public int getDlqMaxTimesRedelivered() 104 { 105 return dlqMaxTimesRedelivered; 106 } 107 108 public void setDlqMaxTimesRedelivered(int dlqMaxTimesRedelivered) 109 { 110 this.dlqMaxTimesRedelivered = dlqMaxTimesRedelivered; 111 } 112 113 public int getDlqTimeToLive() 114 { 115 return dlqTimeToLive; 116 } 117 118 public void setDlqTimeToLive(int dlqTimeToLive) 119 { 120 this.dlqTimeToLive = dlqTimeToLive; 121 } 122 123 public String getProviderAdapterJNDI() 124 { 125 return providerAdapterJNDI; 126 } 127 128 public void setProviderAdapterJNDI(String providerAdapterJNDI) 129 { 130 this.providerAdapterJNDI = providerAdapterJNDI; 131 } 132 133 public String getAcknowledgeMode() 134 { 135 return acknowledgeMode; 136 } 137 138 public void setAcknowledgeMode(String acknowledgeMode) 139 { 140 this.acknowledgeMode = acknowledgeMode; 141 } 142 143 public String getClientID() 144 { 145 return clientID; 146 } 147 148 public void setClientID(String clientID) 149 { 150 this.clientID = clientID; 151 } 152 153 160 public String getDurability() 161 { 162 return durability; 163 } 164 165 public void setDurability(String durability) 166 { 167 this.durability = durability; 168 } 169 170 public String getSubscriptionName() 171 { 172 return subscriptionName; 173 } 174 175 public void setSubscriptionName(String subscriptionName) 176 { 177 this.subscriptionName = subscriptionName; 178 } 179 180 public String getDestination() 181 { 182 return destination; 183 } 184 185 public void setDestination(String destination) 186 { 187 this.destination = destination; 188 } 189 190 public String getUser() 191 { 192 return user; 193 } 194 195 public void setUser(String user) 196 { 197 this.user = user; 198 } 199 200 public String getPassword() 201 { 202 return password; 203 } 204 205 public void setPassword(String password) 206 { 207 this.password = password; 208 } 209 210 public String getMessageSelector() 211 { 212 return messageSelector; 213 } 214 215 public void setMessageSelector(String messageSelector) 216 { 217 this.messageSelector = messageSelector; 218 } 219 220 public String getDestinationType() 221 { 222 return destinationType; 223 } 224 225 public void setDestinationType(String destinationType) 226 { 227 this.destinationType = destinationType; 228 } 229 230 public int getMinPoolSize() 231 { 232 return minPoolSize; 233 } 234 235 public void setMinPoolSize(int minPoolSize) 236 { 237 this.minPoolSize = minPoolSize; 238 } 239 240 public int getMaxPoolSize() 241 { 242 return maxPoolSize; 243 } 244 245 public void setMaxPoolSize(int maxPoolSize) 246 { 247 this.maxPoolSize = maxPoolSize; 248 } 249 250 public int getKeepAlive() 251 { 252 return keepAlive; 253 } 254 255 public void setKeepAlive(int keepAlive) 256 { 257 this.keepAlive = keepAlive; 258 } 259 260 public int getMaxMessages() 261 { 262 return maxMessages; 263 } 264 265 public void setMaxMessages(int maxMessages) 266 { 267 this.maxMessages = maxMessages; 268 } 269 270 public String getServerSessionPoolFactoryJNDI() 271 { 272 return serverSessionPoolFactoryJNDI; 273 } 274 275 public void setServerSessionPoolFactoryJNDI(String serverSessionPoolFactoryJNDI) 276 { 277 this.serverSessionPoolFactoryJNDI = serverSessionPoolFactoryJNDI; 278 } 279 280 public long getReconnectInterval() 281 { 282 return reconnectInterval; 283 } 284 285 public void setReconnectInterval(long reconnectInterval) 286 { 287 this.reconnectInterval = reconnectInterval; 288 } 289 290 public static MDBConfig createMDBConfig(ActivationSpec spec) 291 { 292 MDBConfig instance = new MDBConfig(); 293 BeanInfo beanInfo = null; 294 try 295 { 296 beanInfo = Introspector.getBeanInfo(MDBConfig.class); 297 } 298 catch (IntrospectionException e) 299 { 300 throw new RuntimeException (e.getMessage(), e); 301 } 302 PropertyDescriptor [] descriptors = beanInfo.getPropertyDescriptors(); 303 if (descriptors == null) 304 { 305 descriptors = new PropertyDescriptor [0]; 306 } 307 308 for (String name : spec.keySet()) 309 { 310 setAttribute(instance, descriptors, name, spec.get(name)); 311 312 } 313 return instance; 314 } 315 316 private static void setAttribute(Object instance, PropertyDescriptor [] descriptors, String attributeName, String attributeText) 317 { 318 for (int i = 0; i < descriptors.length; i++) 319 { 320 if (attributeName.equalsIgnoreCase(descriptors[i].getName())) 321 { 322 Class typeClass = descriptors[i].getPropertyType(); 323 324 Object value; 325 PropertyEditor editor = PropertyEditorManager.findEditor(typeClass); 326 if (editor == null) 327 { 328 throw new RuntimeException 329 ("No property editor for attribute: " + attributeName + 330 "; type=" + typeClass); 331 } 332 333 editor.setAsText(attributeText); 334 value = editor.getValue(); 335 try 336 { 337 descriptors[i].getWriteMethod().invoke(instance, new Object []{value}); 338 } 339 catch (Exception e) 340 { 341 throw new RuntimeException ("Error setting attribute '" + 342 attributeName + "' in MDBConfig", e); 343 } 344 break; 345 } 346 } } 348 349 } 350 | Popular Tags |