Home » xml-commons-external-1.4.01-src » javax » xml » messaging » [javadoc | source]

    1   /*
    2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    3    *
    4    * Copyright 2000-2007 Sun Microsystems, Inc. All rights reserved. 
    5    *
    6    * The contents of this file are subject to the terms of either the GNU
    7    * General Public License Version 2 only ("GPL") or the Common Development
    8    * and Distribution License ("CDDL") (collectively, the "License").  You may
    9    * not use this file except in compliance with the License.  You can obtain
   10    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   11    * or mq/legal/LICENSE.txt.  See the License for the specific language
   12    * governing permissions and limitations under the License.
   13    * 
   14    * When distributing the software, include this License Header Notice in each
   15    * file and include the License file at mq/legal/LICENSE.txt.  Sun designates
   16    * this particular file as subject to the "Classpath" exception as provided by
   17    * Sun in the GPL Version 2 section of the License file that accompanied this
   18    * code.  If applicable, add the following below the License Header, with the
   19    * fields enclosed by brackets [] replaced by your own identifying information:
   20    * "Portions Copyrighted [year] [name of copyright owner]"
   21    * 
   22    * Contributor(s):
   23    * 
   24    * If you wish your version of this file to be governed by only the CDDL or
   25    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   26    * elects to include this software in this distribution under the [CDDL or GPL
   27    * Version 2] license."  If you don't indicate a single choice of license, a
   28    * recipient has the option to distribute your version of this file under
   29    * either the CDDL, the GPL Version 2 or  to extend the choice of license to
   30    * its licensees as provided above.  However, if you add GPL Version 2 code
   31    * and therefore, elected the GPL Version 2 license, then the option applies
   32    * only if the new code is made subject to such option by the copyright holder. 
   33    */
   34   
   35   /*
   36    * @(#)ProviderConnectionFactory.java	1.5 07/02/07
   37    */ 
   38   
   39   package javax.xml.messaging;
   40   
   41   import javax.xml.soap;
   42   
   43   /**
   44    * A factory for creating connections to a particular messaging provider.
   45    * A <code>ProviderConnectionFactory</code> object can be obtained in two
   46    * different ways.
   47    * <ul>
   48    * <li>Call the <code>ProviderConnectionFactory.newInstance</code>
   49    * method to get an instance of the default <code>ProviderConnectionFactory</code>
   50    * object.<br>
   51    *  This instance can be used to create a <code>ProviderConnection</code>
   52    * object that connects to the default provider implementation.
   53    * <PRE>
   54    *      ProviderConnectionFactory pcf = ProviderConnectionFactory.newInstance();
   55    *      ProviderConnection con = pcf.createConnection();
   56    * </PRE>
   57    * <P>
   58    * <li>Retrieve a <code>ProviderConnectionFactory</code> object
   59    * that has been registered with a naming service based on Java Naming and 
   60    * Directory Interface<sup><font size=-2>TM</font></sup> (JNDI) technology.<br>
   61    * In this case, the <code>ProviderConnectionFactory</code> object is an 
   62    * administered object that was created by a container (a servlet or Enterprise
   63    * JavaBeans<sup><font size=-2>TM</font></sup> container). The
   64    * <code>ProviderConnectionFactory</code> object was configured in an implementation-
   65    * specific way, and the connections it creates will be to the specified
   66    * messaging provider. <br>
   67    * <P>
   68    * Registering a <code>ProviderConnectionFactory</code> object with a JNDI naming service
   69    * associates it with a logical name. When an application wants to establish a
   70    * connection with the provider associated with that
   71    * <code>ProviderConnectionFactory</code> object, it does a lookup, providing the
   72    * logical name.  The application can then use the 
   73    * <code>ProviderConnectionFactory</code>
   74    * object that is returned to create a connection to the messaging provider.
   75    * The first two lines of the  following code fragment use JNDI methods to 
   76    * retrieve a <code>ProviderConnectionFactory</code> object. The third line uses the
   77    * returned object to create a connection to the JAXM provider that was 
   78    * registered with "ProviderXYZ" as its logical name.
   79    * <PRE>
   80    *      Context ctx = new InitialContext();
   81    *      ProviderConnectionFactory pcf = (ProviderConnectionFactory)ctx.lookup(
   82    *                                                                 "ProviderXYZ");
   83    *      ProviderConnection con = pcf.createConnection();
   84    * </PRE>
   85    * </ul>
   86    */
   87   public abstract class ProviderConnectionFactory {
   88       /**
   89        * Creates a <code>ProviderConnection</code> object to the messaging provider that
   90        * is associated with this <code>ProviderConnectionFactory</code>
   91        * object. 
   92        *
   93        * @return a <code>ProviderConnection</code> object that represents 
   94        *         a connection to the provider associated with this 
   95        *         <code>ProviderConnectionFactory</code> object
   96        * @exception JAXMException if there is an error in creating the
   97        *            connection
   98        */
   99       public abstract ProviderConnection createConnection() 
  100           throws JAXMException;
  101   
  102       static private final String PCF_PROPERTY
  103           = "javax.xml.messaging.ProviderConnectionFactory";
  104   
  105       static private final String DEFAULT_PCF 
  106           = "com.sun.xml.messaging.jaxm.client.remote.ProviderConnectionFactoryImpl";
  107   
  108       /**
  109        * Creates a default <code>ProviderConnectionFactory</code> object. 
  110        *
  111        * @return a new instance of a <code>ProviderConnectionFactory</code>
  112        *
  113        * @exception JAXMException if there was an error creating the
  114        *            default <code>ProviderConnectionFactory</code>
  115        */
  116       public static ProviderConnectionFactory newInstance() 
  117           throws JAXMException
  118       {
  119           //try {
  120   	    return (ProviderConnectionFactory)
  121                   FactoryFinder.find(PCF_PROPERTY,
  122                                      DEFAULT_PCF);
  123           //} catch (Exception ex) {
  124               //throw new JAXMException("Unable to create "+
  125                                       //"ProviderConnectionFactory: "
  126                                       //+ex.getMessage());
  127           //}
  128       }
  129   }

Home » xml-commons-external-1.4.01-src » javax » xml » messaging » [javadoc | source]