KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > repository > JdbcXAResource


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 in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
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 Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.repository;
24
25 import java.io.Serializable JavaDoc;
26 import java.util.*;
27 import com.sun.enterprise.util.Utility;
28 // IASRI 4660742 START
29
import java.util.logging.*;
30 import com.sun.logging.*;
31 // IASRI 4660742 END
32

33 /**
34  * Resource info for JDBC XA DataSources.
35  *
36  * @author Kenneth Saks
37  */

38 public class JdbcXAResource extends J2EEResourceBase implements Serializable JavaDoc {
39
40 // IASRI 4660742 START
41
private static Logger _logger=null;
42     static{
43        _logger=LogDomains.getLogger(LogDomains.ROOT_LOGGER);
44         }
45 // IASRI 4660742 END
46
private String JavaDoc classname_;
47     private String JavaDoc dbuser_;
48     private String JavaDoc dbpassword_;
49     
50     public JdbcXAResource(String JavaDoc name) {
51         super(name);
52     }
53
54     protected J2EEResource doClone(String JavaDoc name) {
55         JdbcXAResource clone = new JdbcXAResource(name);
56         clone.setClassname(getClassname());
57         clone.setDbuser(getDbuser());
58         clone.setDbpassword(getDbpassword());
59         return clone;
60     }
61
62     public int getType() {
63         return J2EEResource.JDBC_XA_RESOURCE;
64     }
65
66     public String JavaDoc getClassname() {
67         return classname_;
68     }
69
70     public void setClassname(String JavaDoc classname) {
71         classname_ = classname;
72     }
73
74     public String JavaDoc getDbuser() {
75         return dbuser_;
76     }
77
78     public void setDbuser(String JavaDoc dbuser) {
79         dbuser_ = dbuser;
80     }
81
82     public String JavaDoc getDbpassword() {
83         return dbpassword_;
84     }
85
86     public void setDbpassword(String JavaDoc dbpassword) {
87         dbpassword_ = dbpassword;
88     }
89
90     // start IASRI 4659935
91
// Moved this method to JdbcConnectionPool
92
/*
93     public Object createDataSource() throws J2EEResourceException {
94         Object dataSource = null;
95         try {
96             Class dataSourceClass = Class.forName(getClassname());
97             dataSource = dataSourceClass.newInstance();
98             for(Iterator iter = getProperties().iterator(); iter.hasNext(); ){
99                 ResourceProperty next = (ResourceProperty) iter.next();
100                 Utility.invokeSetMethod(dataSource, next.getName(),
101                                         next.getValue().toString());
102             }
103         } catch(Exception e) {
104 // IASRI 4660742 e.printStackTrace();
105 // START OF IASRI 4660742
106         _logger.log(Level.SEVERE,"enterprise.datasource_exception",e);
107 // END OF IASRI 4660742
108             throw new J2EEResourceException(e);
109         }
110         return dataSource;
111     }
112     */

113     // end IASRI 4659935
114

115     public String JavaDoc toString() {
116         String JavaDoc propsString = getPropsString();
117         return "< JDBC XA Resource : " + getName() +
118             " , " + getClassname() + " , " + getDbuser() +
119             " , " + getDbpassword() + " , " +
120             ((propsString.length() > 0) ?
121              propsString : "No properties") + " >";
122     }
123 }
124
Popular Tags