1 23 24 29 30 package com.sun.enterprise.tools.common.deploy; 31 32 import java.beans.*; 33 import java.util.List ; 34 35 public class BaseResource implements java.io.Serializable { 36 37 private String name; 38 private String Description; 39 protected String JndiName; 40 private String ResType; 41 private String Enabled; 44 45 transient protected PropertyChangeSupport propertySupport; 46 47 public BaseResource(List resources, String resName) { 48 propertySupport = new PropertyChangeSupport ( this ); 49 JndiName = "JndiName"; Description = ""; ResType = "ResourceType"; Enabled = "true"; 56 String t_name = null; 57 if(resources.size() != 0){ 58 int num = resources.size()+1; 59 t_name = resName + "_" + num; boolean resource_exists = FactoryName(t_name, resources); 61 while(resource_exists){ 62 num++; 63 t_name = resName + "_" + num; resource_exists = FactoryName(t_name, resources); 65 } 66 }else{ 67 t_name = resName + "_1"; } 69 name = t_name; 70 } 71 72 public boolean FactoryName(String value, List resources){ 73 boolean exists = false; 74 for(int i=0; i<resources.size(); i++){ 75 IResource instance = (IResource) resources.get(i); 76 String inst = instance.getName(); 77 if(inst.equals(value)) 78 exists = true; 79 } return exists; 81 } 82 83 public String getJndiName() { 84 return JndiName; 85 } 86 87 public void setJndiName(String value) { 88 String oldValue = JndiName; 89 this.JndiName = value; 90 initPropertyChangeSupport(); 91 propertySupport.firePropertyChange ("JndiName", oldValue, JndiName); setName(JndiName); 93 } 94 95 public void simpleSetJndiName(String value) { 96 this.JndiName = value; 97 setName(JndiName); 98 } 99 100 public String getDescription() { 101 return Description; 102 } 103 104 public void setDescription(String value) { 105 String oldValue = Description; 106 this.Description = value; 107 initPropertyChangeSupport(); 108 propertySupport.firePropertyChange ("Description", oldValue, Description); } 110 111 public String getResType() { 112 return ResType; 113 } 114 115 public void setResType(String value) { 116 String oldValue = ResType; 117 this.ResType = value; 118 initPropertyChangeSupport(); 119 propertySupport.firePropertyChange ("ResType", oldValue, ResType); } 121 144 public String getEnabled() { 145 return Enabled; 146 } 147 148 public void setEnabled(String value) { 149 String oldValue = Enabled; 150 this.Enabled = value; 151 initPropertyChangeSupport(); 152 propertySupport.firePropertyChange ("Enabled", oldValue, Enabled); } 154 155 protected void initPropertyChangeSupport(){ 156 if(propertySupport==null) 157 propertySupport = new PropertyChangeSupport ( this ); 158 159 } 160 public void addPropertyChangeListener (PropertyChangeListener listener) { 161 initPropertyChangeSupport(); 162 propertySupport.addPropertyChangeListener (listener); 163 } 164 165 public void removePropertyChangeListener (PropertyChangeListener listener) { 166 initPropertyChangeSupport(); 167 propertySupport.removePropertyChangeListener (listener); 168 } 169 170 public String getName() { 171 return name; 172 } 173 public void setName(String value) { 174 String oldValue = name; 175 this.name = value; 176 initPropertyChangeSupport(); 177 propertySupport.firePropertyChange ("name", oldValue, name); } 179 } 180 | Popular Tags |