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.io.File ; 37 import java.util.Vector ; 38 import com.sun.enterprise.tools.common.util.diagnostics.Reporter; 39 40 public class MailResource extends Object implements java.io.Serializable { 41 42 private String name; 43 private String Description; 44 private String JndiName; 45 private String StoreProtocol; 46 private String StoreProtocolClass; 47 private String TransportProtocol; 48 private String TransportProtocolClass; 49 private String Host; 50 private String Enabled; 52 private NameValuePair[] extParams = new NameValuePair[0]; 53 54 private String User; 55 private String From; 56 private String Debug; 57 58 transient protected PropertyChangeSupport propertySupport; 59 60 public MailResource(List resources) { 61 propertySupport = new PropertyChangeSupport ( this ); 62 JndiName = "mail/jndiname"; Description = ""; StoreProtocol = "imap"; StoreProtocolClass = "com.sun.mail.imap.IMAPStore"; TransportProtocol = "smtp"; TransportProtocolClass = "com.sun.mail.smtp.SMTPTransport"; Host = "Mail Host"; Enabled = "true"; 73 User = "User Name"; From = "User Email Address"; Debug = "false"; 77 String resName = "MailResource"; String t_name = null; 79 if(resources.size() != 0){ 80 int num = resources.size()+1; 81 t_name = resName + "_" + num; boolean resource_exists = FactoryName(t_name, resources); 83 while(resource_exists){ 84 num++; 85 t_name = resName + "_" + num; resource_exists = FactoryName(t_name, resources); 87 } 88 }else{ 89 t_name = resName + "_1"; } 91 name = t_name; 92 } 93 94 public boolean FactoryName(String value, List resources){ 95 boolean exists = false; 96 for(int i=0; i<resources.size(); i++){ 97 IMailResource instance = (IMailResource) resources.get(i); 98 String inst = instance.getName(); 99 if(inst.equals(value)) 100 exists = true; 101 } return exists; 103 } 104 105 public String getJndiName() { 106 return JndiName; 107 } 108 109 public void setJndiName(String value) { 110 String oldValue = JndiName; 111 this.JndiName = value; 112 initPropertyChangeSupport(); 113 propertySupport.firePropertyChange ("JndiName", oldValue, JndiName); setName(JndiName); 115 } 116 117 public void simpleSetJndiName(String value) { 118 this.JndiName = value; 119 setName(JndiName); 120 } 121 122 public String getDescription() { 123 return Description; 124 } 125 126 public void setDescription(String value) { 127 String oldValue = Description; 128 this.Description = value; 129 initPropertyChangeSupport(); 130 propertySupport.firePropertyChange ("Description", oldValue, Description); } 132 133 public String getStoreProtocol() { 134 return StoreProtocol; 135 } 136 137 public void setStoreProtocol(String value) { 138 String oldValue = StoreProtocol; 139 this.StoreProtocol = value; 140 initPropertyChangeSupport(); 141 propertySupport.firePropertyChange ("StoreProtocol", oldValue, StoreProtocol); } 143 144 public String getStoreProtocolClass() { 145 return StoreProtocolClass; 146 } 147 148 public void setStoreProtocolClass(String value) { 149 String oldValue = StoreProtocolClass; 150 this.StoreProtocolClass = value; 151 initPropertyChangeSupport(); 152 propertySupport.firePropertyChange ("StoreProtocolClass", oldValue, StoreProtocolClass); } 154 155 public String getTransportProtocol() { 156 return TransportProtocol; 157 } 158 159 public void setTransportProtocol(String value) { 160 String oldValue = TransportProtocol; 161 this.TransportProtocol = value; 162 initPropertyChangeSupport(); 163 propertySupport.firePropertyChange ("TransportProtocol", oldValue, TransportProtocol); } 165 166 public String getTransportProtocolClass() { 167 return TransportProtocolClass; 168 } 169 170 public void setTransportProtocolClass(String value) { 171 String oldValue = TransportProtocolClass; 172 this.TransportProtocolClass = value; 173 initPropertyChangeSupport(); 174 propertySupport.firePropertyChange ("TransportProtocolClass", oldValue, TransportProtocolClass); } 176 177 public String getHost() { 178 return Host; 179 } 180 181 public void setHost(String value) { 182 String oldValue = Host; 183 this.Host = value; 184 initPropertyChangeSupport(); 185 propertySupport.firePropertyChange ("Host", oldValue, Host); } 187 188 public String getEnabled() { 189 return Enabled; 190 } 191 192 public void setEnabled(String value) { 193 String oldValue = Enabled; 194 this.Enabled = value; 195 initPropertyChangeSupport(); 196 propertySupport.firePropertyChange ("Enabled", oldValue, Enabled); } 198 199 public String getUser() { 200 return User; 201 } 202 203 public void setUser(String value) { 204 String oldValue = User; 205 this.User = value; 206 initPropertyChangeSupport(); 207 propertySupport.firePropertyChange ("User", oldValue, User); } 209 210 public String getFrom() { 211 return From; 212 } 213 214 public void setFrom(String value) { 215 String oldValue = From; 216 this.From = value; 217 initPropertyChangeSupport(); 218 propertySupport.firePropertyChange ("From", oldValue, From); } 220 221 public String getDebug() { 222 return Debug; 223 } 224 225 public void setDebug(String value) { 226 String oldValue = Debug; 227 this.Debug = value; 228 initPropertyChangeSupport(); 229 propertySupport.firePropertyChange ("Debug", oldValue, Debug); } 231 232 private void initPropertyChangeSupport(){ 233 if(propertySupport==null) 234 propertySupport = new PropertyChangeSupport ( this ); 235 236 } 237 238 public void addPropertyChangeListener (PropertyChangeListener listener) { 239 initPropertyChangeSupport(); 240 propertySupport.addPropertyChangeListener (listener); 241 } 242 243 public void removePropertyChangeListener (PropertyChangeListener listener) { 244 initPropertyChangeSupport(); 245 propertySupport.removePropertyChangeListener (listener); 246 } 247 248 public String getName() { 249 return name; 250 } 251 252 public void setName(String value) { 253 String oldValue = name; 254 this.name = value; 255 initPropertyChangeSupport(); 256 propertySupport.firePropertyChange ("name", oldValue, name); } 258 259 public NameValuePair[] getExtParams() { 260 return extParams; 261 } 262 263 public void setExtParams(Object [] value) { 264 Reporter.info(new Integer (value.length)); NameValuePair[] pairs = new NameValuePair[value.length]; 266 for (int i = 0; i < value.length; i++) { 267 NameValuePair val = (NameValuePair)value[i]; 268 NameValuePair pair = new NameValuePair(); 269 pair.setParamName(val.getParamName()); 270 pair.setParamValue(val.getParamValue()); 271 pair.setParamDescription(val.getParamDescription()); 272 Reporter.info(pair.getParamName() + " " + pair.getParamValue()); pairs[i] = pair; 274 } 275 NameValuePair[] oldValue = extParams; 276 this.extParams = pairs; 277 initPropertyChangeSupport(); 278 propertySupport.firePropertyChange ("extParams", oldValue, extParams); } 280 281 public String toString() { 282 return "name: " + getName() + ", Description: " + getDescription() + ", JndiName: " + getJndiName() + ", Store Protocol: " + getStoreProtocol() + ", Store Protocol Class: " + getStoreProtocolClass() + ", Transport Protocol: " + getTransportProtocol() + ", Transport Protocol Class: " + getTransportProtocolClass() + ", Host: " + getHost() + ", User: " + getUser() + ", From: " + getFrom() + ", Debug: " + getDebug() + ", Enabled: " + getEnabled(); } 290 } 291 | Popular Tags |