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.JavaMsgServiceResource; 30 import org.netbeans.modules.j2ee.sun.dd.api.DDProvider; 31 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.Resources; 32 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.PropertyElement; 33 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.ConnectorResource; 34 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.AdminObjectResource; 35 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.ConnectorConnectionPool; 36 37 41 public class JMSBean extends JavaMsgServiceResource implements java.io.Serializable { 42 43 44 public JMSBean() { 45 } 46 47 public String getName() { 48 return super.getName(); 49 } 50 51 public static JMSBean createBean(Resources resources) { 52 JMSBean bean = new JMSBean(); 53 ConnectorResource connresource = resources.getConnectorResource(0); 56 bean.setName(connresource.getJndiName()); 57 bean.setDescription(connresource.getDescription()); 58 bean.setIsEnabled(connresource.getEnabled()); 59 bean.setJndiName(connresource.getJndiName()); 60 bean.setPoolName(connresource.getPoolName()); 61 62 ConnectorConnectionPool connpoolresource = resources.getConnectorConnectionPool(0); 63 bean.setResAdapter(connpoolresource.getResourceAdapterName()); 64 bean.setResType(connpoolresource.getConnectionDefinitionName()); 65 66 PropertyElement[] extraProperties = connpoolresource.getPropertyElement(); 67 Vector vec = new Vector (); 68 for (int i = 0; i < extraProperties.length; i++) { 69 NameValuePair pair = new NameValuePair(); 70 pair.setParamName(extraProperties[i].getName()); 71 pair.setParamValue(extraProperties[i].getValue()); 72 vec.add(pair); 73 } 74 75 if (vec != null && vec.size() > 0) { 76 NameValuePair[] props = new NameValuePair[vec.size()]; 77 bean.setExtraParams((NameValuePair[])vec.toArray(props)); 78 } 79 80 return bean; 81 } 82 83 public static JMSBean createBean(AdminObjectResource aoresource) { 84 JMSBean bean = new JMSBean(); 85 86 bean.setName(aoresource.getJndiName()); 89 bean.setDescription(aoresource.getDescription()); 90 bean.setIsEnabled(aoresource.getEnabled()); 91 bean.setJndiName(aoresource.getJndiName()); 92 bean.setResAdapter(aoresource.getResAdapter()); 93 bean.setResType(aoresource.getResType()); 94 95 PropertyElement[] extraProperties = aoresource.getPropertyElement(); 96 Vector vec = new Vector (); 97 for (int i = 0; i < extraProperties.length; i++) { 98 NameValuePair pair = new NameValuePair(); 99 pair.setParamName(extraProperties[i].getName()); 100 pair.setParamValue(extraProperties[i].getValue()); 101 vec.add(pair); 102 } 103 104 if (vec != null && vec.size() > 0) { 105 NameValuePair[] props = new NameValuePair[vec.size()]; 106 bean.setExtraParams((NameValuePair[])vec.toArray(props)); 107 } 108 109 return bean; 110 } 111 112 public Resources getConnectorGraph(){ 113 Resources res = getResourceGraph(); 114 ConnectorResource connresource = res.newConnectorResource(); 115 connresource.setDescription(getDescription()); 116 connresource.setEnabled(getIsEnabled()); 117 connresource.setJndiName(getJndiName()); 118 connresource.setPoolName(getJndiName()); 119 120 ConnectorConnectionPool connpoolresource = res.newConnectorConnectionPool(); 121 connpoolresource.setName(getJndiName()); 122 connpoolresource.setResourceAdapterName(getResAdapter()); 123 connpoolresource.setConnectionDefinitionName(getResType()); 124 NameValuePair[] params = getExtraParams(); 126 if (params != null && params.length > 0) { 127 for (int i = 0; i < params.length; i++) { 128 NameValuePair pair = params[i]; 129 PropertyElement prop = connpoolresource.newPropertyElement(); 130 prop = populatePropertyElement(prop, pair); 131 connpoolresource.addPropertyElement(prop); 132 } 133 } 134 135 res.addConnectorResource(connresource); 136 res.addConnectorConnectionPool(connpoolresource); 137 138 return res; 139 } 140 141 public Resources getAdminObjectGraph(){ 142 Resources res = getResourceGraph(); 143 AdminObjectResource aoresource = res.newAdminObjectResource(); 144 aoresource.setDescription(getDescription()); 145 aoresource.setEnabled(getIsEnabled()); 146 aoresource.setJndiName(getJndiName()); 147 aoresource.setResAdapter(getResAdapter()); 148 aoresource.setResType(getResType()); 149 150 NameValuePair[] params = getExtraParams(); 152 if (params != null && params.length > 0) { 153 for (int i = 0; i < params.length; i++) { 154 NameValuePair pair = params[i]; 155 PropertyElement prop = aoresource.newPropertyElement(); 156 prop = populatePropertyElement(prop, pair); 157 aoresource.addPropertyElement(prop); 158 } 159 } 160 161 res.addAdminObjectResource(aoresource); 162 return res; 163 } 164 } 165 | Popular Tags |