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 NodeAgents 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 NODE_AGENT = "NodeAgent"; 50 51 public NodeAgents() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public NodeAgents(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("node-agent", NODE_AGENT, 61 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 62 NodeAgent.class); 63 this.createAttribute(NODE_AGENT, "name", "Name", 64 AttrProp.CDATA | AttrProp.REQUIRED, 65 null, null); 66 this.createAttribute(NODE_AGENT, "system-jmx-connector-name", "SystemJmxConnectorName", 67 AttrProp.CDATA | AttrProp.IMPLIED, 68 null, null); 69 this.createAttribute(NODE_AGENT, "start-servers-in-startup", "StartServersInStartup", 70 AttrProp.CDATA, 71 null, "true"); 72 this.initialize(options); 73 } 74 75 void initialize(int options) { 77 78 } 79 80 public void setNodeAgent(int index, NodeAgent value) { 82 this.setValue(NODE_AGENT, index, value); 83 } 84 85 public NodeAgent getNodeAgent(int index) { 87 return (NodeAgent)this.getValue(NODE_AGENT, index); 88 } 89 90 public void setNodeAgent(NodeAgent[] value) { 92 this.setValue(NODE_AGENT, value); 93 } 94 95 public NodeAgent[] getNodeAgent() { 97 return (NodeAgent[])this.getValues(NODE_AGENT); 98 } 99 100 public int sizeNodeAgent() { 102 return this.size(NODE_AGENT); 103 } 104 105 public int addNodeAgent(NodeAgent value) 107 throws ConfigException{ 108 return addNodeAgent(value, true); 109 } 110 111 public int addNodeAgent(NodeAgent value, boolean overwrite) 113 throws ConfigException{ 114 NodeAgent old = getNodeAgentByName(value.getName()); 115 if(old != null) { 116 throw new ConfigException(StringManager.getManager(NodeAgents.class).getString("cannotAddDuplicate", "NodeAgent")); 117 } 118 return this.addValue(NODE_AGENT, value, overwrite); 119 } 120 121 public int removeNodeAgent(NodeAgent value){ 126 return this.removeValue(NODE_AGENT, value); 127 } 128 129 public int removeNodeAgent(NodeAgent value, boolean overwrite) 135 throws StaleWriteConfigException{ 136 return this.removeValue(NODE_AGENT, value, overwrite); 137 } 138 139 public NodeAgent getNodeAgentByName(String id) { 140 if (null != id) { id = id.trim(); } 141 NodeAgent[] o = getNodeAgent(); 142 if (o == null) return null; 143 144 for (int i=0; i < o.length; i++) { 145 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 146 return o[i]; 147 } 148 } 149 150 return null; 151 152 } 153 157 public NodeAgent newNodeAgent() { 158 return new NodeAgent(); 159 } 160 161 166 protected String getRelativeXPath() { 167 String ret = null; 168 ret = "node-agents"; 169 return (null != ret ? ret.trim() : null); 170 } 171 172 175 public static String getDefaultAttributeValue(String attr) { 176 if(attr == null) return null; 177 attr = attr.trim(); 178 return null; 179 } 180 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 182 comparators.add(c); 183 } 184 185 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 187 comparators.remove(c); 188 } 189 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 190 } 191 192 public void dump(StringBuffer str, String indent){ 194 String s; 195 Object o; 196 org.netbeans.modules.schema2beans.BaseBean n; 197 str.append(indent); 198 str.append("NodeAgent["+this.sizeNodeAgent()+"]"); for(int i=0; i<this.sizeNodeAgent(); i++) 200 { 201 str.append(indent+"\t"); 202 str.append("#"+i+":"); 203 n = (org.netbeans.modules.schema2beans.BaseBean) this.getNodeAgent(i); 204 if (n != null) 205 n.dump(str, indent + "\t"); else 207 str.append(indent+"\tnull"); this.dumpAttributes(NODE_AGENT, i, str, indent); 209 } 210 211 } 212 public String dumpBeanNode(){ 213 StringBuffer str = new StringBuffer (); 214 str.append("NodeAgents\n"); this.dump(str, "\n "); return str.toString(); 217 }} 218 219 221 | Popular Tags |