KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > ejb > cmp3 > base > DataSourceConfig


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.ejb.cmp3.base;
23
24 import java.io.StringWriter JavaDoc;
25
26 /**
27  * Simplest of all possible holder objects for all of the data source
28  * info required by the Entity test environment. Use the constructor to
29  * simultaneously create the instance and set the fields.
30  * <p>
31  * At least one (transactional) data source must be specified and
32  * potentially a non-transactional if such a data source is appropriate
33  * (e.g. for non-transactional operations).
34  * <p>
35  * @see ContainerConfig
36  * @see EntityContainer
37  */

38 public class DataSourceConfig {
39
40     /** Identifier to name this data source (must be Container-unique) */
41     public String JavaDoc dsName;
42
43     /** JNDI name that data source should be bound to */
44     public String JavaDoc jndiName;
45
46     /** URL that is passed to the driver to determine db */
47     public String JavaDoc url;
48
49     /** Driver class name string */
50     public String JavaDoc driver;
51
52     /** User name to use when connecting to the db */
53     public String JavaDoc user;
54
55     /** Password to use when connecting to the db */
56     public String JavaDoc password;
57     
58     /**
59      * Constructor used to create a DataSourceConfig
60      *
61      * @param dsName Data source identifier
62      * @param jndiName Name that the data source should be bound to in JNDI
63      * @param url Passed to the driver to determine db
64      * @param driver The class name for the db driver
65      * @param user User name to use when connecting to the db
66      * @param password Password to use when connecting to the db
67      */

68     public DataSourceConfig(String JavaDoc dsName, String JavaDoc jndiName, String JavaDoc url, String JavaDoc driver, String JavaDoc user, String JavaDoc password) {
69         this.dsName = dsName;
70         this.jndiName = jndiName;
71         this.url = url;
72         this.driver = driver;
73         this.user = user;
74         this.password = password;
75     }
76
77     /**
78      * INTERNAL:
79      */

80     public String JavaDoc toString() {
81         StringWriter JavaDoc writer = new StringWriter JavaDoc();
82         if(dsName != null) {
83             writer.write("dsName = " + dsName + '\n');
84         }
85         if(jndiName != null) {
86             writer.write("jndiName = " + jndiName + '\n');
87         }
88         if(url != null) {
89             writer.write("url = " + url + '\n');
90         }
91         if(driver != null) {
92             writer.write("driver = " + driver + '\n');
93         }
94         if(user != null) {
95             writer.write("user = " + user + '\n');
96         }
97         return writer.toString();
98     }
99 }
100
Popular Tags