1 23 24 31 32 package com.sun.enterprise.tools.common.deploy; 33 34 import java.beans.*; 35 import java.util.List ; 36 import java.net.InetAddress ; 37 import java.io.File ; 38 import java.util.Vector ; 39 import com.sun.enterprise.tools.common.util.diagnostics.Reporter; 40 41 import com.sun.enterprise.tools.common.deploy.IPMFactory; 43 44 public class PersistenceManager extends Object implements java.io.Serializable { 45 46 private String name; 47 private String Description; 48 private String JndiName; 49 private String FactoryClassName; 51 private String Enabled; 53 private NameValuePair[] extParams = new NameValuePair[0]; 54 55 private String DataSourceName; 56 63 transient protected PropertyChangeSupport propertySupport; 64 65 public PersistenceManager(List resources) { 66 propertySupport = new PropertyChangeSupport ( this ); 67 JndiName = "jdo/"; Description = ""; FactoryClassName = "com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpl"; Enabled = "true"; 76 DataSourceName = "jdbc/"; 84 String resName = "PersistenceManager"; String t_name = null; 86 if(resources.size() != 0){ 87 int num = resources.size()+1; 88 t_name = resName + "_" + num; boolean resource_exists = FactoryName(t_name, resources); 90 while(resource_exists){ 91 num++; 92 t_name = resName + "_" + num; resource_exists = FactoryName(t_name, resources); 94 } 95 }else{ 96 t_name = resName + "_1"; } 98 name = t_name; 99 } 100 101 public boolean FactoryName(String value, List resources){ 102 boolean exists = false; 103 for(int i=0; i<resources.size(); i++){ 104 IPMFactory instance = (IPMFactory) resources.get(i); 105 String inst = instance.getName(); 106 if(inst.equals(value)) 107 exists = true; 108 } return exists; 110 } 111 112 public String getJndiName() { 113 return JndiName; 114 } 115 116 public void setJndiName(String value) { 117 String oldValue = JndiName; 118 this.JndiName = value; 119 initPropertyChangeSupport(); 120 propertySupport.firePropertyChange ("JndiName", oldValue, JndiName); setName(JndiName); 122 } 123 124 public void simpleSetJndiName(String value) { 125 this.JndiName = value; 126 setName(JndiName); 127 } 128 129 public String getDescription() { 130 return Description; 131 } 132 133 public void setDescription(String value) { 134 String oldValue = Description; 135 this.Description = value; 136 initPropertyChangeSupport(); 137 propertySupport.firePropertyChange ("Description", oldValue, Description); } 139 151 public String getFactoryClassName() { 152 return FactoryClassName; 153 } 154 155 public void setFactoryClassName(String value) { 156 String oldValue = FactoryClassName; 157 this.FactoryClassName = value; 158 initPropertyChangeSupport(); 159 propertySupport.firePropertyChange ("FactoryClassName", oldValue, FactoryClassName); } 161 162 174 175 public String getEnabled() { 176 return Enabled; 177 } 178 179 public void setEnabled(String value) { 180 String oldValue = Enabled; 181 this.Enabled = value; 182 initPropertyChangeSupport(); 183 propertySupport.firePropertyChange ("Enabled", oldValue, Enabled); } 185 186 198 199 public String getDataSourceName() { 200 return DataSourceName; 201 } 202 203 public void setDataSourceName(String value) { 204 String oldValue = DataSourceName; 205 this.DataSourceName = value; 206 initPropertyChangeSupport(); 207 propertySupport.firePropertyChange ("DataSourceName", oldValue, DataSourceName); } 209 265 private void initPropertyChangeSupport(){ 266 if(propertySupport==null) 267 propertySupport = new PropertyChangeSupport ( this ); 268 269 } 270 271 public void addPropertyChangeListener (PropertyChangeListener listener) { 272 initPropertyChangeSupport(); 273 propertySupport.addPropertyChangeListener (listener); 274 } 275 276 public void removePropertyChangeListener (PropertyChangeListener listener) { 277 initPropertyChangeSupport(); 278 propertySupport.removePropertyChangeListener (listener); 279 } 280 281 public String getName() { 282 return name; 283 } 284 285 public void setName(String value) { 286 String oldValue = name; 287 this.name = value; 288 initPropertyChangeSupport(); 289 propertySupport.firePropertyChange ("name", oldValue, name); } 291 292 public NameValuePair[] getExtParams() { 293 return extParams; 294 } 295 296 public void setExtParams(Object [] value) { 297 Reporter.info(new Integer (value.length)); NameValuePair[] pairs = new NameValuePair[value.length]; 299 for (int i = 0; i < value.length; i++) { 300 NameValuePair val = (NameValuePair)value[i]; 301 NameValuePair pair = new NameValuePair(); 302 pair.setParamName(val.getParamName()); 303 pair.setParamValue(val.getParamValue()); 304 pair.setParamDescription(val.getParamDescription()); 305 Reporter.info(pair.getParamName() + " " + pair.getParamValue() + " " + pair.getParamDescription()); pairs[i] = pair; 307 } 308 NameValuePair[] oldValue = extParams; 309 this.extParams = pairs; 310 initPropertyChangeSupport(); 311 propertySupport.firePropertyChange ("extParams", oldValue, extParams); } 313 public String toString() { 314 return "name: " + getName() + ", Description: " + getDescription() + ", JndiName: " + getJndiName() + ", FactoryClassName: " + getFactoryClassName() + ", Enabled: " + getEnabled(); } 318 } 319 | Popular Tags |