User: pra     
  Date: 00/12/29 14:06:36

  Modified:    src/main/org/jboss/ejb/plugins/jms JMSContainerInvoker.java
  Log:
  Added support for user/pwd for MDB and for a clientId in jboss.xml 
(mdb-user,mdb-passwd,mdb-client-id) - now durable topic with Spyder should work - see 
jbosstest for examples
  
  Revision  Changes    Path
  1.4       +29 -8     
jboss/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
  
  Index: JMSContainerInvoker.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JMSContainerInvoker.java  2000/12/29 21:01:21     1.3
  +++ JMSContainerInvoker.java  2000/12/29 22:06:36     1.4
  @@ -59,7 +59,7 @@
    *      @author Rickard �berg ([EMAIL PROTECTED])
    *           @author <a href="mailto:[EMAIL PROTECTED]">Sebastien 
Alborini</a>
    *      @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
  - *      @version $Revision: 1.3 $
  + *      @version $Revision: 1.4 $
    */
   public class JMSContainerInvoker implements
   ContainerInvoker, XmlLoadable
  @@ -242,7 +242,8 @@
   
          // Get configuration data from jboss.xml
          String destinationJNDI = config.getDestinationJndiName();
  -
  +       String user = config.getUser();
  +       
   
          /*
        * Set upp JNDI
  @@ -269,14 +270,21 @@
          
          
          if (destinationType.equals("javax.jms.Topic")) {
  -        Logger.debug("Got destination type Topic");
  +        Logger.debug("Got destination type Topic for " + config.getEjbName());
           
           // All classes are different between topics and queues!!
           TopicConnectionFactory topicFactory = 
               (TopicConnectionFactory)context.lookup(adapter.getTopicFactoryName());
  -        TopicConnection topicConnection = topicFactory.createTopicConnection();
  -        // Test to set an identity
  -        
//topicConnection.setClientID(((MessageDrivenMetaData)container.getBeanMetaData()).getEjbName());
  +        // Do we have a user - this is messy code (should be done for queues to)
  +        TopicConnection topicConnection;
  +        if(user != null) {
  +            Logger.debug("Creating topic connection with user: " + user +
  +                         " passwd: " + config.getPasswd());
  +            topicConnection = topicFactory.createTopicConnection(user, 
config.getPasswd());
  +        }else {
  +            topicConnection = topicFactory.createTopicConnection();
  +        }
  +        
           // Lookup destination
           Topic topic = (Topic)context.lookup(destinationJNDI);
           
  @@ -287,8 +295,15 @@
               // Create non durable
            connectionConsumer = topicConnection.createConnectionConsumer(topic, 
messageSelector, pool, maxMessagesNr); 
           } else {
  +            // ClientId
  +            // Test to set an identity - have to be there for durable!
  +            String clientId = config.getClientId();
  +            //topicConnection.setClientID(clientId);
               // Create durable - FIXME durable name!!
  -            String durableName = config.getEjbName();
  +            //String durableName = config.getEjbName();
  +            String durableName = clientId != null ? 
  +                clientId:
  +                config.getEjbName();
               connectionConsumer = 
topicConnection.createDurableConnectionConsumer(topic, durableName,messageSelector, 
pool, maxMessagesNr);
           }
           // set global connection, so we have something to start() and close()
  @@ -300,7 +315,13 @@
           QueueConnectionFactory queueFactory = 
               (QueueConnectionFactory)context.lookup(adapter.getQueueFactoryName());
   
  -        QueueConnection queueConnection = queueFactory.createQueueConnection();
  +        // Do we have a user
  +        QueueConnection queueConnection;
  +        if (user != null) {
  +            queueConnection = 
queueFactory.createQueueConnection(user,config.getPasswd());
  +        } else {
  +            queueConnection = queueFactory.createQueueConnection();
  +        }
           // Test to set an identity
           
//topicConnection.setClientID(((MessageDrivenMetaData)container.getBeanMetaData()).getEjbName());
           // Lookup destination
  
  
  

Reply via email to