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 NodeAgent 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 AUTH_REALM = "AuthRealm"; 51 static public final String LOG_SERVICE = "LogService"; 52 static public final String ELEMENT_PROPERTY = "ElementProperty"; 53 54 public NodeAgent() { 55 this(Common.USE_DEFAULT_VALUES); 56 } 57 58 public NodeAgent(int options) 59 { 60 super(comparators, runtimeVersion); 61 initPropertyTables(4); 63 this.createProperty("jmx-connector", JMX_CONNECTOR, 64 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 65 JmxConnector.class); 66 this.createAttribute(JMX_CONNECTOR, "name", "Name", 67 AttrProp.CDATA | AttrProp.REQUIRED, 68 null, null); 69 this.createAttribute(JMX_CONNECTOR, "enabled", "Enabled", 70 AttrProp.CDATA, 71 null, "true"); 72 this.createAttribute(JMX_CONNECTOR, "protocol", "Protocol", 73 AttrProp.CDATA, 74 null, "rmi_jrmp"); 75 this.createAttribute(JMX_CONNECTOR, "address", "Address", 76 AttrProp.CDATA | AttrProp.REQUIRED, 77 null, null); 78 this.createAttribute(JMX_CONNECTOR, "port", "Port", 79 AttrProp.CDATA | AttrProp.REQUIRED, 80 null, null); 81 this.createAttribute(JMX_CONNECTOR, "accept-all", "AcceptAll", 82 AttrProp.CDATA, 83 null, "false"); 84 this.createAttribute(JMX_CONNECTOR, "auth-realm-name", "AuthRealmName", 85 AttrProp.CDATA | AttrProp.REQUIRED, 86 null, null); 87 this.createAttribute(JMX_CONNECTOR, "security-enabled", "SecurityEnabled", 88 AttrProp.CDATA, 89 null, "true"); 90 this.createProperty("auth-realm", AUTH_REALM, 91 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 92 AuthRealm.class); 93 this.createAttribute(AUTH_REALM, "name", "Name", 94 AttrProp.CDATA | AttrProp.REQUIRED, 95 null, null); 96 this.createAttribute(AUTH_REALM, "classname", "Classname", 97 AttrProp.CDATA | AttrProp.REQUIRED, 98 null, null); 99 this.createProperty("log-service", LOG_SERVICE, 100 Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 101 LogService.class); 102 this.createAttribute(LOG_SERVICE, "file", "File", 103 AttrProp.CDATA | AttrProp.IMPLIED, 104 null, null); 105 this.createAttribute(LOG_SERVICE, "use-system-logging", "UseSystemLogging", 106 AttrProp.CDATA, 107 null, "false"); 108 this.createAttribute(LOG_SERVICE, "log-handler", "LogHandler", 109 AttrProp.CDATA | AttrProp.IMPLIED, 110 null, null); 111 this.createAttribute(LOG_SERVICE, "log-filter", "LogFilter", 112 AttrProp.CDATA | AttrProp.IMPLIED, 113 null, null); 114 this.createAttribute(LOG_SERVICE, "log-to-console", "LogToConsole", 115 AttrProp.CDATA, 116 null, "false"); 117 this.createAttribute(LOG_SERVICE, "log-rotation-limit-in-bytes", "LogRotationLimitInBytes", 118 AttrProp.CDATA, 119 null, "500000"); 120 this.createAttribute(LOG_SERVICE, "log-rotation-timelimit-in-minutes", "LogRotationTimelimitInMinutes", 121 AttrProp.CDATA, 122 null, "0"); 123 this.createAttribute(LOG_SERVICE, "alarms", "Alarms", 124 AttrProp.CDATA, 125 null, "false"); 126 this.createAttribute(LOG_SERVICE, "retain-error-statistics-for-hours", "RetainErrorStatisticsForHours", 127 AttrProp.CDATA, 128 null, "5"); 129 this.createProperty("property", ELEMENT_PROPERTY, 130 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 131 ElementProperty.class); 132 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 133 AttrProp.CDATA | AttrProp.REQUIRED, 134 null, null); 135 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 136 AttrProp.CDATA | AttrProp.REQUIRED, 137 null, null); 138 this.initialize(options); 139 } 140 141 void initialize(int options) { 143 144 } 145 146 public void setJmxConnector(JmxConnector value) { 148 this.setValue(JMX_CONNECTOR, value); 149 } 150 151 public JmxConnector getJmxConnector() { 153 return (JmxConnector)this.getValue(JMX_CONNECTOR); 154 } 155 156 public void setAuthRealm(AuthRealm value) { 158 this.setValue(AUTH_REALM, value); 159 } 160 161 public AuthRealm getAuthRealm() { 163 return (AuthRealm)this.getValue(AUTH_REALM); 164 } 165 166 public void setLogService(LogService value) { 168 this.setValue(LOG_SERVICE, value); 169 } 170 171 public LogService getLogService() { 173 return (LogService)this.getValue(LOG_SERVICE); 174 } 175 176 public void setElementProperty(int index, ElementProperty value) { 178 this.setValue(ELEMENT_PROPERTY, index, value); 179 } 180 181 public ElementProperty getElementProperty(int index) { 183 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 184 } 185 186 public void setElementProperty(ElementProperty[] value) { 188 this.setValue(ELEMENT_PROPERTY, value); 189 } 190 191 public ElementProperty[] getElementProperty() { 193 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 194 } 195 196 public int sizeElementProperty() { 198 return this.size(ELEMENT_PROPERTY); 199 } 200 201 public int addElementProperty(ElementProperty value) 203 throws ConfigException{ 204 return addElementProperty(value, true); 205 } 206 207 public int addElementProperty(ElementProperty value, boolean overwrite) 209 throws ConfigException{ 210 ElementProperty old = getElementPropertyByName(value.getName()); 211 if(old != null) { 212 throw new ConfigException(StringManager.getManager(NodeAgent.class).getString("cannotAddDuplicate", "ElementProperty")); 213 } 214 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 215 } 216 217 public int removeElementProperty(ElementProperty value){ 222 return this.removeValue(ELEMENT_PROPERTY, value); 223 } 224 225 public int removeElementProperty(ElementProperty value, boolean overwrite) 231 throws StaleWriteConfigException{ 232 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 233 } 234 235 public ElementProperty getElementPropertyByName(String id) { 236 if (null != id) { id = id.trim(); } 237 ElementProperty[] o = getElementProperty(); 238 if (o == null) return null; 239 240 for (int i=0; i < o.length; i++) { 241 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 242 return o[i]; 243 } 244 } 245 246 return null; 247 248 } 249 253 public String getName() { 254 return getAttributeValue(ServerTags.NAME); 255 } 256 261 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 262 setAttributeValue(ServerTags.NAME, v, overwrite); 263 } 264 268 public void setName(String v) { 269 setAttributeValue(ServerTags.NAME, v); 270 } 271 275 public String getSystemJmxConnectorName() { 276 return getAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME); 277 } 278 283 public void setSystemJmxConnectorName(String v, boolean overwrite) throws StaleWriteConfigException { 284 setAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME, v, overwrite); 285 } 286 290 public void setSystemJmxConnectorName(String v) { 291 setAttributeValue(ServerTags.SYSTEM_JMX_CONNECTOR_NAME, v); 292 } 293 297 public boolean isStartServersInStartup() { 298 return toBoolean(getAttributeValue(ServerTags.START_SERVERS_IN_STARTUP)); 299 } 300 305 public void setStartServersInStartup(boolean v, boolean overwrite) throws StaleWriteConfigException { 306 setAttributeValue(ServerTags.START_SERVERS_IN_STARTUP, ""+(v==true), overwrite); 307 } 308 312 public void setStartServersInStartup(boolean v) { 313 setAttributeValue(ServerTags.START_SERVERS_IN_STARTUP, ""+(v==true)); 314 } 315 318 public static String getDefaultStartServersInStartup() { 319 return "true".trim(); 320 } 321 325 public JmxConnector newJmxConnector() { 326 return new JmxConnector(); 327 } 328 329 333 public AuthRealm newAuthRealm() { 334 return new AuthRealm(); 335 } 336 337 341 public LogService newLogService() { 342 return new LogService(); 343 } 344 345 349 public ElementProperty newElementProperty() { 350 return new ElementProperty(); 351 } 352 353 358 protected String getRelativeXPath() { 359 String ret = null; 360 ret = "node-agent" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 361 return (null != ret ? ret.trim() : null); 362 } 363 364 367 public static String getDefaultAttributeValue(String attr) { 368 if(attr == null) return null; 369 attr = attr.trim(); 370 if(attr.equals(ServerTags.START_SERVERS_IN_STARTUP)) return "true".trim(); 371 return null; 372 } 373 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 375 comparators.add(c); 376 } 377 378 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 380 comparators.remove(c); 381 } 382 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 383 } 384 385 public void dump(StringBuffer str, String indent){ 387 String s; 388 Object o; 389 org.netbeans.modules.schema2beans.BaseBean n; 390 str.append(indent); 391 str.append("JmxConnector"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getJmxConnector(); 393 if (n != null) 394 n.dump(str, indent + "\t"); else 396 str.append(indent+"\tnull"); this.dumpAttributes(JMX_CONNECTOR, 0, str, indent); 398 399 str.append(indent); 400 str.append("AuthRealm"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getAuthRealm(); 402 if (n != null) 403 n.dump(str, indent + "\t"); else 405 str.append(indent+"\tnull"); this.dumpAttributes(AUTH_REALM, 0, str, indent); 407 408 str.append(indent); 409 str.append("LogService"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getLogService(); 411 if (n != null) 412 n.dump(str, indent + "\t"); else 414 str.append(indent+"\tnull"); this.dumpAttributes(LOG_SERVICE, 0, str, indent); 416 417 str.append(indent); 418 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 420 { 421 str.append(indent+"\t"); 422 str.append("#"+i+":"); 423 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 424 if (n != null) 425 n.dump(str, indent + "\t"); else 427 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 429 } 430 431 } 432 public String dumpBeanNode(){ 433 StringBuffer str = new StringBuffer (); 434 str.append("NodeAgent\n"); this.dump(str, "\n "); return str.toString(); 437 }} 438 439 441 | Popular Tags |