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.JdbcDS; 31 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.*; 32 33 37 public class DataSourceBean extends JdbcDS implements java.io.Serializable { 38 39 40 public DataSourceBean() { 41 42 } 43 44 public String getName() { 45 return super.getName(); 46 } 47 48 public String getJndiName(){ 49 return super.getJndiName(); 50 } 51 52 public static DataSourceBean createBean(JdbcResource datasource) { 53 DataSourceBean bean = new DataSourceBean(); 54 bean.setName(datasource.getJndiName()); 57 bean.setDescription(datasource.getDescription()); 58 bean.setJndiName(datasource.getJndiName()); 59 bean.setConnPoolName(datasource.getPoolName()); 60 bean.setResType(datasource.getObjectType()); 61 bean.setIsEnabled(datasource.getEnabled()); 62 63 PropertyElement[] extraProperties = datasource.getPropertyElement(); 64 Vector vec = new Vector (); 65 for (int i = 0; i < extraProperties.length; i++) { 66 NameValuePair pair = new NameValuePair(); 67 pair.setParamName(extraProperties[i].getName()); 68 pair.setParamValue(extraProperties[i].getValue()); 69 vec.add(pair); 70 } 71 72 if (vec != null && vec.size() > 0) { 73 NameValuePair[] props = new NameValuePair[vec.size()]; 74 bean.setExtraParams((NameValuePair[])vec.toArray(props)); 75 } 76 77 return bean; 78 } 79 80 public Resources getGraph(){ 81 Resources res = getResourceGraph(); 82 JdbcResource datasource = res.newJdbcResource(); 83 datasource.setDescription(getDescription()); 84 datasource.setJndiName(getJndiName()); 85 datasource.setPoolName(getConnPoolName()); 86 datasource.setObjectType(getResType()); 87 datasource.setEnabled(getIsEnabled()); 88 89 NameValuePair[] params = getExtraParams(); 91 if (params != null && params.length > 0) { 92 for (int i = 0; i < params.length; i++) { 93 NameValuePair pair = params[i]; 94 PropertyElement prop = datasource.newPropertyElement(); 95 prop = populatePropertyElement(prop, pair); 96 datasource.addPropertyElement(prop); 97 } 98 } 99 100 res.addJdbcResource(datasource); 101 return res; 102 } 103 104 } 105 | Popular Tags |