1 23 24 package com.sun.enterprise.tools.common.deploy; 25 26 import java.beans.*; 27 import java.net.InetAddress ; 28 import java.io.File ; 29 import java.util.ResourceBundle ; 30 import java.util.List ; 31 import javax.swing.JOptionPane ; 32 import com.sun.enterprise.tools.common.datasource.IDSBean; 38 import com.sun.enterprise.tools.common.util.diagnostics.Reporter; 39 46 public class DSFields extends Object implements java.io.Serializable { 47 48 static final ResourceBundle bundle = ResourceBundle.getBundle("com.sun.enterprise.tools.common.deploy.Bundle"); private static String filename; 50 51 transient private PropertyChangeSupport propertySupport; 52 53 private String name; 54 private String JndiName; 55 private String PoolName; 56 private String Enabled; 58 private String Description; 59 private NameValuePair[] extParams; 60 61 private String RegPoolName; 62 63 70 71 public DSFields(List ds) { 72 propertySupport = new PropertyChangeSupport ( this ); 73 74 PoolName = bundle.getString("Unconfigured"); RegPoolName = PoolName; 77 Enabled = "true"; Description = ""; extParams = new NameValuePair[0]; 81 87 String t_name = null; 89 if(ds.size() != 0){ 90 int num = ds.size()+1; 91 t_name = "DataSource_" + num; boolean exists = DataSourceName(t_name,ds); 93 while(exists){ 94 num++; 95 t_name = "DataSource_" + num; exists = DataSourceName(t_name,ds); 97 } 98 }else{ 99 t_name = "DataSource_1"; } 101 name = t_name; 102 JndiName = "jdbc/"; } 104 105 public String getJndiName() { 106 return JndiName; 107 } 108 public void setJndiName(java.lang.String jndiName) { 109 String prev = JndiName; 110 this.JndiName = jndiName; 111 initPropertyChangeSupport(); 112 propertySupport.firePropertyChange ("JndiName", prev, JndiName); 118 setName(JndiName); 119 } 120 121 public void simpleSetJndiName(String value) { 122 this.JndiName = value; 123 setName(JndiName); 124 } 125 126 public String getPoolName() { 127 Reporter.info(PoolName + " " + RegPoolName); return PoolName; 129 } 130 131 public void setPoolName(java.lang.String val) { 132 String prev = PoolName; 133 this.PoolName = val; 134 setRegPoolName(PoolName); 135 Reporter.info(PoolName + " " + RegPoolName); initPropertyChangeSupport(); 137 propertySupport.firePropertyChange ("PoolName", prev, PoolName); } 139 140 public String getRegPoolName(){ 141 Reporter.info(PoolName + " " + RegPoolName); return RegPoolName; 143 } 144 public void setRegPoolName(java.lang.String val){ 145 String prev = RegPoolName; 146 int offset = val.indexOf("("); if (offset == -1) 148 this.RegPoolName = val; 149 else 150 this.RegPoolName = val.substring(0, offset); 151 Reporter.info(PoolName + " " + RegPoolName); } 153 154 166 public String getEnabled() { 167 return Enabled; 168 } 169 170 public void setEnabled(java.lang.String val) { 171 String prev = Enabled; 172 this.Enabled = val; 173 initPropertyChangeSupport(); 174 propertySupport.firePropertyChange ("Enabled", prev, Enabled); } 176 177 public String getDescription() { 178 return Description; 179 } 180 181 public void setDescription(java.lang.String val) { 182 String prev = Description; 183 this.Description = val; 184 initPropertyChangeSupport(); 185 propertySupport.firePropertyChange ("Description", prev, Description); } 187 188 public NameValuePair[] getExtParams() { 189 return extParams; 190 } 191 192 public void setExtParams(Object [] value) { 193 Reporter.info(new Integer (value.length)); NameValuePair[] pairs = new NameValuePair[value.length]; 195 for (int i = 0; i < value.length; i++) { 196 NameValuePair val = (NameValuePair)value[i]; 197 NameValuePair pair = new NameValuePair(); 198 pair.setParamName(val.getParamName()); 199 pair.setParamValue(val.getParamValue()); 200 pair.setParamDescription(val.getParamDescription()); 201 Reporter.info(pair.getParamName() + " " + pair.getParamValue()); pairs[i] = pair; 203 } 204 NameValuePair[] oldValue = extParams; 205 this.extParams = pairs; 206 initPropertyChangeSupport(); 207 propertySupport.firePropertyChange ("extParams", oldValue, extParams); } 209 210 private void initPropertyChangeSupport(){ 211 if(propertySupport==null) 212 propertySupport = new PropertyChangeSupport ( this ); 213 214 } 215 public void addPropertyChangeListener (PropertyChangeListener listener) { 216 initPropertyChangeSupport(); 217 propertySupport.addPropertyChangeListener (listener); 218 } 219 220 public void removePropertyChangeListener (PropertyChangeListener listener) { 221 initPropertyChangeSupport(); 222 propertySupport.removePropertyChangeListener (listener); 223 } 224 225 public String getName() { 226 return name; 227 } 228 public void setName(String value) { 229 String oldValue = " "; name = value; 231 initPropertyChangeSupport(); 232 propertySupport.firePropertyChange ("name", oldValue, name); } 234 302 334 private boolean DataSourceName(String value, List pm1){ 335 boolean exists = false; 336 for(int i=0; i<pm1.size(); i++){ 340 IDSBean instance = (IDSBean) pm1.get(i); 343 String inst = instance.getName(); 344 if(inst.equals(value)) 345 exists = true; 346 } return exists; 348 } 349 350 } 351 352 | Popular Tags |