KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > serverresources > beans > WS70JdbcResourceBean


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * WS70JdbcResourceBean.java
22  */

23
24 package org.netbeans.modules.j2ee.sun.ws7.serverresources.beans;
25 import java.beans.Beans JavaDoc;
26 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.WS70JdbcResource;
27 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.WS70Resources;
28 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.PropertyElement;
29
30 import java.util.Vector JavaDoc;
31 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair;
32
33 /**
34  *
35  * @author Administrator
36  */

37 public class WS70JdbcResourceBean extends WS70BaseResourceBean implements java.io.Serializable JavaDoc{
38     private String JavaDoc dsClass;
39     private String JavaDoc minConnections;
40     private String JavaDoc maxConnections;
41     private String JavaDoc waitTimeout;
42     private String JavaDoc idleTimeout;
43     private String JavaDoc isolationLevel;
44     private String JavaDoc isolationLevelGuaranteed;
45     private String JavaDoc connectionValidation;
46     private String JavaDoc connectionValidationTablename;
47     private String JavaDoc failAllConnections;
48     /** Creates a new instance of WS70JdbcResourceBean */
49     public WS70JdbcResourceBean() {
50     }
51     public String JavaDoc getDsClass() {
52         return dsClass;
53     }
54     public void setDsClass(String JavaDoc value) {
55         String JavaDoc oldValue = dsClass;
56         this.dsClass = value;
57         initPropertyChangeSupport();
58         propertySupport.firePropertyChange ("dsClass", oldValue, dsClass);//NOI18N
59
}
60     public String JavaDoc getMinConnections() {
61         return minConnections;
62     }
63     public void setMinConnections(String JavaDoc value) {
64         String JavaDoc oldValue = minConnections;
65         this.minConnections = value;
66         initPropertyChangeSupport();
67         propertySupport.firePropertyChange ("minConnections", oldValue, minConnections);//NOI18N
68
}
69     public String JavaDoc getMaxConnections() {
70         return maxConnections;
71     }
72     public void setMaxConnections(String JavaDoc value) {
73         String JavaDoc oldValue = maxConnections;
74         this.maxConnections = value;
75         initPropertyChangeSupport();
76         propertySupport.firePropertyChange ("maxConnections", oldValue, maxConnections);//NOI18N
77
}
78     public String JavaDoc getIdleTimeout() {
79         return idleTimeout;
80     }
81     public void setIdleTimeout(String JavaDoc value) {
82         String JavaDoc oldValue = idleTimeout;
83         this.idleTimeout = value;
84         initPropertyChangeSupport();
85         propertySupport.firePropertyChange ("idleTimeout", oldValue, idleTimeout);//NOI18N
86
}
87     public String JavaDoc getWaitTimeout() {
88         return waitTimeout;
89     }
90     public void setWaitTimeout(String JavaDoc value) {
91         String JavaDoc oldValue = waitTimeout;
92         this.waitTimeout = value;
93         initPropertyChangeSupport();
94         propertySupport.firePropertyChange ("waitTimeout", oldValue, waitTimeout);//NOI18N
95
}
96     public String JavaDoc getIsolationLevel() {
97         return isolationLevel;
98     }
99     public void setIsolationLevel(String JavaDoc value) {
100         String JavaDoc oldValue = isolationLevel;
101         this.isolationLevel = value;
102         initPropertyChangeSupport();
103         propertySupport.firePropertyChange ("isolationLevel", oldValue, isolationLevel);//NOI18N
104
}
105     public String JavaDoc getIsolationLevelGuaranteed() {
106         return isolationLevelGuaranteed;
107     }
108     public void setIsolationLevelGuaranteed(String JavaDoc value) {
109         String JavaDoc oldValue = isolationLevelGuaranteed;
110         this.isolationLevelGuaranteed = value;
111         initPropertyChangeSupport();
112         propertySupport.firePropertyChange ("isolationLevelGuaranteed", oldValue, isolationLevelGuaranteed);//NOI18N
113
}
114     public String JavaDoc getConnectionValidation() {
115         return connectionValidation;
116     }
117     public void setConnectionValidation(String JavaDoc value) {
118         String JavaDoc oldValue = connectionValidation;
119         this.connectionValidation = value;
120         initPropertyChangeSupport();
121         propertySupport.firePropertyChange ("connectionValidation", oldValue, connectionValidation);//NOI18N
122
}
123     public String JavaDoc getConnectionValidationTablename() {
124         return connectionValidationTablename;
125     }
126     public void setConnectionValidationTablename(String JavaDoc value) {
127         String JavaDoc oldValue = connectionValidationTablename;
128         this.connectionValidationTablename = value;
129         initPropertyChangeSupport();
130         propertySupport.firePropertyChange ("connectionValidationTablename", oldValue, connectionValidationTablename);//NOI18N
131
}
132     public String JavaDoc getFailAllConnections() {
133         return failAllConnections;
134     }
135     public void setFailAllConnections(String JavaDoc value) {
136         String JavaDoc oldValue = failAllConnections;
137         this.failAllConnections = value;
138         initPropertyChangeSupport();
139         propertySupport.firePropertyChange ("failAllConnections", oldValue, failAllConnections);//NOI18N
140
}
141     public static WS70JdbcResourceBean createBean(WS70JdbcResource jdbcresource) {
142         WS70JdbcResourceBean bean = new WS70JdbcResourceBean();
143         //name attribute in bean is for studio display purpose.
144
//It is not part of the jdbc-resource dtd.
145
bean.setDsClass(jdbcresource.getDatasourceClass());
146         bean.setName(jdbcresource.getJndiName());
147         bean.setDescription(jdbcresource.getDescription());
148         bean.setJndiName(jdbcresource.getJndiName());
149         bean.setIsEnabled(jdbcresource.getEnabled());
150         bean.setMinConnections(jdbcresource.getMinConnections());
151         bean.setMaxConnections(jdbcresource.getMaxConnections());
152         bean.setWaitTimeout(jdbcresource.getWaitTimeout());
153         bean.setIdleTimeout(jdbcresource.getIdleTimeout());
154         bean.setIsolationLevel(jdbcresource.getIsolationLevel());
155         bean.setIsolationLevelGuaranteed(jdbcresource.getIsolationLevelGuaranteed());
156         bean.setConnectionValidation(jdbcresource.getConnectionValidation());
157         bean.setConnectionValidationTablename(jdbcresource.getConnectionValidationTableName());
158         bean.setFailAllConnections(jdbcresource.getFailAllConnections());
159         PropertyElement[] extraProperties = jdbcresource.getPropertyElement();
160         Vector JavaDoc vec = new Vector JavaDoc();
161         for (int i = 0; i < extraProperties.length; i++) {
162             NameValuePair pair = new NameValuePair();
163             pair.setParamName(extraProperties[i].getName());
164             pair.setParamValue(extraProperties[i].getValue());
165             vec.add(pair);
166         }
167         
168         if (vec != null && vec.size() > 0) {
169             NameValuePair[] props = new NameValuePair[vec.size()];
170             bean.setExtraParams((NameValuePair[])vec.toArray(props));
171         }
172         
173         return bean;
174     }
175     public WS70Resources getGraph(){
176         WS70Resources res = getResourceGraph();
177         WS70JdbcResource jdbcresource = res.newWS70JdbcResource();
178         jdbcresource.setDatasourceClass(getDsClass());
179         jdbcresource.setDescription(getDescription());
180         jdbcresource.setJndiName(getJndiName());
181         jdbcresource.setMinConnections(getMinConnections());
182         jdbcresource.setMaxConnections(getMaxConnections());
183         jdbcresource.setIdleTimeout(getIdleTimeout());
184         jdbcresource.setIsolationLevel(getIsolationLevel());
185         jdbcresource.setIsolationLevelGuaranteed(getIsolationLevelGuaranteed());
186         jdbcresource.setIdleTimeout(getIdleTimeout());
187         jdbcresource.setWaitTimeout(getWaitTimeout());
188         jdbcresource.setConnectionValidation(getConnectionValidation());
189         jdbcresource.setConnectionValidationTableName(getConnectionValidationTablename());
190         jdbcresource.setFailAllConnections(getFailAllConnections());
191         jdbcresource.setEnabled(getIsEnabled());
192         
193         res.addWS70JdbcResource(jdbcresource);
194         return res;
195     }
196     
197 }
198
Popular Tags