Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » mq » [javadoc | source]
    1   /*
    2   * JBoss, Home of Professional Open Source
    3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
    4   * by the @authors tag. See the copyright.txt in the distribution for a
    5   * full listing of individual contributors.
    6   *
    7   * This is free software; you can redistribute it and/or modify it
    8   * under the terms of the GNU Lesser General Public License as
    9   * published by the Free Software Foundation; either version 2.1 of
   10   * the License, or (at your option) any later version.
   11   *
   12   * This software is distributed in the hope that it will be useful,
   13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   15   * Lesser General Public License for more details.
   16   *
   17   * You should have received a copy of the GNU Lesser General Public
   18   * License along with this software; if not, write to the Free
   19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   21   */
   22   package org.jboss.mq;
   23   
   24   import java.io.Serializable;
   25   import java.util.Properties;
   26   
   27   import javax.jms.JMSException;
   28   import javax.jms.XAConnection;
   29   import javax.jms.XAConnectionFactory;
   30   import javax.jms.XAQueueConnection;
   31   import javax.jms.XAQueueConnectionFactory;
   32   import javax.jms.XATopicConnection;
   33   import javax.jms.XATopicConnectionFactory;
   34   import javax.naming.NamingException;
   35   import javax.naming.Reference;
   36   
   37   /**
   38    * This class implements <code>javax.jms.XATopicConnectionFactory</code> and
   39    * <code>javax.jms.XAQueueConnectionFactory</code>.
   40    * 
   41    * @author Hiram Chirino (Cojonudo14@hotmail.com)
   42    * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
   43    * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
   44    * @version <tt>$Revision: 37459 $</tt>
   45    */
   46   public class SpyXAConnectionFactory extends SpyConnectionFactory
   47      implements Serializable, XAConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory
   48   {
   49      // Constants -----------------------------------------------------
   50   
   51      /** The serialVersionUID */
   52      static final long serialVersionUID = -3869656253676593051L;
   53      
   54      // Attributes ----------------------------------------------------
   55      
   56      // Static --------------------------------------------------------
   57      
   58      // Constructors --------------------------------------------------
   59   
   60      /**
   61       * Create a new SpyXAConnectionFactory
   62       *
   63       * @param factory the generic connection factory
   64       */
   65      public SpyXAConnectionFactory(GenericConnectionFactory factory)
   66      {
   67         super(factory);
   68      }
   69   
   70      /**
   71       * Create a new SpyXAConnectionFactory
   72       *
   73       * @param config the configuration
   74       */
   75      public SpyXAConnectionFactory(Properties config)
   76      {
   77         super(config);
   78      }
   79      
   80      // Public --------------------------------------------------------
   81      
   82      // XAConnectionFactory implementation ----------------------------
   83   
   84      public XAConnection createXAConnection() throws JMSException
   85      {
   86         try
   87         {
   88            return new SpyXAConnection(factory);
   89         }
   90         catch (JMSException e)
   91         {
   92            throw e;
   93         }
   94         catch (Exception e)
   95         {
   96            throw new SpyJMSException("Failed to create XAConnection", e);
   97         }
   98      }
   99   
  100      public XAConnection createXAConnection(String userName, String password) throws JMSException
  101      {
  102         try
  103         {
  104            if (userName == null)
  105               throw new SpyJMSException("Username is null");
  106            if (password == null)
  107               throw new SpyJMSException("Password is null");
  108   
  109            return new SpyXAConnection(userName, password, factory);
  110         }
  111         catch (JMSException e)
  112         {
  113            throw e;
  114         }
  115         catch (Exception e)
  116         {
  117            throw new SpyJMSException("Failed to create XAConnection", e);
  118         }
  119      }
  120      
  121      // XAQueueConnectionFactory implementation -----------------------
  122   
  123      public XAQueueConnection createXAQueueConnection() throws JMSException
  124      {
  125         return (XAQueueConnection) createXAConnection();
  126      }
  127   
  128      public XAQueueConnection createXAQueueConnection(String userName, String password) throws JMSException
  129      {
  130         return (XAQueueConnection) createXAConnection(userName, password);
  131      }
  132      
  133      // XATopicConnectionFactory implementation -----------------------
  134   
  135      public XATopicConnection createXATopicConnection() throws JMSException
  136      {
  137         return (XATopicConnection) createXAConnection();
  138      }
  139   
  140      public XATopicConnection createXATopicConnection(String userName, String password) throws JMSException
  141      {
  142         return (XATopicConnection) createXAConnection(userName, password);
  143      }
  144      
  145      // Referenceable implementation ----------------------------------
  146   
  147      public Reference getReference() throws NamingException
  148      {
  149   
  150         return new Reference("org.jboss.mq.SpyXAConnectionFactory", new org.jboss.mq.referenceable.ObjectRefAddr("DCF",
  151               factory),
  152               "org.jboss.mq.referenceable.SpyConnectionFactoryObjectFactory", null);
  153      }
  154      
  155      // Package protected ---------------------------------------------
  156      
  157      // Protected -----------------------------------------------------
  158      
  159      // Private -------------------------------------------------------
  160      
  161      // Inner classes -------------------------------------------------
  162   }

Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » mq » [javadoc | source]