1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.sunresources.beans; 26 27 import java.util.Vector ; 28 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair; 29 import org.netbeans.modules.j2ee.sun.share.serverresources.MailSessionResource; 30 import org.netbeans.modules.j2ee.sun.dd.api.DDProvider; 31 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.*; 32 33 37 public class JavaMailSessionBean extends MailSessionResource implements java.io.Serializable { 38 39 40 public JavaMailSessionBean() { 41 } 42 43 public String getName() { 44 return super.getName(); 45 } 46 47 public String getJndiName(){ 48 return super.getJndiName(); 49 } 50 51 public static JavaMailSessionBean createBean(MailResource mailresource) { 52 JavaMailSessionBean bean = new JavaMailSessionBean(); 53 bean.setName(mailresource.getJndiName()); 56 bean.setDescription(mailresource.getDescription()); 57 bean.setJndiName(mailresource.getJndiName()); 58 bean.setStoreProt(mailresource.getStoreProtocol()); 59 bean.setStoreProtClass(mailresource.getStoreProtocolClass()); 60 bean.setTransProt(mailresource.getTransportProtocol()); 61 bean.setTransProtClass(mailresource.getTransportProtocolClass()); 62 bean.setHostName(mailresource.getHost()); 63 bean.setUserName(mailresource.getUser()); 64 bean.setFromAddr(mailresource.getFrom()); 65 bean.setIsDebug(mailresource.getDebug()); 66 bean.setIsEnabled(mailresource.getEnabled()); 67 68 PropertyElement[] extraProperties = mailresource.getPropertyElement(); 69 Vector vec = new Vector (); 70 for (int i = 0; i < extraProperties.length; i++) { 71 NameValuePair pair = new NameValuePair(); 72 pair.setParamName(extraProperties[i].getName()); 73 pair.setParamValue(extraProperties[i].getValue()); 74 vec.add(pair); 75 } 76 77 if (vec != null && vec.size() > 0) { 78 NameValuePair[] props = new NameValuePair[vec.size()]; 79 bean.setExtraParams((NameValuePair[])vec.toArray(props)); 80 } 81 82 return bean; 83 } 84 85 public Resources getGraph(){ 86 Resources res = getResourceGraph(); 87 MailResource mlresource = res.newMailResource(); 88 mlresource.setDescription(getDescription()); 89 mlresource.setJndiName(getJndiName()); 90 mlresource.setStoreProtocol(getStoreProt()); 91 mlresource.setStoreProtocolClass(getStoreProtClass()); 92 mlresource.setTransportProtocol(getTransProt()); 93 mlresource.setTransportProtocolClass(getTransProtClass()); 94 mlresource.setHost(getHostName()); 95 mlresource.setUser(getUserName()); 96 mlresource.setFrom(getFromAddr()); 97 mlresource.setDebug(getIsDebug()); 98 mlresource.setEnabled(getIsEnabled()); 99 100 NameValuePair[] params = getExtraParams(); 102 if (params != null && params.length > 0) { 103 for (int i = 0; i < params.length; i++) { 104 NameValuePair pair = params[i]; 105 PropertyElement prop = mlresource.newPropertyElement(); 106 prop = populatePropertyElement(prop, pair); 107 mlresource.addPropertyElement(prop); 108 } 109 } 110 111 res.addMailResource(mlresource); 112 return res; 113 } 114 115 } 116 | Popular Tags |