1 23 24 29 30 package com.sun.enterprise.tools.common.dd.ejb; 31 32 import org.w3c.dom.*; 33 import org.netbeans.modules.schema2beans.*; 34 import java.beans.*; 35 import java.util.*; 36 import com.sun.enterprise.tools.common.dd.DefaultResourcePrincipal; 37 38 40 public class CmpResource extends com.sun.enterprise.tools.common.dd.SunBaseBean 41 { 42 43 static Vector comparators = new Vector(); 44 45 static public final String JNDI_NAME = "JndiName"; static public final String DEFAULT_RESOURCE_PRINCIPAL = "DefaultResourcePrincipal"; static public final String PROPERTY = "PropertyElement"; static public final String CREATE_TABLES_AT_DEPLOY = "CreateTablesAtDeploy"; static public final String DROP_TABLES_AT_UNDEPLOY = "DropTablesAtUndeploy"; static public final String DATABASE_VENDOR_NAME = "DatabaseVendorName"; static public final String SCHEMA_GENERATOR_PROPERTIES = "SchemaGeneratorProperties"; 53 public CmpResource() { 54 this(Common.USE_DEFAULT_VALUES); 55 } 56 57 public CmpResource(int options) 58 { 59 super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0)); 60 this.createProperty("jndi-name", JNDI_NAME, 63 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 64 String .class); 65 this.createProperty("default-resource-principal", DEFAULT_RESOURCE_PRINCIPAL, 67 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 68 DefaultResourcePrincipal.class); 69 this.createProperty("property", PROPERTY, 71 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 72 PropertyElement.class); 73 this.createProperty("create-tables-at-deploy", CREATE_TABLES_AT_DEPLOY, 75 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 76 String .class); 77 this.createProperty("drop-tables-at-undeploy", DROP_TABLES_AT_UNDEPLOY, 79 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 80 String .class); 81 this.createProperty("database-vendor-name", DATABASE_VENDOR_NAME, 83 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 84 String .class); 85 this.createProperty("schema-generator-properties", SCHEMA_GENERATOR_PROPERTIES, 87 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 88 SchemaGeneratorProperties.class); 89 this.initialize(options); 90 } 91 92 void initialize(int options) 94 { 95 96 } 97 98 public void setJndiName(String value) { 100 this.setValue(JNDI_NAME, value); 101 } 102 103 public String getJndiName() { 105 return (String )this.getValue(JNDI_NAME); 106 } 107 108 public void setDefaultResourcePrincipal(DefaultResourcePrincipal value) { 110 this.setValue(DEFAULT_RESOURCE_PRINCIPAL, value); 111 } 112 113 public DefaultResourcePrincipal getDefaultResourcePrincipal() { 115 return (DefaultResourcePrincipal)this.getValue(DEFAULT_RESOURCE_PRINCIPAL); 116 } 117 118 public void setPropertyElement(int index, PropertyElement value) { 120 this.setValue(PROPERTY, index, value); 121 } 122 123 public PropertyElement getPropertyElement(int index) { 125 return (PropertyElement)this.getValue(PROPERTY, index); 126 } 127 128 public void setPropertyElement(PropertyElement[] value) { 130 this.setValue(PROPERTY, value); 131 } 132 133 public PropertyElement[] getPropertyElement() { 135 return (PropertyElement[])this.getValues(PROPERTY); 136 } 137 138 public int sizePropertyElement() { 140 return this.size(PROPERTY); 141 } 142 143 public int addPropertyElement(com.sun.enterprise.tools.common.dd.ejb.PropertyElement value) { 145 return this.addValue(PROPERTY, value); 146 } 147 148 public int removePropertyElement(com.sun.enterprise.tools.common.dd.ejb.PropertyElement value) { 153 return this.removeValue(PROPERTY, value); 154 } 155 156 public void setCreateTablesAtDeploy(String value) { 158 this.setValue(CREATE_TABLES_AT_DEPLOY, value); 159 } 160 161 public String getCreateTablesAtDeploy() { 163 return (String )this.getValue(CREATE_TABLES_AT_DEPLOY); 164 } 165 166 public void setDropTablesAtUndeploy(String value) { 168 this.setValue(DROP_TABLES_AT_UNDEPLOY, value); 169 } 170 171 public String getDropTablesAtUndeploy() { 173 return (String )this.getValue(DROP_TABLES_AT_UNDEPLOY); 174 } 175 176 public void setDatabaseVendorName(String value) { 178 this.setValue(DATABASE_VENDOR_NAME, value); 179 } 180 181 public String getDatabaseVendorName() { 183 return (String )this.getValue(DATABASE_VENDOR_NAME); 184 } 185 186 public void setSchemaGeneratorProperties(SchemaGeneratorProperties value) { 188 this.setValue(SCHEMA_GENERATOR_PROPERTIES, value); 189 } 190 191 public SchemaGeneratorProperties getSchemaGeneratorProperties() { 193 return (SchemaGeneratorProperties)this.getValue(SCHEMA_GENERATOR_PROPERTIES); 194 } 195 196 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 198 comparators.add(c); 199 } 200 201 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 203 comparators.remove(c); 204 } 205 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 206 boolean restrictionFailure = false; 207 if (getJndiName() == null) { 209 throw new org.netbeans.modules.schema2beans.ValidateException("getJndiName() == null", "jndiName", this); } 211 if (getDefaultResourcePrincipal() != null) { 213 getDefaultResourcePrincipal().validate(); 214 } 215 for (int _index = 0; _index < sizePropertyElement(); ++_index) { 217 com.sun.enterprise.tools.common.dd.ejb.PropertyElement element = getPropertyElement(_index); 218 if (element != null) { 219 element.validate(); 220 } 221 } 222 if (getCreateTablesAtDeploy() != null) { 224 } 225 if (getDropTablesAtUndeploy() != null) { 227 } 228 if (getDatabaseVendorName() != null) { 230 } 231 if (getSchemaGeneratorProperties() != null) { 233 getSchemaGeneratorProperties().validate(); 234 } 235 } 236 237 public void dump(StringBuffer str, String indent){ 239 String s; 240 Object o; 241 org.netbeans.modules.schema2beans.BaseBean n; 242 str.append(indent); 243 str.append("JndiName"); str.append(indent+"\t"); str.append("<"); s = this.getJndiName(); 247 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(JNDI_NAME, 0, str, indent); 250 251 str.append(indent); 252 str.append("DefaultResourcePrincipal"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getDefaultResourcePrincipal(); 254 if (n != null) 255 n.dump(str, indent + "\t"); else 257 str.append(indent+"\tnull"); this.dumpAttributes(DEFAULT_RESOURCE_PRINCIPAL, 0, str, indent); 259 260 str.append(indent); 261 str.append("PropertyElement["+this.sizePropertyElement()+"]"); for(int i=0; i<this.sizePropertyElement(); i++) 263 { 264 str.append(indent+"\t"); 265 str.append("#"+i+":"); 266 n = (org.netbeans.modules.schema2beans.BaseBean) this.getPropertyElement(i); 267 if (n != null) 268 n.dump(str, indent + "\t"); else 270 str.append(indent+"\tnull"); this.dumpAttributes(PROPERTY, i, str, indent); 272 } 273 274 str.append(indent); 275 str.append("CreateTablesAtDeploy"); str.append(indent+"\t"); str.append("<"); s = this.getCreateTablesAtDeploy(); 279 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(CREATE_TABLES_AT_DEPLOY, 0, str, indent); 282 283 str.append(indent); 284 str.append("DropTablesAtUndeploy"); str.append(indent+"\t"); str.append("<"); s = this.getDropTablesAtUndeploy(); 288 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(DROP_TABLES_AT_UNDEPLOY, 0, str, indent); 291 292 str.append(indent); 293 str.append("DatabaseVendorName"); str.append(indent+"\t"); str.append("<"); s = this.getDatabaseVendorName(); 297 str.append((s==null?"null":s.trim())); str.append(">\n"); this.dumpAttributes(DATABASE_VENDOR_NAME, 0, str, indent); 300 301 str.append(indent); 302 str.append("SchemaGeneratorProperties"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getSchemaGeneratorProperties(); 304 if (n != null) 305 n.dump(str, indent + "\t"); else 307 str.append(indent+"\tnull"); this.dumpAttributes(SCHEMA_GENERATOR_PROPERTIES, 0, str, indent); 309 310 } 311 public String dumpBeanNode(){ 312 StringBuffer str = new StringBuffer (); 313 str.append("CmpResource\n"); this.dump(str, "\n "); return str.toString(); 316 }} 317 318 320 321 1165 | Popular Tags |