1 22 package org.jboss.resource.adapter.jms.inflow; 23 24 import javax.jms.Queue ; 25 import javax.jms.Session ; 26 import javax.jms.Topic ; 27 import javax.resource.ResourceException ; 28 import javax.resource.spi.ActivationSpec ; 29 import javax.resource.spi.InvalidPropertyException ; 30 import javax.resource.spi.ResourceAdapter ; 31 32 import org.jboss.logging.Logger; 33 import org.jboss.util.Strings; 34 35 41 public class JmsActivationSpec implements ActivationSpec 42 { 43 44 private static final Logger log = Logger.getLogger(JmsActivationSpec.class); 45 46 47 private ResourceAdapter ra; 48 49 50 private String destination; 51 52 53 private boolean isTopic = false; 54 55 56 private String messageSelector; 57 58 59 private int acknowledgeMode; 60 61 62 private boolean subscriptionDurability; 63 64 65 private String clientId; 66 67 68 private String subscriptionName; 69 70 71 private long reconnectInterval = 10; 72 73 74 private String providerAdapterJNDI = "java:/DefaultJMSProvider"; 75 76 77 private String user; 78 79 80 private String pass; 81 82 83 private int maxMessages = 1; 84 85 86 private int minSession = 1; 87 88 89 private int maxSession = 15; 90 91 92 private long keepAlive = 60000; 93 94 95 private boolean sessionTransacted = true; 96 97 98 private String dLQHandler = "org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler"; 99 100 101 private boolean useDLQ = true; 102 103 104 private String dLQJNDIName = "queue/DLQ"; 105 106 107 private String dLQUser; 108 109 110 private String dLQPassword; 111 112 113 private String dLQClientID; 114 115 116 private int dLQMaxResent; 117 118 private int reconnectAttempts = 5; 120 121 private boolean redeliverUnspecified = true; 122 123 126 public String getAcknowledgeMode() 127 { 128 if (sessionTransacted) 129 return "TRANSACTED"; 130 else if (Session.DUPS_OK_ACKNOWLEDGE == acknowledgeMode) 131 return "DUPS_OK_ACKNOWLEDGE"; 132 else 133 return "AUTO_ACKNOWLEDGE"; 134 } 135 136 139 public void setAcknowledgeMode(String acknowledgeMode) 140 { 141 if ("DUPS_OK_ACKNOWLEDGE".equals(acknowledgeMode)) 142 this.acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE; 143 else if ("AUTO_ACKNOWLEDGE".equals(acknowledgeMode)) 144 this.acknowledgeMode = Session.AUTO_ACKNOWLEDGE; 145 else if ("SESSION_TRANSACTED".equals(acknowledgeMode)) 146 this.acknowledgeMode = Session.SESSION_TRANSACTED; 147 else 148 throw new IllegalArgumentException ("Unsupported acknowledgement mode " + acknowledgeMode); 149 } 150 151 154 public int getAcknowledgeModeInt() 155 { 156 if (sessionTransacted) 157 return Session.SESSION_TRANSACTED; 158 return acknowledgeMode; 159 } 160 161 164 public String getClientId() 165 { 166 return clientId; 167 } 168 169 172 public void setClientId(String clientId) 173 { 174 this.clientId = clientId; 175 } 176 177 180 public String getDestination() 181 { 182 return destination; 183 } 184 185 188 public void setDestination(String destination) 189 { 190 this.destination = destination; 191 } 192 193 196 public String getDestinationType() 197 { 198 if (isTopic) 199 return Topic .class.getName(); 200 else 201 return Queue .class.getName(); 202 } 203 204 207 public void setDestinationType(String destinationType) 208 { 209 if (Topic .class.getName().equals(destinationType)) 210 this.isTopic = true; 211 else 212 this.isTopic = false; 213 } 214 215 218 public boolean isTopic() 219 { 220 return isTopic; 221 } 222 223 226 public String getMessageSelector() 227 { 228 return messageSelector; 229 } 230 231 234 public void setMessageSelector(String messageSelector) 235 { 236 this.messageSelector = messageSelector; 237 } 238 239 242 public String getSubscriptionDurability() 243 { 244 if (subscriptionDurability) 245 return "Durable"; 246 else 247 return "NonDurable"; 248 } 249 250 253 public void setSubscriptionDurability(String subscriptionDurability) 254 { 255 this.subscriptionDurability = "Durable".equals(subscriptionDurability); 256 } 257 258 261 public boolean isDurable() 262 { 263 return subscriptionDurability; 264 } 265 266 269 public String getSubscriptionName() 270 { 271 return subscriptionName; 272 } 273 274 277 public void setSubscriptionName(String subscriptionName) 278 { 279 this.subscriptionName = subscriptionName; 280 } 281 282 285 public long getReconnectInterval() 286 { 287 return reconnectInterval; 288 } 289 290 293 public void setReconnectInterval(long reconnectInterval) 294 { 295 this.reconnectInterval = reconnectInterval; 296 } 297 298 301 public long getReconnectIntervalLong() 302 { 303 return reconnectInterval * 1000; 304 } 305 306 309 public String getProviderAdapterJNDI() 310 { 311 return providerAdapterJNDI; 312 } 313 314 317 public void setProviderAdapterJNDI(String providerAdapterJNDI) 318 { 319 this.providerAdapterJNDI = providerAdapterJNDI; 320 } 321 322 325 public String getUser() 326 { 327 return user; 328 } 329 330 333 public void setUser(String user) 334 { 335 this.user = user; 336 } 337 338 341 public String getPassword() 342 { 343 return pass; 344 } 345 346 349 public void setPassword(String pass) 350 { 351 this.pass = pass; 352 } 353 354 357 public int getMaxMessages() 358 { 359 return maxMessages; 360 } 361 362 365 public void setMaxMessages(int maxMessages) 366 { 367 this.maxSession = maxMessages; 368 } 369 370 373 public int getMaxMessagesInt() 374 { 375 return maxMessages; 376 } 377 378 381 public int getMinSession() 382 { 383 return minSession; 384 } 385 386 389 public void setMinSession(int minSession) 390 { 391 this.minSession = minSession; 392 } 393 394 397 public int getMinSessionInt() 398 { 399 return minSession; 400 } 401 402 405 public int getMaxSession() 406 { 407 return maxSession; 408 } 409 410 413 public void setMaxSession(int maxSession) 414 { 415 this.maxSession = maxSession; 416 } 417 418 421 public int getMaxSessionInt() 422 { 423 return maxSession; 424 } 425 426 429 public long getKeepAlive() 430 { 431 return keepAlive; 432 } 433 434 437 public void setKeepAlive(long keepAlive) 438 { 439 this.keepAlive = keepAlive; 440 } 441 442 445 public long getKeepAliveLong() 446 { 447 return keepAlive; 448 } 449 450 453 public boolean getSessionTransacted() 454 { 455 return sessionTransacted; 456 } 457 458 461 public void setSessionTransacted(boolean sessionTransacted) 462 { 463 this.sessionTransacted = sessionTransacted; 464 } 465 466 469 public boolean isSessionTransacted() 470 { 471 return sessionTransacted; 472 } 473 474 477 public String getDLQHandler() 478 { 479 return dLQHandler; 480 } 481 482 485 public void setDLQHandler(String handler) 486 { 487 this.dLQHandler = handler; 488 } 489 490 493 public String getDLQJNDIName() 494 { 495 return dLQJNDIName; 496 } 497 498 501 public void setDLQJNDIName(String name) 502 { 503 dLQJNDIName = name; 504 } 505 506 509 public boolean getUseDLQ() 510 { 511 return useDLQ; 512 } 513 514 517 public void setUseDLQ(boolean useDLQ) 518 { 519 this.useDLQ = useDLQ; 520 } 521 522 527 public boolean isUseDLQ() 528 { 529 return useDLQ; 530 } 531 532 535 public String getDLQClientID() 536 { 537 return dLQClientID; 538 } 539 540 543 public void setDLQClientID(String clientID) 544 { 545 dLQClientID = clientID; 546 } 547 548 551 public String getDLQPassword() 552 { 553 return dLQPassword; 554 } 555 556 559 public void setDLQPassword(String password) 560 { 561 dLQPassword = password; 562 } 563 564 567 public String getDLQUser() 568 { 569 return dLQUser; 570 } 571 572 575 public void setDLQUser(String user) 576 { 577 dLQUser = user; 578 } 579 580 583 public int getDLQMaxResent() 584 { 585 return dLQMaxResent; 586 } 587 590 public void setDLQMaxResent(int maxResent) 591 { 592 this.dLQMaxResent = maxResent; 593 } 594 595 public ResourceAdapter getResourceAdapter() 596 { 597 return ra; 598 } 599 600 public void setResourceAdapter(ResourceAdapter ra) throws ResourceException 601 { 602 this.ra = ra; 603 } 604 605 public void validate() throws InvalidPropertyException 606 { 607 if (log.isTraceEnabled()) 608 log.trace("validate " + this); 609 } 611 612 public String toString() 613 { 614 StringBuffer buffer = new StringBuffer (); 615 buffer.append(Strings.defaultToString(this)).append('('); 616 buffer.append("ra=").append(ra); 617 buffer.append(" destination=").append(destination); 618 buffer.append(" isTopic=").append(isTopic); 619 if (messageSelector != null) 620 buffer.append(" selector=").append(messageSelector); 621 buffer.append(" tx=").append(sessionTransacted); 622 if (sessionTransacted == false) 623 buffer.append(" ack=").append(getAcknowledgeMode()); 624 buffer.append(" durable=").append(subscriptionDurability); 625 if (clientId != null) 626 buffer.append(" clientID=").append(clientId); 627 if (subscriptionName != null) 628 buffer.append(" subscription=").append(subscriptionName); 629 buffer.append(" reconnect=").append(reconnectInterval); 630 buffer.append(" provider=").append(providerAdapterJNDI); 631 buffer.append(" user=").append(user); 632 if (pass != null) 633 buffer.append(" pass=").append("<not shown>"); 634 buffer.append(" maxMessages=").append(maxMessages); 635 buffer.append(" minSession=").append(minSession); 636 buffer.append(" maxSession=").append(maxSession); 637 buffer.append(" keepAlive=").append(keepAlive); 638 buffer.append(" useDLQ=").append(useDLQ); 639 if (useDLQ) 640 { 641 buffer.append(" DLQHandler=").append(dLQHandler); 642 buffer.append(" DLQJndiName=").append(dLQJNDIName); 643 buffer.append(" DLQUser=").append(dLQUser); 644 if (dLQPassword != null) 645 buffer.append(" DLQPass=").append("<not shown>"); 646 if (dLQClientID != null) 647 buffer.append(" DLQClientID=").append(dLQClientID); 648 buffer.append(" DLQMaxResent=").append(dLQMaxResent); 649 } 650 buffer.append(')'); 651 return buffer.toString(); 652 } 653 654 public int getReconnectAttempts() 655 { 656 return reconnectAttempts; 657 } 658 659 public void setReconnectAttempts(int reconnectAttempts) 660 { 661 this.reconnectAttempts = reconnectAttempts; 662 } 663 664 public boolean getRedeliverUnspecified() 665 { 666 return redeliverUnspecified; 667 } 668 669 public void setRedeliverUnspecified(boolean redeliverUnspecified) 670 { 671 this.redeliverUnspecified = redeliverUnspecified; 672 } 673 } | Popular Tags |