1 23 24 29 30 package com.sun.enterprise.tools.common.beans; 31 32 import java.util.ResourceBundle ; 33 34 import java.beans.PropertyVetoException ; 35 import java.beans.VetoableChangeListener ; 36 import java.beans.PropertyChangeEvent ; 37 38 import com.sun.enterprise.tools.common.properties.RoleMapElement; 39 import com.sun.enterprise.tools.common.properties.PropertyElements; 40 41 import com.sun.enterprise.tools.common.dd.connector.*; 42 import org.netbeans.modules.schema2beans.BaseBean; 43 48 public class IasConnectorOneZero extends BasicIasBean { 50 private static String PROPNAME_MAXPOOLSIZE = "maxPoolSize"; private static String PROPNAME_STEADYPOOLSIZE = "steadyPoolSize"; private static String PROPNAME_MAXWAITTIMEINMILLIS= "maxWaitTimeInMilis"; private static String PROPNAME_IDLETIMEOUTINSECONDS = "idleTimeoutInSeconds"; private static String PROPNAME_JNDINAME = "jndiName"; private static String PROPNAME_DESCRIPTION = "description"; 57 protected SunConnector fileBean = null; 58 protected ResourceAdapter ra = null; 59 protected RoleMapElement roleMap = null; 60 protected PropertyElements propertyElements = null; 61 public static String DEFAULT_MAP_ID = "1"; 63 66 protected IasConnectorOneZero() { 67 initListeners(); 68 } 69 70 public IasConnectorOneZero(java.io.InputStream is) { 71 try { 72 fileBean = SunConnector.createGraph(is); 73 } 74 catch (Throwable t) { 75 fileBean = SunConnector.createGraph(); 78 ra = new ResourceAdapter(); 79 ra.setAttributeValue("jndi-name","default"); fileBean.setResourceAdapter(ra); 81 } 82 ra = fileBean.getResourceAdapter(); 83 RoleMap rm = fileBean.getRoleMap(); 84 if (null == rm) { 85 rm = new RoleMap(); 86 rm.setAttributeValue("map-id", DEFAULT_MAP_ID); 87 fileBean.setRoleMap(rm); 95 } 96 roleMap = new RoleMapElement(rm); 97 propertyElements = new PropertyElements(ra); 98 initListeners(); 99 } 100 101 private void initListeners() { 102 getVCS().addVetoableChangeListener(PROPNAME_MAXPOOLSIZE, greaterThanNegOne); 103 getVCS().addVetoableChangeListener(PROPNAME_STEADYPOOLSIZE, greaterThanNegOne); 104 getVCS().addVetoableChangeListener(PROPNAME_MAXWAITTIMEINMILLIS, greaterThanNegOne); 105 getVCS().addVetoableChangeListener(PROPNAME_IDLETIMEOUTINSECONDS, greaterThanNegOne); 106 getVCS().addVetoableChangeListener(PROPNAME_JNDINAME, notNull); 107 } 108 109 110 public void setDescription(String newDesc) throws PropertyVetoException { 111 String elementName = "description"; String propName = PROPNAME_DESCRIPTION; 113 doElementSetProcessing(ra, newDesc, elementName, propName); 114 } 115 116 public String getDescription() { 117 return ra.getDescription(); 118 } 119 120 public void setJndiName(String newName) throws PropertyVetoException { 121 String attrName = "jndi-name"; String propName = PROPNAME_JNDINAME; 123 doAttrSetProcessing(ra, newName, attrName, propName); 124 } 125 126 127 public String getJndiName() { 128 return ra.getAttributeValue("jndi-name"); } 130 131 public void setMaxPoolSize(int newVal) throws PropertyVetoException { 132 String attrName = "max-pool-size"; String propName = PROPNAME_MAXPOOLSIZE; 134 doAttrSetProcessing(ra, newVal,attrName, propName); 135 } 136 137 138 public int getMaxPoolSize() { 139 return Integer.parseInt(ra.getAttributeValue("max-pool-size")); } 141 142 public void setSteadyPoolSize(int newVal) throws PropertyVetoException { 143 String attrName = "steady-pool-size"; String propName = PROPNAME_STEADYPOOLSIZE; 145 doAttrSetProcessing(ra, newVal,attrName, propName); 146 } 147 148 public int getSteadyPoolSize() { 149 return Integer.parseInt(ra.getAttributeValue("steady-pool-size")); } 151 152 public void setMaxWaitTimeInMillis(int newVal) throws PropertyVetoException { 153 String attrName = "max-wait-time-in-millis"; String propName = PROPNAME_MAXWAITTIMEINMILLIS; 155 doAttrSetProcessing(ra, newVal,attrName, propName); 156 } 157 158 public int getMaxWaitTimeInMillis() { 159 return Integer.parseInt(ra.getAttributeValue("max-wait-time-in-millis")); } 161 162 public void setIdleTimeoutInSeconds(int newVal) throws PropertyVetoException { 163 String attrName = "idle-timeout-in-seconds"; String propName = PROPNAME_IDLETIMEOUTINSECONDS; 165 doAttrSetProcessing(ra, newVal,attrName, propName); 166 } 167 168 public int getIdleTimeoutInSeconds() { 169 return Integer.parseInt(ra.getAttributeValue("idle-timeout-in-seconds")); } 171 172 public void setRoleMap(RoleMapElement newVal) throws PropertyVetoException { 173 RoleMapElement oldVal = roleMap; 176 fireMyVetoableChange("roleMap", oldVal, newVal); roleMap = newVal; 178 fileBean.setRoleMap(newVal.getRoleMap()); 179 fireMyPropertyChange("roleMap", oldVal, newVal); } 181 182 public RoleMapElement getRoleMap() { 183 return roleMap; 184 } 185 186 public void setPropertyElements(PropertyElements newVal) throws PropertyVetoException { 187 PropertyElements oldVal = propertyElements; 191 fireMyVetoableChange("propertyElements", oldVal, newVal); propertyElements = newVal; 193 ra = newVal.getResourceAdapter(); 194 fileBean.setResourceAdapter(ra); 195 fireMyPropertyChange("propertyElements", oldVal, newVal); } 197 198 public PropertyElements getPropertyElements() { 199 return propertyElements; 201 } 202 203 public void outTo(java.io.OutputStream os) throws java.io.IOException { 204 fileBean.write(os); 205 } 206 207 static public void main (String [] args) { 208 try { 209 IasConnectorOneZero bean = new IasConnectorOneZero(null); 210 bean.outTo(System.out); bean.setDescription("test setDescription"); bean.setIdleTimeoutInSeconds(1); 213 bean.setJndiName("testSetJndiName"); bean.setMaxPoolSize(2); 215 bean.setMaxWaitTimeInMillis(-3); 216 bean.setSteadyPoolSize(4); 217 bean.outTo(System.out); } 219 catch (Throwable t) { 220 t.printStackTrace(); 221 } 222 } 223 224 public SunConnector getSunConnector(){ 225 return fileBean; 226 } 227 } 228 | Popular Tags |