KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > sunresources > beans > ConnPoolBean


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  * ConnPoolBean.java
21  *
22  * Created on September 12, 2003, 4:18 PM
23  */

24
25 package org.netbeans.modules.j2ee.sun.ide.sunresources.beans;
26
27 import java.util.Vector JavaDoc;
28
29 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair;
30 import org.netbeans.modules.j2ee.sun.share.serverresources.JdbcCP;
31 import org.netbeans.modules.j2ee.sun.dd.api.DDProvider;
32 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.*;
33
34 import org.netbeans.modules.j2ee.sun.ide.editors.IsolationLevelEditor;
35 import org.openide.util.NbBundle;
36 /**
37  *
38  * @author nityad
39  */

40 public class ConnPoolBean extends JdbcCP implements java.io.Serializable JavaDoc{
41     
42     /** Creates new ConnPoolBean */
43     public ConnPoolBean() {
44
45     }
46     
47     public String JavaDoc getName() {
48         return super.getName();
49     }
50     
51     public static ConnPoolBean createBean(JdbcConnectionPool pool) {
52         ConnPoolBean bean = new ConnPoolBean();
53                 
54         bean.setName(pool.getName());
55         bean.setDescription(pool.getDescription());
56         bean.setDsClass(pool.getDatasourceClassname());
57         bean.setResType(pool.getResType());
58         bean.setSteadyPoolSize(pool.getSteadyPoolSize());
59         bean.setMaxPoolSize(pool.getMaxPoolSize());
60         bean.setMaxWaitTimeMilli(pool.getMaxWaitTimeInMillis());
61         bean.setPoolResizeQty(pool.getPoolResizeQuantity());
62         bean.setIdleIimeoutSecond(pool.getIdleTimeoutInSeconds());
63         bean.setTranxIsoLevel(pool.getTransactionIsolationLevel());
64         bean.setIsIsoLevGuaranteed(pool.getIsIsolationLevelGuaranteed());
65         bean.setIsConnValidReq(pool.getIsConnectionValidationRequired());
66         bean.setConnValidMethod(pool.getConnectionValidationMethod());
67         bean.setValidationTableName(pool.getValidationTableName());
68         bean.setFailAllConns(pool.getFailAllConnections());
69         bean.setNontranxconns(pool.getNonTransactionalConnections());
70         bean.setAllowNonComponentCallers(pool.getAllowNonComponentCallers());
71                 
72         PropertyElement[] extraProperties = pool.getPropertyElement();
73         Vector JavaDoc vec = new Vector JavaDoc();
74         for (int i = 0; i < extraProperties.length; i++) {
75             NameValuePair pair = new NameValuePair();
76             pair.setParamName(extraProperties[i].getName());
77             pair.setParamValue(extraProperties[i].getValue());
78             vec.add(pair);
79         }
80         
81         if (vec != null && vec.size() > 0) {
82             NameValuePair[] props = new NameValuePair[vec.size()];
83             bean.setExtraParams((NameValuePair[])vec.toArray(props));
84         }
85         return bean;
86     }
87     
88     public Resources getGraph(){
89         Resources res = getResourceGraph();
90         JdbcConnectionPool connPool = res.newJdbcConnectionPool();
91         connPool.setDescription(getDescription());
92         connPool.setName(getName());
93         connPool.setDatasourceClassname(getDsClass());
94         connPool.setResType(getResType());
95         connPool.setSteadyPoolSize(getSteadyPoolSize());
96         connPool.setMaxPoolSize(getMaxPoolSize());
97         connPool.setMaxWaitTimeInMillis(getMaxWaitTimeMilli());
98         connPool.setPoolResizeQuantity(getPoolResizeQty());
99         connPool.setIdleTimeoutInSeconds(getIdleIimeoutSecond());
100         String JavaDoc isolation = getTranxIsoLevel();
101         if (isolation != null && (isolation.length() == 0 || isolation.equals(NbBundle.getMessage(IsolationLevelEditor.class, "LBL_driver_default")))) { //NOI18N
102
isolation = null;
103         }
104         connPool.setTransactionIsolationLevel(isolation);
105         connPool.setIsIsolationLevelGuaranteed(getIsIsoLevGuaranteed());
106         connPool.setIsConnectionValidationRequired(getIsConnValidReq());
107         connPool.setConnectionValidationMethod(getConnValidMethod());
108         connPool.setValidationTableName(getValidationTableName());
109         connPool.setFailAllConnections(getFailAllConns());
110         connPool.setNonTransactionalConnections(getNontranxconns());
111         connPool.setAllowNonComponentCallers(getAllowNonComponentCallers());
112         NameValuePair[] params = getExtraParams();
113         if (params != null && params.length > 0) {
114             for (int i = 0; i < params.length; i++) {
115                 NameValuePair pair = params[i];
116                 PropertyElement prop = connPool.newPropertyElement();
117                 prop = populatePropertyElement(prop, pair);
118                 connPool.addPropertyElement(prop);
119             }
120         }
121         res.addJdbcConnectionPool(connPool);
122         return res;
123     }
124 }
125
Popular Tags