1 19 20 24 25 package org.netbeans.modules.j2ee.sun.ws7.serverresources.beans; 26 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.WS70CustomResource; 27 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.WS70Resources; 28 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.PropertyElement; 29 30 import java.util.Vector ; 31 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair; 32 33 34 38 public class WS70CustomResourceBean extends WS70BaseResourceBean implements java.io.Serializable { 39 40 private String resType; 41 private String factoryClass; 42 43 44 45 public WS70CustomResourceBean() { 46 } 47 public String getResType() { 48 return resType; 49 } 50 public void setResType(String value) { 51 String oldValue = resType; 52 this.resType = value; 53 initPropertyChangeSupport(); 54 propertySupport.firePropertyChange ("resType", oldValue, resType); } 56 public String getFactoryClass() { 57 return factoryClass; 58 } 59 public void setFactoryClass(String value) { 60 String oldValue = factoryClass; 61 this.factoryClass = value; 62 initPropertyChangeSupport(); 63 propertySupport.firePropertyChange ("factoryClass", oldValue, factoryClass); } 65 66 67 public static WS70CustomResourceBean createBean(WS70CustomResource customresource) { 68 WS70CustomResourceBean bean = new WS70CustomResourceBean(); 69 bean.setName(customresource.getJndiName()); 72 bean.setDescription(customresource.getDescription()); 73 bean.setJndiName(customresource.getJndiName()); 74 bean.setFactoryClass(customresource.getFactoryClass()); 75 bean.setResType(customresource.getResType()); 76 bean.setIsEnabled(customresource.getEnabled()); 77 78 PropertyElement[] extraProperties = customresource.getPropertyElement(); 79 Vector vec = new Vector (); 80 for (int i = 0; i < extraProperties.length; i++) { 81 NameValuePair pair = new NameValuePair(); 82 pair.setParamName(extraProperties[i].getName()); 83 pair.setParamValue(extraProperties[i].getValue()); 84 vec.add(pair); 85 } 86 87 if (vec != null && vec.size() > 0) { 88 NameValuePair[] props = new NameValuePair[vec.size()]; 89 bean.setExtraParams((NameValuePair[])vec.toArray(props)); 90 } 91 92 return bean; 93 } 94 95 public WS70Resources getGraph(){ 96 WS70Resources res = getResourceGraph(); 97 WS70CustomResource customresource = res.newWS70CustomResource(); 98 customresource.setDescription(getDescription()); 99 customresource.setJndiName(getJndiName()); 100 101 customresource.setResType(getResType()); 102 customresource.setFactoryClass(getFactoryClass()); 103 customresource.setEnabled(getIsEnabled()); 104 105 NameValuePair[] params = getExtraParams(); 107 if (params != null && params.length > 0) { 108 for (int i = 0; i < params.length; i++) { 109 NameValuePair pair = params[i]; 110 PropertyElement prop = customresource.newPropertyElement(); 111 prop = populatePropertyElement(prop, pair); 112 customresource.addPropertyElement(prop); 113 } 114 } 115 116 res.addWS70CustomResource(customresource); 117 return res; 118 } 119 120 } 121 | Popular Tags |