1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-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
9 * may 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 glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
12 * language 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 glassfish/bootstrap/legal/LICENSE.txt.
16 * Sun designates this particular file as subject to the "Classpath" exception
17 * as provided by Sun in the GPL Version 2 section of the License file that
18 * accompanied this code. If applicable, add the following below the License
19 * Header, with the fields enclosed by brackets [] replaced by your own
20 * identifying information: "Portions Copyrighted [year]
21 * [name of copyright owner]"
22 *
23 * Contributor(s):
24 *
25 * If you wish your version of this file to be governed by only the CDDL or
26 * only the GPL Version 2, indicate your decision by adding "[Contributor]
27 * elects to include this software in this distribution under the [CDDL or GPL
28 * Version 2] license." If you don't indicate a single choice of license, a
29 * recipient has the option to distribute your version of this file under
30 * either the CDDL, the GPL Version 2 or to extend the choice of license to
31 * its licensees as provided above. However, if you add GPL Version 2 code
32 * and therefore, elected the GPL Version 2 license, then the option applies
33 * only if the new code is made subject to such option by the copyright
34 * holder.
35 */
36
37 package javax.resource.cci;
38
39
40 import java.io.PrintWriter;
41 import javax.resource.ResourceException;
42 import javax.resource.NotSupportedException;
43
44
45 /** <code>ConnectionFactory</code> provides an interface for getting
46 * connection to an EIS instance. An implementation of ConnectionFactory
47 * interface is provided by a resource adapter.
48 *
49 * <p>Application code looks up a ConnectionFactory instance from JNDI
50 * namespace and uses it to get EIS connections.
51 *
52 * <p>An implementation class for ConnectionFactory is required to
53 * implement <code>java.io.Serializable</code> and
54 * <code>javax.resource.Referenceable</code>interfaces to support
55 * JNDI registration.
56 *
57 * @author Rahul Sharma
58 * @version 0.8
59 * @see javax.resource.cci.Connection
60 * @see javax.resource.Referenceable
61 **/
62 public interface ConnectionFactory
63 extends java.io.Serializable,
64 javax.resource.Referenceable {
65
66 /** Gets a connection to an EIS instance. This getConnection variant
67 * should be used when a component wants the container to manage EIS
68 * sign-on. This case is termed container-managed sign-on. The
69 * component does not pass any security information.
70 *
71 *
72 * @return Connection instance
73 * @throws ResourceException Failed to get a connection to
74 * the EIS instance. Examples of
75 * error cases are:
76 * <UL>
77 * <LI> Invalid configuration of ManagedConnectionFactory--
78 * example: invalid server name
79 * <LI> Application server-internal error--example:
80 * connection pool related error
81 * <LI> Communication error
82 * <LI> EIS-specific error--example: EIS not active
83 * <LI> Resource adapter-internal error
84 * <LI> Security related error; example: invalid user
85 * <LI> Failure to allocate system resources
86 * </UL>
87 **/
88 public
89 Connection getConnection() throws ResourceException;
90
91 /** Gets a connection to an EIS instance. A component should use
92 * the getConnection variant with javax.resource.cci.ConnectionSpec
93 * parameter, if it needs to pass any resource adapter specific
94 * security information and connection parameters. In the component-
95 * managed sign-on case, an application component passes security
96 * information (example: username, password) through the
97 * ConnectionSpec instance.
98 *
99 * <p>It is important to note that the properties passed through
100 * the getConnection method should be client-specific (example:
101 * username, password, language) and not related to the
102 * configuration of a target EIS instance (example: port number,
103 * server name). The ManagedConnectionFactory instance is configured
104 * with complete set of properties required for the creation of a
105 * connection to an EIS instance.
106 *
107 * @param properties Connection parameters and security
108 * information specified as
109 * ConnectionSpec instance
110 * @return Connection instance
111 *
112 * @throws ResourceException Failed to get a connection to
113 * the EIS instance. Examples of
114 * error cases are:
115 * <UL>
116 * <LI> Invalid specification of input parameters
117 * <LI> Invalid configuration of ManagedConnectionFactory--
118 * example: invalid server name
119 * <LI> Application server-internal error--example:
120 * connection pool related error
121 * <LI> Communication error
122 * <LI> EIS-specific error--example: EIS not active
123 * <LI> Resource adapter-internal error
124 * <LI> Security related error; example: invalid user
125 * <LI> Failure to allocate system resources
126 * </UL>
127 * @see javax.resource.cci.ConnectionSpec
128 **/
129 public
130 Connection getConnection(ConnectionSpec properties)
131 throws ResourceException;
132
133 /** Gets a RecordFactory instance. The RecordFactory is used for
134 * the creation of generic Record instances.
135 *
136 * @return RecordFactory RecordFactory instance
137 *
138 * @throws ResourceException Failed to create a RecordFactory
139 * @throws NotSupportedException Operation not supported
140 **/
141 public
142 RecordFactory getRecordFactory() throws ResourceException;
143
144 /** Gets metadata for the Resource Adapter. Note that the metadata
145 * information is about the ResourceAdapter and not the EIS instance.
146 * An invocation of this method does not require that an active
147 * connection to an EIS instance should have been established.
148 *
149 * @return ResourceAdapterMetaData instance
150 * @throws ResourceException Failed to get metadata information
151 * about the resource adapter
152 **/
153 public
154 ResourceAdapterMetaData getMetaData() throws ResourceException;
155
156 }