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 * @(#)ConnectionFactory.java 1.13 07/02/07
37 */
38
39 package javax.jms;
40
41 /** A <CODE>ConnectionFactory</CODE> object encapsulates a set of connection
42 * configuration
43 * parameters that has been defined by an administrator. A client uses
44 * it to create a connection with a JMS provider.
45 *
46 * <P>A <CODE>ConnectionFactory</CODE> object is a JMS administered object and
47 * supports concurrent use.
48 *
49 * <P>JMS administered objects are objects containing configuration
50 * information that are created by an administrator and later used by
51 * JMS clients. They make it practical to administer the JMS API in the
52 * enterprise.
53 *
54 * <P>Although the interfaces for administered objects do not explicitly
55 * depend on the Java Naming and Directory Interface (JNDI) API, the JMS API
56 * establishes the convention that JMS clients find administered objects by
57 * looking them up in a JNDI namespace.
58 *
59 * <P>An administrator can place an administered object anywhere in a
60 * namespace. The JMS API does not define a naming policy.
61 *
62 * <P>It is expected that JMS providers will provide the tools an
63 * administrator needs to create and configure administered objects in a
64 * JNDI namespace. JMS provider implementations of administered objects
65 * should be both <CODE>javax.jndi.Referenceable</CODE> and
66 * <CODE>java.io.Serializable</CODE> so that they can be stored in all
67 * JNDI naming contexts. In addition, it is recommended that these
68 * implementations follow the JavaBeans<SUP><FONT SIZE="-2">TM</FONT></SUP>
69 * design patterns.
70 *
71 * <P>This strategy provides several benefits:
72 *
73 * <UL>
74 * <LI>It hides provider-specific details from JMS clients.
75 * <LI>It abstracts administrative information into objects in the Java
76 * programming language ("Java objects")
77 * that are easily organized and administered from a common
78 * management console.
79 * <LI>Since there will be JNDI providers for all popular naming
80 * services, this means that JMS providers can deliver one implementation
81 * of administered objects that will run everywhere.
82 * </UL>
83 *
84 * <P>An administered object should not hold on to any remote resources.
85 * Its lookup should not use remote resources other than those used by the
86 * JNDI API itself.
87 *
88 * <P>Clients should think of administered objects as local Java objects.
89 * Looking them up should not have any hidden side effects or use surprising
90 * amounts of local resources.
91 *
92 * @see javax.jms.Connection
93 * @see javax.jms.QueueConnectionFactory
94 * @see javax.jms.TopicConnectionFactory
95 */
96
97 public interface ConnectionFactory {
98 /** Creates a connection with the default user identity.
99 * The connection is created in stopped mode. No messages
100 * will be delivered until the <code>Connection.start</code> method
101 * is explicitly called.
102 *
103 * @return a newly created connection
104 *
105 * @exception JMSException if the JMS provider fails to create the
106 * connection due to some internal error.
107 * @exception JMSSecurityException if client authentication fails due to
108 * an invalid user name or password.
109 * @since 1.1
110 */
111
112 Connection
113 createConnection() throws JMSException;
114
115
116 /** Creates a connection with the specified user identity.
117 * The connection is created in stopped mode. No messages
118 * will be delivered until the <code>Connection.start</code> method
119 * is explicitly called.
120 *
121 * @param userName the caller's user name
122 * @param password the caller's password
123 *
124 * @return a newly created connection
125 *
126 * @exception JMSException if the JMS provider fails to create the
127 * connection due to some internal error.
128 * @exception JMSSecurityException if client authentication fails due to
129 * an invalid user name or password.
130 * @since 1.1
131 */
132
133 Connection
134 createConnection(String userName, String password)
135 throws JMSException;
136 }