User: chirino 
  Date: 02/01/07 12:54:19

  Modified:    src/main/org/jboss/ejb/plugins/jms DLQHandler.java
                        JMSContainerInvoker.java
  Log:
  Merged in changes by Andreas Mueller for better integration with SwiftMQ
  
  Revision  Changes    Path
  1.7       +43 -22    jboss/src/main/org/jboss/ejb/plugins/jms/DLQHandler.java
  
  Index: DLQHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/jms/DLQHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DLQHandler.java   2002/01/05 12:08:52     1.6
  +++ DLQHandler.java   2002/01/07 20:54:19     1.7
  @@ -26,8 +26,8 @@
   import org.jboss.logging.Logger;
   import org.jboss.deployment.DeploymentException;
   import org.jboss.metadata.MetaData;
  +import org.jboss.jms.jndi.JMSProviderAdapter;
   
  -
   /**
    * Places redeliveded messages on a Dead Letter Queue.
    *
  @@ -52,8 +52,9 @@
    * Created: Thu Aug 23 21:17:26 2001
    *
    * @author
  - * @version $Revision: 1.6 $ $Date: 2002/01/05 12:08:52 $
  + * @version $Revision: 1.7 $ $Date: 2002/01/07 20:54:19 $
    */
  +
   public class DLQHandler
   {
      /** Class logger. */
  @@ -101,29 +102,36 @@
      private QueueConnection connection;
      private Queue dlq;
      private Hashtable resentBuffer = new Hashtable();
  -   
  +   private JMSProviderAdapter providerAdapter = null;
  +
      public DLQHandler()
      {
         
      }
  -   
  -   
  -   //--- Service
  +
  +  // Fix: set the JMS provider adapter to handle DLQ stuff
  +  public DLQHandler(JMSProviderAdapter providerAdapter)
  +  {
  +    this.providerAdapter = providerAdapter;
  +  }
  +
  +  //--- Service
      /**
       * Initalize the service.
       *
       * @throws Exception    Service failed to initalize.
       */
  -   void create() throws Exception {
  -
  -      Context ctx = new InitialContext();
  +   void create() throws Exception
  +   {
  +      // Fix: use provider adapter eventually
  +      Context ctx = providerAdapter != null? providerAdapter.getInitialContext(): 
new InitialContext();
         QueueConnectionFactory factory = (QueueConnectionFactory)
         ctx.lookup(FACTORY_JNDI);
         
         connection = factory.createQueueConnection();
         dlq = (Queue)ctx.lookup(destinationJNDI);
         if (log.isDebugEnabled())
  -         log.debug("Created Dead Letter Queue connection " + dlq);
  +      log.debug("Created Dead Letter Queue connection " + dlq);
      }
      
      /**
  @@ -152,8 +160,10 @@
         try
         {
            connection.stop();
  -      }catch(Exception ex)
  -      {}
  +      }
  +      catch(Exception ex)
  +      {
  +      }
      }
      
      //--- Logic
  @@ -188,13 +198,12 @@
         catch(JMSException ex)
         {
            // If we can't send it ahead, we do not dare to just drop it...or?
  -         log.error("Could not send message to Dead Letter Queue " + ex,ex);
  +         log.error("Could not send message to Dead Letter Queue", ex);
            return false;
         }
         return false;
  -      
      }
  -   
  +
      //--- Private helper stuff
      /**
       * Increment the counter for the specific JMS message id.
  @@ -208,18 +217,17 @@
         if(!resentBuffer.containsKey(id))
         {
            if (debug)
  -            log.debug("Making new entry for id " + id);
  +         log.debug("Making new entry for id " + id);
            entry = new BufferEntry();
            entry.id = id;
            entry.count = 1;
            resentBuffer.put(id,entry);
  -      }
  -      else
  +      } else
         {
            entry = (BufferEntry)resentBuffer.get(id);
            entry.count++;
            if (debug)
  -            log.debug("Incremented old entry for id " + id + " count " + 
entry.count);
  +         log.debug("Incremented old entry for id " + id + " count " + entry.count);
         }
         return entry.count;
      }
  @@ -251,7 +259,7 @@
            ses = connection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
            sender = ses.createSender(dlq);
            if (log.isDebugEnabled())
  -            log.debug("Resending DLQ message to destination" + dlq);
  +         log.debug("Resending DLQ message to destination" + dlq);
            sender.send(msg,deliveryMode,priority,timeToLive);
         }
         finally
  @@ -265,6 +273,7 @@
            {
            }
         }
  +      
      }
      
      /**
  @@ -312,7 +321,6 @@
            String ttl = MetaData.getElementContent
            (MetaData.getUniqueChild(element, "TimeToLive"));
            timeToLive = Long.parseLong(ttl);
  -         // A timeToLive < 0 means the msg is unusable so use default instead
            if( timeToLive < 0 )
               timeToLive = Message.DEFAULT_TIME_TO_LIVE;
         }
  @@ -324,8 +332,9 @@
         {
            //Noop will take default value
         }
  +      
      }
  -
  +   
      public String toString()
      {
         StringBuffer buff = new StringBuffer();
  @@ -343,3 +352,15 @@
         String id;
      }
   } // DLQHandler
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  
  
  
  1.40      +285 -285  
jboss/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
  
  Index: JMSContainerInvoker.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- JMSContainerInvoker.java  2002/01/05 12:08:52     1.39
  +++ JMSContainerInvoker.java  2002/01/07 20:54:19     1.40
  @@ -1,17 +1,17 @@
   /*
  -* JBoss, the OpenSource J2EE webOS
  -*
  -* Distributable under LGPL license.
  -* See terms of license at gnu.org.
  -*/
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.ejb.plugins.jms;
   import java.lang.reflect.Method;
   import java.security.Principal;
   
   import java.util.Collection;
   import java.util.Hashtable;
  -
   import javax.ejb.EJBHome;
  +
   import javax.ejb.EJBMetaData;
   import javax.ejb.EJBObject;
   
  @@ -22,6 +22,7 @@
   import javax.management.ObjectName;
   import javax.naming.Context;
   import javax.naming.InitialContext;
  +
   import javax.naming.Name;
   import javax.naming.NamingException;
   
  @@ -47,131 +48,127 @@
   import org.w3c.dom.Element;
   import org.w3c.dom.Node;
   /**
  -* ContainerInvoker for JMS MessageDrivenBeans, based on JRMPContainerInvoker.
  -*
  -* @author    <a href="mailto:[EMAIL PROTECTED]";>Peter Antman</a> .
  -* @author    <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
  -* @author    <a href="mailto:[EMAIL PROTECTED]";>Sebastien Alborini
  -*      </a>
  -* @author    <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  -* @author    <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  -* @version   $Revision: 1.39 $
  -*/
  -
  + * ContainerInvoker for JMS MessageDrivenBeans, based on JRMPContainerInvoker.
  + *
  + * @author    <a href="mailto:[EMAIL PROTECTED]";>Peter Antman</a> .
  + * @author    <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
  + * @author    <a href="mailto:[EMAIL PROTECTED]";>Sebastien Alborini
  + *      </a>
  + * @author    <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  + * @author    <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  + * @version   $Revision: 1.40 $
  + */
   public class JMSContainerInvoker
  -implements ContainerInvoker, XmlLoadable
  +   implements ContainerInvoker, XmlLoadable
   {
      // Constants -----------------------------------------------------
      
      /**
  -   * {@link MessageListener#onMessage} reference.
  -   */
  -   /*
  -   * final
  -   */
  +    * {@link MessageListener#onMessage} reference.
  +    */
      protected static Method ON_MESSAGE;
      
      /**
  -   * Default destination type. Used when no message-driven-destination is given
  -   * in ejb-jar, and a lookup of destinationJNDI from jboss.xml is not
  -   * successfull. Default value: javax.jms.Topic.
  -   */
  +    * Default destination type. Used when no message-driven-destination is given
  +    * in ejb-jar, and a lookup of destinationJNDI from jboss.xml is not
  +    * successfull. Default value: javax.jms.Topic.
  +    */
      protected final static String DEFAULT_DESTINATION_TYPE = "javax.jms.Topic";
      
      // Attributes ----------------------------------------------------
      
      /**
  -   * Description of the Field
  -   */
  +    * Description of the Field
  +    */
      protected boolean optimize;
      // = false;
      /**
  -   * Maximu number provider is allowed to stuff into a session.
  -   */
  +    * Maximu number provider is allowed to stuff into a session.
  +    */
      protected int maxMessagesNr = 1;
      /**
  -   * Maximun pool size of server sessions.
  -   */
  +    * Maximun pool size of server sessions.
  +    */
      protected int maxPoolSize = 15;
      /**
  -   * Time to wait before retrying to reconnect a lost connection.
  -   */
  +    * Time to wait before retrying to reconnect a lost connection.
  +    */
      protected long reconnectInterval = 10000;
      /**
  -   * If Dead letter queue should be used or not.
  -   */
  +    * If Dead letter queue should be used or not.
  +    */
      protected boolean useDLQ = false;
      /**
  -   * JNDI name of the provider adapter.
  -   * @see org.jboss.jms.jndi.JMSProviderAdapter
  -   */
  +    * JNDI name of the provider adapter.
  +    * @see org.jboss.jms.jndi.JMSProviderAdapter
  +    */
      protected String providerAdapterJNDI;
      /**
  -   * JNDI name of the server session factory.
  -   * @see org.jboss.jms.asf.ServerSessionPoolFactory
  -   */
  +    * JNDI name of the server session factory.
  +    * @see org.jboss.jms.asf.ServerSessionPoolFactory
  +    */
      protected String serverSessionPoolFactoryJNDI;
      /**
  -   * JMS acknowledge mode, used when session is not XA.
  -   */
  +    * JMS acknowledge mode, used when session is not XA.
  +    */
      protected int acknowledgeMode;
      /**
  -   * escription of the Field
  -   */
  +    * escription of the Field
  +    */
      protected boolean isContainerManagedTx;
      /**
  -   * Description of the Field
  -   */
  +    * Description of the Field
  +    */
      protected boolean isNotSupportedTx;
      /**
  -   * The container.
  -   */
  +    * The container.
  +    */
      protected Container container;
      /**
  -   * The JMS connection.
  -   */
  +    * The JMS connection.
  +    */
      protected Connection connection;
      /**
  -   * TH JMS connection consumer.
  -   */
  +    * TH JMS connection consumer.
  +    */
      protected ConnectionConsumer connectionConsumer;
      /**
  -   * Description of the Field
  -   */
  +    * Description of the Field
  +    */
      protected TransactionManager tm;
      /**
  -   * Description of the Field
  -   */
  +    * Description of the Field
  +    */
      protected ServerSessionPool pool;
      /**
  -   * Description of the Field
  -   */
  +    * Description of the Field
  +    */
      protected ExceptionListenerImpl exListener;
      /**
  -   * Description of the Field
  -   */
  +    * Description of the Field
  +    */
      protected String beanName;
      /**
  -   * Dead letter queue handler.
  -   */
  +    * Dead letter queue handler.
  +    */
      protected DLQHandler dlqHandler;
      /**
  -   * DLQConfig element from MDBConfig element from jboss.xml.
  -   */
  +    * DLQConfig element from MDBConfig element from jboss.xml.
  +    */
      protected Element dlqConfig;
      
      /**
  -   * Instance logger.
  -   */
  +    * Instance logger.
  +    */
      private final Logger log = Logger.getLogger(this.getClass());
  -   
  +
      // ContainerService implementation -------------------------------
      
      /**
  -   * Set the container for which this is an invoker to.
  -   *
  -   * @param container  The container for which this is an invoker to.
  -   */
  +    * Set the container for which this is an invoker to.
  +    *
  +    * @param container  The container for which this is an invoker to.
  +    */
      public void setContainer(final Container container)
      {
         this.container = container;
  @@ -185,24 +182,24 @@
      // Public --------------------------------------------------------
      
      /**
  -   * Sets the Optimized attribute of the JMSContainerInvoker object
  -   *
  -   * @param optimize  The new Optimized value
  -   */
  +    * Sets the Optimized attribute of the JMSContainerInvoker object
  +    *
  +    * @param optimize  The new Optimized value
  +    */
      public void setOptimized(final boolean optimize)
      {
         if (log.isDebugEnabled())
  -         log.debug("Container Invoker optimize set to " + optimize);
  +      log.debug("Container Invoker optimize set to " + optimize);
         this.optimize = optimize;
      }
      
      // ContainerInvoker implementation
      
   /*
  -   * Gets the EJBHome attribute of the JMSContainerInvoker object
  -   *
  -   * @return   The EJBHome value
  -   */
  +    * Gets the EJBHome attribute of the JMSContainerInvoker object
  +    *
  +    * @return   The EJBHome value
  +    */
      public Object getEJBHome()
   
      {
  @@ -210,32 +207,32 @@
      }
      
      /**
  -   * Gets the EJBMetaData attribute of the JMSContainerInvoker object
  -   *
  -   * @return   The EJBMetaData value
  -   */
  +    * Gets the EJBMetaData attribute of the JMSContainerInvoker object
  +    *
  +    * @return   The EJBMetaData value
  +    */
      public EJBMetaData getEJBMetaData()
      {
         throw new Error("Not valid for MessageDriven beans");
      }
      
      /**
  -   * Gets the EntityCollection attribute of the JMSContainerInvoker object
  -   *
  -   * @param ids  Description of Parameter
  -   * @return     The EntityCollection value
  -   */
  +    * Gets the EntityCollection attribute of the JMSContainerInvoker object
  +    *
  +    * @param ids  Description of Parameter
  +    * @return     The EntityCollection value
  +    */
      public Collection getEntityCollection(Collection ids)
      {
         throw new Error("Not valid for MessageDriven beans");
      }
      
      /**
  -   * Gets the EntityEJBObject attribute of the JMSContainerInvoker object
  -   *
  -   * @param id  Description of Parameter
  -   * @return    The EntityEJBObject value
  -   */
  +    * Gets the EntityEJBObject attribute of the JMSContainerInvoker object
  +    *
  +    * @param id  Description of Parameter
  +    * @return    The EntityEJBObject value
  +    */
      public Object getEntityEJBObject(Object id)
   
      {
  @@ -243,12 +240,12 @@
      }
      
      /**
  -   * Gets the StatefulSessionEJBObject attribute of the JMSContainerInvoker
  -   * object
  -   *
  -   * @param id  Description of Parameter
  -   * @return    The StatefulSessionEJBObject value
  -   */
  +    * Gets the StatefulSessionEJBObject attribute of the JMSContainerInvoker
  +    * object
  +    *
  +    * @param id  Description of Parameter
  +    * @return    The StatefulSessionEJBObject value
  +    */
      public Object getStatefulSessionEJBObject(Object id)
   
      {
  @@ -257,11 +254,11 @@
      
      /**
   
  -   * Gets the StatelessSessionEJBObject attribute of the JMSContainerInvoker
  -   * object
  -   *
  -   * @return   The StatelessSessionEJBObject value
  -   */
  +    * Gets the StatelessSessionEJBObject attribute of the JMSContainerInvoker
  +    * object
  +    *
  +    * @return   The StatelessSessionEJBObject value
  +    */
      public Object getStatelessSessionEJBObject()
   
      {
  @@ -269,31 +266,31 @@
      }
      
      /**
  -   * Gets the Optimized attribute of the JMSContainerInvoker object
  -   *
  -   * @return   The Optimized value
  -   */
  +    * Gets the Optimized attribute of the JMSContainerInvoker object
  +    *
  +    * @return   The Optimized value
  +    */
      public boolean isOptimized()
      {
         if (log.isDebugEnabled())
  -         log.debug("Optimize in action: " + optimize);
  +      log.debug("Optimize in action: " + optimize);
         return optimize;
      }
      
      /**
  -   * Take down all fixtures.
  -   */
  +    * Take down all fixtures.
  +    */
      public void destroy()
      {
         if (log.isDebugEnabled())
  -         log.debug("Destroying JMSContainerInvoker for bean " + beanName);
  -
  +      log.debug("Destroying JMSContainerInvoker for bean " + beanName);
  +      
         // Take down DLQ
         if ( dlqHandler != null)
         {
            dlqHandler.destroy();
         }
  -
  +      
         // close the connection consumer
         try
         {
  @@ -306,7 +303,7 @@
         {
            log.error("Could not close consumer", e);
         }
  -
  +      
         // clear the server session pool (if it is clearable)
         try
         {
  @@ -320,7 +317,7 @@
         {
            log.error("Could not clear ServerSessionPool", e);
         }
  -
  +      
         // close the connection
         if (connection != null)
         {
  @@ -334,43 +331,46 @@
            }
         }
      }
  -
  +   
      /**
  -   * XmlLoadable implementation.
  -   *
  -   * FIXME - we ought to move all config into MDBConfig, but I do not
  -   * do that now due to backward compatibility.
  -   *
  -   * @param element                  Description of Parameter
  -   * @exception DeploymentException  Description of Exception
  -   */
  +    * XmlLoadable implementation.
  +    *
  +    * FIXME - we ought to move all config into MDBConfig, but I do not
  +    * do that now due to backward compatibility.
  +    *
  +    * @param element                  Description of Parameter
  +    * @exception DeploymentException  Description of Exception
  +    */
      public void importXml(Element element) throws DeploymentException
      {
         try
         {
            String maxMessages = MetaData.getElementContent
  -         (MetaData.getUniqueChild(element, "MaxMessages"));
  +            (MetaData.getUniqueChild(element, "MaxMessages"));
            maxMessagesNr = Integer.parseInt(maxMessages);
            
            String maxSize = MetaData.getElementContent
  -         (MetaData.getUniqueChild(element, "MaximumSize"));
  +            (MetaData.getUniqueChild(element, "MaximumSize"));
            maxPoolSize = Integer.parseInt(maxSize);
            
            Element mdbConfig = MetaData.getUniqueChild(element, "MDBConfig");
            
            String reconnect = MetaData.getElementContent
  -         (MetaData.getUniqueChild(mdbConfig, "ReconnectIntervalSec"));
  +            (MetaData.getUniqueChild(mdbConfig, "ReconnectIntervalSec"));
            reconnectInterval = Long.parseLong(reconnect)*1000;
            
            // Get Dead letter queue config - and save it for later use
            Element dlqEl = MetaData.getOptionalChild(mdbConfig, "DLQConfig");
  -         if (dlqEl != null) {
  +         if (dlqEl != null)
  +         {
               dlqConfig = (Element)((Node)dlqEl).cloneNode(true);
               useDLQ = true;
  -         } else {
  +         }
  +         else
  +         {
               useDLQ = false;
            }
  -      
  +         
         }
         catch (NumberFormatException e)
         {
  @@ -383,10 +383,10 @@
         
         // If these are not found we will get a DeploymentException, I hope
         providerAdapterJNDI = MetaData.getElementContent
  -      (MetaData.getUniqueChild(element, "JMSProviderAdapterJNDI"));
  +         (MetaData.getUniqueChild(element, "JMSProviderAdapterJNDI"));
         
         serverSessionPoolFactoryJNDI = MetaData.getElementContent
  -      (MetaData.getUniqueChild(element, "ServerSessionPoolFactoryJNDI"));
  +         (MetaData.getUniqueChild(element, "ServerSessionPoolFactoryJNDI"));
         
         // Check java:/ prefix
         if (!providerAdapterJNDI.startsWith("java:/"))
  @@ -398,23 +398,20 @@
         {
            serverSessionPoolFactoryJNDI = "java:/" + serverSessionPoolFactoryJNDI;
         }
  -
  -   
  -   
      }
  -   
  +
      /**
  -   * Initialize the container invoker. Sets up a connection, a server session
  -   * pool and a connection consumer for the configured destination.
  -   *
  -   * @throws Exception  Failed to initalize.
  -   */
  +    * Initialize the container invoker. Sets up a connection, a server session
  +    * pool and a connection consumer for the configured destination.
  +    *
  +    * @throws Exception  Failed to initalize.
  +    */
      public void create() throws Exception
   
      {
         boolean debug = log.isDebugEnabled();
         if (debug)
  -         log.debug("initializing");
  +      log.debug("initializing");
         
         // Set up Dead Letter Queue handler
         
  @@ -438,7 +435,7 @@
         
         // Queue or Topic - optional unfortunately
         String destinationType = config.getDestinationType();
  -
  +      
         // Bean Name
         beanName = config.getEjbName();
         
  @@ -458,12 +455,12 @@
         // Get the JMS provider
         JMSProviderAdapter adapter = getJMSProviderAdapter();
         if (debug)
  -         log.debug("provider adapter: " + adapter);
  +      log.debug("provider adapter: " + adapter);
         
         // Connect to the JNDI server and get a reference to root context
         Context context = adapter.getInitialContext();
         if (debug)
  -         log.debug("context: " + context);
  +      log.debug("context: " + context);
         
         // if we can't get the root context then exit with an exception
         if (context == null)
  @@ -473,9 +470,9 @@
         
         // Get the JNDI suffix of the destination
         String jndiSuffix = parseJndiSuffix(destinationJNDI,
  -         config.getEjbName());
  +      config.getEjbName());
         if (debug)
  -         log.debug("jndiSuffix: " + jndiSuffix);
  +      log.debug("jndiSuffix: " + jndiSuffix);
         
         // Unfortunately the destination is optional, so if we do not have one
         // here we have to look it up if we have a destinationJNDI, else give it
  @@ -489,7 +486,7 @@
         if (destinationType.equals("javax.jms.Topic"))
         {
            if (debug)
  -            log.debug("Got destination type Topic for " + config.getEjbName());
  +         log.debug("Got destination type Topic for " + config.getEjbName());
            
            // create a topic connection
            Object factory = context.lookup(adapter.getTopicFactoryRef());
  @@ -497,10 +494,16 @@
            (TopicConnection)ConnectionFactoryHelper.createTopicConnection
            (factory, user, password);
            connection = tConnection;
  -         
  +
  +        // Fix: ClientId must be set as the first method call after connection 
creation.
  +        // Fix: ClientId is necessary for durable subscriptions.
  +          String clientId = config.getClientId();
  +          if (clientId != null && clientId.length() > 0)
  +            connection.setClientID(clientId);
  +
  +
            // lookup or create the destination topic
  -         Topic topic =
  -         (Topic)createDestination(Topic.class,
  +         Topic topic = (Topic)createDestination(Topic.class,
               context,
               "topic/" + jndiSuffix,
               jndiSuffix);
  @@ -508,7 +511,7 @@
            // set up the server session pool
            pool = createSessionPool(tConnection,
               maxPoolSize,
  -            true, // tx   
  +            true, // tx
               acknowledgeMode ,
               new MessageListenerImpl(this));
            
  @@ -518,7 +521,7 @@
            {
               // Create non durable
               connectionConsumer =
  -            tConnection.createConnectionConsumer(topic,
  +               tConnection.createConnectionConsumer(topic,
                  messageSelector,
                  pool,
                  maxMessagesNr);
  @@ -526,25 +529,24 @@
            else
            {
               //Durable subscription
  -            String clientId = config.getClientId();
               String durableName =
               clientId != null ? clientId : config.getEjbName();
               
               connectionConsumer =
  -            tConnection.createDurableConnectionConsumer(topic,
  +               tConnection.createDurableConnectionConsumer(topic,
                  durableName,
                  messageSelector,
                  pool,
                  maxMessagesNr);
            }
  -
  +         
            if (debug)
  -            log.debug("Topic connectionConsumer set up");
  +         log.debug("Topic connectionConsumer set up");
         }
         else if (destinationType.equals("javax.jms.Queue"))
         {
            if (debug)
  -            log.debug("Got destination type Queue for " + config.getEjbName());
  +         log.debug("Got destination type Queue for " + config.getEjbName());
            
            // create a queue connection
            Object qFactory = context.lookup(adapter.getQueueFactoryRef());
  @@ -554,8 +556,7 @@
            connection = qConnection;
            
            // lookup or create the destination queue
  -         Queue queue =
  -         (Queue)createDestination(Queue.class,
  +         Queue queue = (Queue)createDestination(Queue.class,
               context,
               "queue/" + jndiSuffix,
               jndiSuffix);
  @@ -568,46 +569,46 @@
               acknowledgeMode,
               new MessageListenerImpl(this));
            if (debug)
  -            log.debug("server session pool: " + pool);
  -
  +         log.debug("server session pool: " + pool);
  +         
            // create the connection consumer
            connectionConsumer =
  -         qConnection.createConnectionConsumer(queue,
  +            qConnection.createConnectionConsumer(queue,
               messageSelector,
               pool,
               maxMessagesNr);
            if (debug)
  -            log.debug("connection consumer: " + connectionConsumer);
  +         log.debug("connection consumer: " + connectionConsumer);
         }
  -
  +      
         if (debug)
  -         log.debug("initialized with config " + toString());
  +      log.debug("initialized with config " + toString());
      }
  -
  +   
      /**
  -   * #Description of the Method
  -   *
  -   * @param id             Description of Parameter
  -   * @param m              Description of Parameter
  -   * @param args           Description of Parameter
  -   * @param tx             Description of Parameter
  -   * @param identity       Description of Parameter
  -   * @param credential     Description of Parameter
  -   * @return               Description of the Returned Value
  -   * @exception Exception  Description of Exception
  -   */
  +    * #Description of the Method
  +    *
  +    * @param id             Description of Parameter
  +    * @param m              Description of Parameter
  +    * @param args           Description of Parameter
  +    * @param tx             Description of Parameter
  +    * @param identity       Description of Parameter
  +    * @param credential     Description of Parameter
  +    * @return               Description of the Returned Value
  +    * @exception Exception  Description of Exception
  +    */
      public Object invoke(Object id,
         Method m,
         Object[] args,
         Transaction tx,
         Principal identity,
         Object credential)
  -   throws Exception
  +      throws Exception
      {
   
         Invocation mi =
         new Invocation(id, m, args, tx, identity, credential);
  -
  +      
         // Set the right context classloader
         ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(container.getClassLoader());
  @@ -623,26 +624,26 @@
      }
      
      /**
  -   * Start the connection.
  -   *
  -   * @exception Exception  Description of Exception
  -   */
  +    * Start the connection.
  +    *
  +    * @exception Exception  Description of Exception
  +    */
      public void start() throws Exception
      {
         if (log.isDebugEnabled())
  -         log.debug("Starting JMSContainerInvoker for bean " + beanName);
  +      log.debug("Starting JMSContainerInvoker for bean " + beanName);
         exListener = new ExceptionListenerImpl(this);
         connection.setExceptionListener(exListener);
         connection.start();
      }
  -
  +   
      /**
  -   * Stop the connection.
  -   */
  +    * Stop the connection.
  +    */
      public void stop()
      {
         if (log.isDebugEnabled())
  -         log.debug("Stopping JMSContainerInvoker for bean " + beanName);
  +      log.debug("Stopping JMSContainerInvoker for bean " + beanName);
         // Silence the exception listener
         if (exListener != null)
         {
  @@ -652,19 +653,19 @@
      }
      
      /**
  -   * Try to get a destination type by looking up the destination JNDI, or
  -   * provide a default if there is not destinationJNDI or if it is not possible
  -   * to lookup.
  -   *
  -   * @param ctx              The naming context to lookup destinations from.
  -   * @param destinationJNDI  The name to use when looking up destinations.
  -   * @return                 The destination type, either derived from
  -   *      destinationJDNI or DEFAULT_DESTINATION_TYPE
  -   */
  +    * Try to get a destination type by looking up the destination JNDI, or
  +    * provide a default if there is not destinationJNDI or if it is not possible
  +    * to lookup.
  +    *
  +    * @param ctx              The naming context to lookup destinations from.
  +    * @param destinationJNDI  The name to use when looking up destinations.
  +    * @return                 The destination type, either derived from
  +    *      destinationJDNI or DEFAULT_DESTINATION_TYPE
  +    */
      protected String getDestinationType(Context ctx, String destinationJNDI)
      {
         String destType = null;
  -
  +      
         if (destinationJNDI != null)
         {
            try
  @@ -681,10 +682,9 @@
            }
            catch (NamingException ex)
            {
  -            if (log.isDebugEnabled())
  -               log.debug("Could not do heristic lookup of destination " + ex, ex);
  +            log.debug("Could not do heristic lookup of destination ", ex);
            }
  -
  +         
         }
         if (destType == null)
         {
  @@ -695,19 +695,19 @@
      }
      
      /**
  -   * Return the JMSProviderAdapter that should be used.
  -   *
  -   * @return                     The JMSProviderAdapter to use.
  -   * @exception NamingException  Description of Exception
  -   */
  +    * Return the JMSProviderAdapter that should be used.
  +    *
  +    * @return                     The JMSProviderAdapter to use.
  +    * @exception NamingException  Description of Exception
  +    */
      protected JMSProviderAdapter getJMSProviderAdapter()
  -   throws NamingException
  +      throws NamingException
      {
         Context context = new InitialContext();
         try
         {
            if (log.isDebugEnabled())
  -            log.debug("looking up provider adapter: " + providerAdapterJNDI);
  +         log.debug("looking up provider adapter: " + providerAdapterJNDI);
            return (JMSProviderAdapter)context.lookup(providerAdapterJNDI);
         }
         finally
  @@ -717,25 +717,25 @@
      }
      
      /**
  -   * Create and or lookup a JMS destination.
  -   *
  -   * @param type                       Either javax.jms.Queue or
  -   *      javax.jms.Topic.
  -   * @param ctx                        The naming context to lookup
  -   *      destinations from.
  -   * @param jndiName                   The name to use when looking up
  -   *      destinations.
  -   * @param jndiSuffix                 The name to use when creating
  -   *      destinations.
  -   * @return                           The destination.
  -   * @throws IllegalArgumentException  Type is not Queue or Topic.
  -   * @exception Exception              Description of Exception
  -   */
  +    * Create and or lookup a JMS destination.
  +    *
  +    * @param type                       Either javax.jms.Queue or
  +    *      javax.jms.Topic.
  +    * @param ctx                        The naming context to lookup
  +    *      destinations from.
  +    * @param jndiName                   The name to use when looking up
  +    *      destinations.
  +    * @param jndiSuffix                 The name to use when creating
  +    *      destinations.
  +    * @return                           The destination.
  +    * @throws IllegalArgumentException  Type is not Queue or Topic.
  +    * @exception Exception              Description of Exception
  +    */
      protected Destination createDestination(final Class type,
         final Context ctx,
         final String jndiName,
         final String jndiSuffix)
  -   throws Exception
  +      throws Exception
      {
         try
         {
  @@ -769,12 +769,12 @@
               throw new IllegalArgumentException
               ("expected javax.jms.Queue or javax.jms.Topic: " + type);
            }
  -         
  +
            // invoke the server to create the destination
            server.invoke(new ObjectName("jboss.mq", "service", "Server"),
               methodName,
  -            new Object[]{jndiSuffix},
  -            new String[]{"java.lang.String"});
  +            new Object[] {jndiSuffix},
  +            new String[] {"java.lang.String"});
            
            // try to look it up again
            return (Destination)ctx.lookup(jndiName);
  @@ -782,24 +782,24 @@
      }
      
      /**
  -   * Create a server session pool for the given connection.
  -   *
  -   * @param connection           The connection to use.
  -   * @param maxSession           The maximum number of sessions.
  -   * @param isTransacted         True if the sessions are transacted.
  -   * @param ack                  The session acknowledgement mode.
  -   * @param listener             The message listener.
  -   * @return                     A server session pool.
  -   * @throws JMSException
  -   * @exception NamingException  Description of Exception
  -   */
  +    * Create a server session pool for the given connection.
  +    *
  +    * @param connection           The connection to use.
  +    * @param maxSession           The maximum number of sessions.
  +    * @param isTransacted         True if the sessions are transacted.
  +    * @param ack                  The session acknowledgement mode.
  +    * @param listener             The message listener.
  +    * @return                     A server session pool.
  +    * @throws JMSException
  +    * @exception NamingException  Description of Exception
  +    */
      protected ServerSessionPool
  -   createSessionPool(final Connection connection,
  +      createSessionPool(final Connection connection,
         final int maxSession,
         final boolean isTransacted,
         final int ack,
         final MessageListener listener)
  -   throws NamingException, JMSException
  +      throws NamingException, JMSException
      {
         ServerSessionPool pool;
         Context context = new InitialContext();
  @@ -808,8 +808,8 @@
         {
            // first lookup the factory
            if (log.isDebugEnabled())
  -            log.debug("looking up session pool factory: " +
  -               serverSessionPoolFactoryJNDI);
  +         log.debug("looking up session pool factory: " +
  +         serverSessionPoolFactoryJNDI);
            ServerSessionPoolFactory factory = (ServerSessionPoolFactory)
            context.lookup(serverSessionPoolFactoryJNDI);
            
  @@ -826,9 +826,9 @@
      }
      
      /**
  -   * Stop done from inside, we should not stop the exceptionListener in inner
  -   * stop.
  -   */
  +    * Stop done from inside, we should not stop the exceptionListener in inner
  +    * stop.
  +    */
      protected void innerStop()
      {
         try
  @@ -860,12 +860,12 @@
      }
      
      /**
  -   * Parse the JNDI suffix from the given JNDI name.
  -   *
  -   * @param jndiname       The JNDI name used to lookup the destination.
  -   * @param defautSuffix   Description of Parameter
  -   * @return               The parsed suffix or the defaultSuffix
  -   */
  +    * Parse the JNDI suffix from the given JNDI name.
  +    *
  +    * @param jndiname       The JNDI name used to lookup the destination.
  +    * @param defautSuffix   Description of Parameter
  +    * @return               The parsed suffix or the defaultSuffix
  +    */
      protected String parseJndiSuffix(final String jndiname,
         final String defautSuffix)
      {
  @@ -903,23 +903,23 @@
      // Inner classes -------------------------------------------------
      
      /**
  -   * An implementation of MessageListener that passes messages on to the
  -   * container invoker.
  -   */
  +    * An implementation of MessageListener that passes messages on to the
  +    * container invoker.
  +    */
      class MessageListenerImpl
  -   implements MessageListener
  +      implements MessageListener
      {
         /**
  -      * The container invoker.
  -      */
  +       * The container invoker.
  +       */
         JMSContainerInvoker invoker;
         // = null;
         
         /**
  -      * Construct a <tt>MessageListenerImpl</tt> .
  -      *
  -      * @param invoker  The container invoker. Must not be null.
  -      */
  +       * Construct a <tt>MessageListenerImpl</tt> .
  +       *
  +       * @param invoker  The container invoker. Must not be null.
  +       */
         MessageListenerImpl(final JMSContainerInvoker invoker)
         {
            // assert invoker != null;
  @@ -928,10 +928,10 @@
         }
         
         /**
  -      * Process a message.
  -      *
  -      * @param message  The message to process.
  -      */
  +       * Process a message.
  +       *
  +       * @param message  The message to process.
  +       */
         public void onMessage(final Message message)
         {
            // assert message != null;
  @@ -951,7 +951,7 @@
               // what ?
               id = "JMSContainerInvoker";
            }
  -         
  +
            // Invoke, shuld we catch any Exceptions??
            try
            {
  @@ -976,7 +976,7 @@
                  null,
                  // Principal
                  null);
  -            // Cred
  +               // Cred
            }
            catch (Exception e)
            {
  @@ -986,10 +986,10 @@
      }
      
      /**
  -   * ExceptionListener for failover handling.
  -   */
  +    * ExceptionListener for failover handling.
  +    */
      class ExceptionListenerImpl
  -   implements ExceptionListener
  +      implements ExceptionListener
      {
         JMSContainerInvoker invoker;
         // = null;
  @@ -1003,10 +1003,10 @@
         }
         
         /**
  -      * #Description of the Method
  -      *
  -      * @param ex  Description of Parameter
  -      */
  +       * #Description of the Method
  +       *
  +       * @param ex  Description of Parameter
  +       */
         public void onException(JMSException ex)
         {
            currentThread = Thread.currentThread();
  @@ -1043,11 +1043,11 @@
            }
            currentThread = null;
         }
  -      
  +
         void stop()
         {
            log.debug("stop requested");
  -
  +         
            notStoped = false;
            if (currentThread != null)
            {
  @@ -1058,8 +1058,8 @@
      }
      
      /**
  -   * Return a string representation of the current config state.
  -   */
  +    * Return a string representation of the current config state.
  +    */
      public String toString()
      {
         StringBuffer buff = new StringBuffer();
  @@ -1081,8 +1081,8 @@
      }
      
      /**
  -   * Initialize the ON_MESSAGE reference.
  -   */
  +    * Initialize the ON_MESSAGE reference.
  +    */
      static
      {
         try
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to