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 JmxConnector 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 SSL = "Ssl"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public JmxConnector() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public JmxConnector(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("ssl", SSL, 62 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 63 Ssl.class); 64 this.createAttribute(SSL, "cert-nickname", "CertNickname", 65 AttrProp.CDATA | AttrProp.REQUIRED, 66 null, null); 67 this.createAttribute(SSL, "ssl2-enabled", "Ssl2Enabled", 68 AttrProp.CDATA, 69 null, "false"); 70 this.createAttribute(SSL, "ssl2-ciphers", "Ssl2Ciphers", 71 AttrProp.CDATA | AttrProp.IMPLIED, 72 null, null); 73 this.createAttribute(SSL, "ssl3-enabled", "Ssl3Enabled", 74 AttrProp.CDATA, 75 null, "true"); 76 this.createAttribute(SSL, "ssl3-tls-ciphers", "Ssl3TlsCiphers", 77 AttrProp.CDATA | AttrProp.IMPLIED, 78 null, null); 79 this.createAttribute(SSL, "tls-enabled", "TlsEnabled", 80 AttrProp.CDATA, 81 null, "true"); 82 this.createAttribute(SSL, "tls-rollback-enabled", "TlsRollbackEnabled", 83 AttrProp.CDATA, 84 null, "true"); 85 this.createAttribute(SSL, "client-auth-enabled", "ClientAuthEnabled", 86 AttrProp.CDATA, 87 null, "false"); 88 this.createProperty("property", ELEMENT_PROPERTY, 89 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 90 ElementProperty.class); 91 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 92 AttrProp.CDATA | AttrProp.REQUIRED, 93 null, null); 94 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 95 AttrProp.CDATA | AttrProp.REQUIRED, 96 null, null); 97 this.initialize(options); 98 } 99 100 void initialize(int options) { 102 103 } 104 105 public void setSsl(Ssl value) { 107 this.setValue(SSL, value); 108 } 109 110 public Ssl getSsl() { 112 return (Ssl)this.getValue(SSL); 113 } 114 115 public void setElementProperty(int index, ElementProperty value) { 117 this.setValue(ELEMENT_PROPERTY, index, value); 118 } 119 120 public ElementProperty getElementProperty(int index) { 122 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 123 } 124 125 public void setElementProperty(ElementProperty[] value) { 127 this.setValue(ELEMENT_PROPERTY, value); 128 } 129 130 public ElementProperty[] getElementProperty() { 132 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 133 } 134 135 public int sizeElementProperty() { 137 return this.size(ELEMENT_PROPERTY); 138 } 139 140 public int addElementProperty(ElementProperty value) 142 throws ConfigException{ 143 return addElementProperty(value, true); 144 } 145 146 public int addElementProperty(ElementProperty value, boolean overwrite) 148 throws ConfigException{ 149 ElementProperty old = getElementPropertyByName(value.getName()); 150 if(old != null) { 151 throw new ConfigException(StringManager.getManager(JmxConnector.class).getString("cannotAddDuplicate", "ElementProperty")); 152 } 153 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 154 } 155 156 public int removeElementProperty(ElementProperty value){ 161 return this.removeValue(ELEMENT_PROPERTY, value); 162 } 163 164 public int removeElementProperty(ElementProperty value, boolean overwrite) 170 throws StaleWriteConfigException{ 171 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 172 } 173 174 public ElementProperty getElementPropertyByName(String id) { 175 if (null != id) { id = id.trim(); } 176 ElementProperty[] o = getElementProperty(); 177 if (o == null) return null; 178 179 for (int i=0; i < o.length; i++) { 180 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 181 return o[i]; 182 } 183 } 184 185 return null; 186 187 } 188 192 public String getName() { 193 return getAttributeValue(ServerTags.NAME); 194 } 195 200 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 201 setAttributeValue(ServerTags.NAME, v, overwrite); 202 } 203 207 public void setName(String v) { 208 setAttributeValue(ServerTags.NAME, v); 209 } 210 214 public boolean isEnabled() { 215 return toBoolean(getAttributeValue(ServerTags.ENABLED)); 216 } 217 222 public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 223 setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite); 224 } 225 229 public void setEnabled(boolean v) { 230 setAttributeValue(ServerTags.ENABLED, ""+(v==true)); 231 } 232 235 public static String getDefaultEnabled() { 236 return "true".trim(); 237 } 238 242 public String getProtocol() { 243 return getAttributeValue(ServerTags.PROTOCOL); 244 } 245 250 public void setProtocol(String v, boolean overwrite) throws StaleWriteConfigException { 251 setAttributeValue(ServerTags.PROTOCOL, v, overwrite); 252 } 253 257 public void setProtocol(String v) { 258 setAttributeValue(ServerTags.PROTOCOL, v); 259 } 260 263 public static String getDefaultProtocol() { 264 return "rmi_jrmp".trim(); 265 } 266 270 public String getAddress() { 271 return getAttributeValue(ServerTags.ADDRESS); 272 } 273 278 public void setAddress(String v, boolean overwrite) throws StaleWriteConfigException { 279 setAttributeValue(ServerTags.ADDRESS, v, overwrite); 280 } 281 285 public void setAddress(String v) { 286 setAttributeValue(ServerTags.ADDRESS, v); 287 } 288 292 public String getPort() { 293 return getAttributeValue(ServerTags.PORT); 294 } 295 300 public void setPort(String v, boolean overwrite) throws StaleWriteConfigException { 301 setAttributeValue(ServerTags.PORT, v, overwrite); 302 } 303 307 public void setPort(String v) { 308 setAttributeValue(ServerTags.PORT, v); 309 } 310 314 public boolean isAcceptAll() { 315 return toBoolean(getAttributeValue(ServerTags.ACCEPT_ALL)); 316 } 317 322 public void setAcceptAll(boolean v, boolean overwrite) throws StaleWriteConfigException { 323 setAttributeValue(ServerTags.ACCEPT_ALL, ""+(v==true), overwrite); 324 } 325 329 public void setAcceptAll(boolean v) { 330 setAttributeValue(ServerTags.ACCEPT_ALL, ""+(v==true)); 331 } 332 335 public static String getDefaultAcceptAll() { 336 return "false".trim(); 337 } 338 342 public String getAuthRealmName() { 343 return getAttributeValue(ServerTags.AUTH_REALM_NAME); 344 } 345 350 public void setAuthRealmName(String v, boolean overwrite) throws StaleWriteConfigException { 351 setAttributeValue(ServerTags.AUTH_REALM_NAME, v, overwrite); 352 } 353 357 public void setAuthRealmName(String v) { 358 setAttributeValue(ServerTags.AUTH_REALM_NAME, v); 359 } 360 364 public boolean isSecurityEnabled() { 365 return toBoolean(getAttributeValue(ServerTags.SECURITY_ENABLED)); 366 } 367 372 public void setSecurityEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 373 setAttributeValue(ServerTags.SECURITY_ENABLED, ""+(v==true), overwrite); 374 } 375 379 public void setSecurityEnabled(boolean v) { 380 setAttributeValue(ServerTags.SECURITY_ENABLED, ""+(v==true)); 381 } 382 385 public static String getDefaultSecurityEnabled() { 386 return "true".trim(); 387 } 388 392 public Ssl newSsl() { 393 return new Ssl(); 394 } 395 396 400 public ElementProperty newElementProperty() { 401 return new ElementProperty(); 402 } 403 404 409 protected String getRelativeXPath() { 410 String ret = null; 411 ret = "jmx-connector" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 412 return (null != ret ? ret.trim() : null); 413 } 414 415 418 public static String getDefaultAttributeValue(String attr) { 419 if(attr == null) return null; 420 attr = attr.trim(); 421 if(attr.equals(ServerTags.ENABLED)) return "true".trim(); 422 if(attr.equals(ServerTags.PROTOCOL)) return "rmi_jrmp".trim(); 423 if(attr.equals(ServerTags.ACCEPT_ALL)) return "false".trim(); 424 if(attr.equals(ServerTags.SECURITY_ENABLED)) return "true".trim(); 425 return null; 426 } 427 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 429 comparators.add(c); 430 } 431 432 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 434 comparators.remove(c); 435 } 436 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 437 } 438 439 public void dump(StringBuffer str, String indent){ 441 String s; 442 Object o; 443 org.netbeans.modules.schema2beans.BaseBean n; 444 str.append(indent); 445 str.append("Ssl"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getSsl(); 447 if (n != null) 448 n.dump(str, indent + "\t"); else 450 str.append(indent+"\tnull"); this.dumpAttributes(SSL, 0, str, indent); 452 453 str.append(indent); 454 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 456 { 457 str.append(indent+"\t"); 458 str.append("#"+i+":"); 459 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 460 if (n != null) 461 n.dump(str, indent + "\t"); else 463 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 465 } 466 467 } 468 public String dumpBeanNode(){ 469 StringBuffer str = new StringBuffer (); 470 str.append("JmxConnector\n"); this.dump(str, "\n "); return str.toString(); 473 }} 474 475 477 | Popular Tags |