1 23 24 28 29 package com.sun.enterprise.config.serverbeans; 30 31 import org.w3c.dom.*; 32 import org.netbeans.modules.schema2beans.*; 33 import java.beans.*; 34 import java.util.*; 35 import java.io.Serializable ; 36 import com.sun.enterprise.config.ConfigBean; 37 import com.sun.enterprise.config.ConfigException; 38 import com.sun.enterprise.config.StaleWriteConfigException; 39 import com.sun.enterprise.util.i18n.StringManager; 40 41 43 public class AdminService extends ConfigBean implements Serializable 44 { 45 46 static Vector comparators = new Vector(); 47 private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0); 48 49 static public final String JMX_CONNECTOR = "JmxConnector"; 50 static public final String DAS_CONFIG = "DasConfig"; 51 static public final String ELEMENT_PROPERTY = "ElementProperty"; 52 53 public AdminService() { 54 this(Common.USE_DEFAULT_VALUES); 55 } 56 57 public AdminService(int options) 58 { 59 super(comparators, runtimeVersion); 60 initPropertyTables(3); 62 this.createProperty("jmx-connector", JMX_CONNECTOR, 63 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 64 JmxConnector.class); 65 this.createAttribute(JMX_CONNECTOR, "name", "Name", 66 AttrProp.CDATA | AttrProp.REQUIRED, 67 null, null); 68 this.createAttribute(JMX_CONNECTOR, "enabled", "Enabled", 69 AttrProp.CDATA, 70 null, "true"); 71 this.createAttribute(JMX_CONNECTOR, "protocol", "Protocol", 72 AttrProp.CDATA, 73 null, "rmi_jrmp"); 74 this.createAttribute(JMX_CONNECTOR, "address", "Address", 75 AttrProp.CDATA | AttrProp.REQUIRED, 76 null, null); 77 this.createAttribute(JMX_CONNECTOR, "port", "Port", 78 AttrProp.CDATA | AttrProp.REQUIRED, 79 null, null); 80 this.createAttribute(JMX_CONNECTOR, "accept-all", "AcceptAll", 81 AttrProp.CDATA, 82 null, "false"); 83 this.createAttribute(JMX_CONNECTOR, "auth-realm-name", "AuthRealmName", 84 AttrProp.CDATA | AttrProp.REQUIRED, 85 null, null); 86 this.createAttribute(JMX_CONNECTOR, "security-enabled", "SecurityEnabled", 87 AttrProp.CDATA, 88 null, "true"); 89 this.createProperty("das-config", DAS_CONFIG, 90 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 91 DasConfig.class); 92 this.createAttribute(DAS_CONFIG, "dynamic-reload-enabled", "DynamicReloadEnabled", 93 AttrProp.CDATA, 94 null, "false"); 95 this.createAttribute(DAS_CONFIG, "dynamic-reload-poll-interval-in-seconds", "DynamicReloadPollIntervalInSeconds", 96 AttrProp.CDATA, 97 null, "2"); 98 this.createAttribute(DAS_CONFIG, "autodeploy-enabled", "AutodeployEnabled", 99 AttrProp.CDATA, 100 null, "false"); 101 this.createAttribute(DAS_CONFIG, "autodeploy-polling-interval-in-seconds", "AutodeployPollingIntervalInSeconds", 102 AttrProp.CDATA, 103 null, "2"); 104 this.createAttribute(DAS_CONFIG, "autodeploy-dir", "AutodeployDir", 105 AttrProp.CDATA, 106 null, "autodeploy"); 107 this.createAttribute(DAS_CONFIG, "autodeploy-verifier-enabled", "AutodeployVerifierEnabled", 108 AttrProp.CDATA, 109 null, "false"); 110 this.createAttribute(DAS_CONFIG, "autodeploy-jsp-precompilation-enabled", "AutodeployJspPrecompilationEnabled", 111 AttrProp.CDATA, 112 null, "false"); 113 this.createAttribute(DAS_CONFIG, "deploy-xml-validation", "DeployXmlValidation", 114 AttrProp.CDATA, 115 null, "full"); 116 this.createAttribute(DAS_CONFIG, "admin-session-timeout-in-minutes", "AdminSessionTimeoutInMinutes", 117 AttrProp.CDATA, 118 null, "60"); 119 this.createProperty("property", ELEMENT_PROPERTY, 120 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 121 ElementProperty.class); 122 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 123 AttrProp.CDATA | AttrProp.REQUIRED, 124 null, null); 125 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 126 AttrProp.CDATA | AttrProp.REQUIRED, 127 null, null); 128 this.initialize(options); 129 } 130 131 void initialize(int options) { 133 134 } 135 136 public void setJmxConnector(int index, JmxConnector value) { 138 this.setValue(JMX_CONNECTOR, index, value); 139 } 140 141 public JmxConnector getJmxConnector(int index) { 143 return (JmxConnector)this.getValue(JMX_CONNECTOR, index); 144 } 145 146 public void setJmxConnector(JmxConnector[] value) { 148 this.setValue(JMX_CONNECTOR, value); 149 } 150 151 public JmxConnector[] getJmxConnector() { 153 return (JmxConnector[])this.getValues(JMX_CONNECTOR); 154 } 155 156 public int sizeJmxConnector() { 158 return this.size(JMX_CONNECTOR); 159 } 160 161 public int addJmxConnector(JmxConnector value) 163 throws ConfigException{ 164 return addJmxConnector(value, true); 165 } 166 167 public int addJmxConnector(JmxConnector value, boolean overwrite) 169 throws ConfigException{ 170 JmxConnector old = getJmxConnectorByName(value.getName()); 171 if(old != null) { 172 throw new ConfigException(StringManager.getManager(AdminService.class).getString("cannotAddDuplicate", "JmxConnector")); 173 } 174 return this.addValue(JMX_CONNECTOR, value, overwrite); 175 } 176 177 public int removeJmxConnector(JmxConnector value){ 182 return this.removeValue(JMX_CONNECTOR, value); 183 } 184 185 public int removeJmxConnector(JmxConnector value, boolean overwrite) 191 throws StaleWriteConfigException{ 192 return this.removeValue(JMX_CONNECTOR, value, overwrite); 193 } 194 195 public JmxConnector getJmxConnectorByName(String id) { 196 if (null != id) { id = id.trim(); } 197 JmxConnector[] o = getJmxConnector(); 198 if (o == null) return null; 199 200 for (int i=0; i < o.length; i++) { 201 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 202 return o[i]; 203 } 204 } 205 206 return null; 207 208 } 209 public void setDasConfig(DasConfig value) { 211 this.setValue(DAS_CONFIG, value); 212 } 213 214 public DasConfig getDasConfig() { 216 return (DasConfig)this.getValue(DAS_CONFIG); 217 } 218 219 public void setElementProperty(int index, ElementProperty value) { 221 this.setValue(ELEMENT_PROPERTY, index, value); 222 } 223 224 public ElementProperty getElementProperty(int index) { 226 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 227 } 228 229 public void setElementProperty(ElementProperty[] value) { 231 this.setValue(ELEMENT_PROPERTY, value); 232 } 233 234 public ElementProperty[] getElementProperty() { 236 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 237 } 238 239 public int sizeElementProperty() { 241 return this.size(ELEMENT_PROPERTY); 242 } 243 244 public int addElementProperty(ElementProperty value) 246 throws ConfigException{ 247 return addElementProperty(value, true); 248 } 249 250 public int addElementProperty(ElementProperty value, boolean overwrite) 252 throws ConfigException{ 253 ElementProperty old = getElementPropertyByName(value.getName()); 254 if(old != null) { 255 throw new ConfigException(StringManager.getManager(AdminService.class).getString("cannotAddDuplicate", "ElementProperty")); 256 } 257 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 258 } 259 260 public int removeElementProperty(ElementProperty value){ 265 return this.removeValue(ELEMENT_PROPERTY, value); 266 } 267 268 public int removeElementProperty(ElementProperty value, boolean overwrite) 274 throws StaleWriteConfigException{ 275 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 276 } 277 278 public ElementProperty getElementPropertyByName(String id) { 279 if (null != id) { id = id.trim(); } 280 ElementProperty[] o = getElementProperty(); 281 if (o == null) return null; 282 283 for (int i=0; i < o.length; i++) { 284 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 285 return o[i]; 286 } 287 } 288 289 return null; 290 291 } 292 296 public String getType() { 297 return getAttributeValue(ServerTags.TYPE); 298 } 299 304 public void setType(String v, boolean overwrite) throws StaleWriteConfigException { 305 setAttributeValue(ServerTags.TYPE, v, overwrite); 306 } 307 311 public void setType(String v) { 312 setAttributeValue(ServerTags.TYPE, v); 313 } 314 317 public static String getDefaultType() { 318 return "server".trim(); 319 } 320 324 public String getSystemJmxConnectorName() { 325 return getAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME); 326 } 327 332 public void setSystemJmxConnectorName(String v, boolean overwrite) throws StaleWriteConfigException { 333 setAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME, v, overwrite); 334 } 335 339 public void setSystemJmxConnectorName(String v) { 340 setAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME, v); 341 } 342 346 public JmxConnector newJmxConnector() { 347 return new JmxConnector(); 348 } 349 350 354 public DasConfig newDasConfig() { 355 return new DasConfig(); 356 } 357 358 362 public ElementProperty newElementProperty() { 363 return new ElementProperty(); 364 } 365 366 371 protected String getRelativeXPath() { 372 String ret = null; 373 ret = "admin-service"; 374 return (null != ret ? ret.trim() : null); 375 } 376 377 380 public static String getDefaultAttributeValue(String attr) { 381 if(attr == null) return null; 382 attr = attr.trim(); 383 if(attr.equals(ServerTags.TYPE)) return "server".trim(); 384 return null; 385 } 386 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 388 comparators.add(c); 389 } 390 391 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 393 comparators.remove(c); 394 } 395 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 396 } 397 398 public void dump(StringBuffer str, String indent){ 400 String s; 401 Object o; 402 org.netbeans.modules.schema2beans.BaseBean n; 403 str.append(indent); 404 str.append("JmxConnector["+this.sizeJmxConnector()+"]"); for(int i=0; i<this.sizeJmxConnector(); i++) 406 { 407 str.append(indent+"\t"); 408 str.append("#"+i+":"); 409 n = (org.netbeans.modules.schema2beans.BaseBean) this.getJmxConnector(i); 410 if (n != null) 411 n.dump(str, indent + "\t"); else 413 str.append(indent+"\tnull"); this.dumpAttributes(JMX_CONNECTOR, i, str, indent); 415 } 416 417 str.append(indent); 418 str.append("DasConfig"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getDasConfig(); 420 if (n != null) 421 n.dump(str, indent + "\t"); else 423 str.append(indent+"\tnull"); this.dumpAttributes(DAS_CONFIG, 0, str, indent); 425 426 str.append(indent); 427 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 429 { 430 str.append(indent+"\t"); 431 str.append("#"+i+":"); 432 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 433 if (n != null) 434 n.dump(str, indent + "\t"); else 436 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 438 } 439 440 } 441 public String dumpBeanNode(){ 442 StringBuffer str = new StringBuffer (); 443 str.append("AdminService\n"); this.dump(str, "\n "); return str.toString(); 446 }} 447 448 450 | Popular Tags |