1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.sunresources.beans; 26 27 import java.util.Vector ; 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 40 public class ConnPoolBean extends JdbcCP implements java.io.Serializable { 41 42 43 public ConnPoolBean() { 44 45 } 46 47 public String 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 vec = new Vector (); 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 isolation = getTranxIsoLevel(); 101 if (isolation != null && (isolation.length() == 0 || isolation.equals(NbBundle.getMessage(IsolationLevelEditor.class, "LBL_driver_default")))) { 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 |