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 Resources 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 CUSTOM_RESOURCE = "CustomResource"; 50 static public final String EXTERNAL_JNDI_RESOURCE = "ExternalJndiResource"; 51 static public final String JDBC_RESOURCE = "JdbcResource"; 52 static public final String MAIL_RESOURCE = "MailResource"; 53 static public final String PERSISTENCE_MANAGER_FACTORY_RESOURCE = "PersistenceManagerFactoryResource"; 54 static public final String ADMIN_OBJECT_RESOURCE = "AdminObjectResource"; 55 static public final String CONNECTOR_RESOURCE = "ConnectorResource"; 56 static public final String RESOURCE_ADAPTER_CONFIG = "ResourceAdapterConfig"; 57 static public final String JDBC_CONNECTION_POOL = "JdbcConnectionPool"; 58 static public final String CONNECTOR_CONNECTION_POOL = "ConnectorConnectionPool"; 59 60 public Resources() { 61 this(Common.USE_DEFAULT_VALUES); 62 } 63 64 public Resources(int options) 65 { 66 super(comparators, runtimeVersion); 67 initPropertyTables(10); 69 this.createProperty("custom-resource", CUSTOM_RESOURCE, Common.SEQUENCE_OR | 70 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 71 CustomResource.class); 72 this.createAttribute(CUSTOM_RESOURCE, "jndi-name", "JndiName", 73 AttrProp.CDATA | AttrProp.REQUIRED, 74 null, null); 75 this.createAttribute(CUSTOM_RESOURCE, "res-type", "ResType", 76 AttrProp.CDATA | AttrProp.REQUIRED, 77 null, null); 78 this.createAttribute(CUSTOM_RESOURCE, "factory-class", "FactoryClass", 79 AttrProp.CDATA | AttrProp.REQUIRED, 80 null, null); 81 this.createAttribute(CUSTOM_RESOURCE, "object-type", "ObjectType", 82 AttrProp.CDATA, 83 null, "user"); 84 this.createAttribute(CUSTOM_RESOURCE, "enabled", "Enabled", 85 AttrProp.CDATA, 86 null, "true"); 87 this.createProperty("external-jndi-resource", EXTERNAL_JNDI_RESOURCE, Common.SEQUENCE_OR | 88 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 89 ExternalJndiResource.class); 90 this.createAttribute(EXTERNAL_JNDI_RESOURCE, "jndi-name", "JndiName", 91 AttrProp.CDATA | AttrProp.REQUIRED, 92 null, null); 93 this.createAttribute(EXTERNAL_JNDI_RESOURCE, "jndi-lookup-name", "JndiLookupName", 94 AttrProp.CDATA | AttrProp.REQUIRED, 95 null, null); 96 this.createAttribute(EXTERNAL_JNDI_RESOURCE, "res-type", "ResType", 97 AttrProp.CDATA | AttrProp.REQUIRED, 98 null, null); 99 this.createAttribute(EXTERNAL_JNDI_RESOURCE, "factory-class", "FactoryClass", 100 AttrProp.CDATA | AttrProp.REQUIRED, 101 null, null); 102 this.createAttribute(EXTERNAL_JNDI_RESOURCE, "object-type", "ObjectType", 103 AttrProp.CDATA, 104 null, "user"); 105 this.createAttribute(EXTERNAL_JNDI_RESOURCE, "enabled", "Enabled", 106 AttrProp.CDATA, 107 null, "true"); 108 this.createProperty("jdbc-resource", JDBC_RESOURCE, Common.SEQUENCE_OR | 109 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 110 JdbcResource.class); 111 this.createAttribute(JDBC_RESOURCE, "jndi-name", "JndiName", 112 AttrProp.CDATA | AttrProp.REQUIRED, 113 null, null); 114 this.createAttribute(JDBC_RESOURCE, "pool-name", "PoolName", 115 AttrProp.CDATA | AttrProp.REQUIRED, 116 null, null); 117 this.createAttribute(JDBC_RESOURCE, "object-type", "ObjectType", 118 AttrProp.CDATA, 119 null, "user"); 120 this.createAttribute(JDBC_RESOURCE, "enabled", "Enabled", 121 AttrProp.CDATA, 122 null, "true"); 123 this.createProperty("mail-resource", MAIL_RESOURCE, Common.SEQUENCE_OR | 124 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 125 MailResource.class); 126 this.createAttribute(MAIL_RESOURCE, "jndi-name", "JndiName", 127 AttrProp.CDATA | AttrProp.REQUIRED, 128 null, null); 129 this.createAttribute(MAIL_RESOURCE, "store-protocol", "StoreProtocol", 130 AttrProp.CDATA, 131 null, "imap"); 132 this.createAttribute(MAIL_RESOURCE, "store-protocol-class", "StoreProtocolClass", 133 AttrProp.CDATA, 134 null, "com.sun.mail.imap.IMAPStore"); 135 this.createAttribute(MAIL_RESOURCE, "transport-protocol", "TransportProtocol", 136 AttrProp.CDATA, 137 null, "smtp"); 138 this.createAttribute(MAIL_RESOURCE, "transport-protocol-class", "TransportProtocolClass", 139 AttrProp.CDATA, 140 null, "com.sun.mail.smtp.SMTPTransport"); 141 this.createAttribute(MAIL_RESOURCE, "host", "Host", 142 AttrProp.CDATA | AttrProp.REQUIRED, 143 null, null); 144 this.createAttribute(MAIL_RESOURCE, "user", "User", 145 AttrProp.CDATA | AttrProp.REQUIRED, 146 null, null); 147 this.createAttribute(MAIL_RESOURCE, "from", "From", 148 AttrProp.CDATA | AttrProp.REQUIRED, 149 null, null); 150 this.createAttribute(MAIL_RESOURCE, "debug", "Debug", 151 AttrProp.CDATA, 152 null, "false"); 153 this.createAttribute(MAIL_RESOURCE, "object-type", "ObjectType", 154 AttrProp.CDATA, 155 null, "user"); 156 this.createAttribute(MAIL_RESOURCE, "enabled", "Enabled", 157 AttrProp.CDATA, 158 null, "true"); 159 this.createProperty("persistence-manager-factory-resource", PERSISTENCE_MANAGER_FACTORY_RESOURCE, Common.SEQUENCE_OR | 160 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 161 PersistenceManagerFactoryResource.class); 162 this.createAttribute(PERSISTENCE_MANAGER_FACTORY_RESOURCE, "jndi-name", "JndiName", 163 AttrProp.CDATA | AttrProp.REQUIRED, 164 null, null); 165 this.createAttribute(PERSISTENCE_MANAGER_FACTORY_RESOURCE, "factory-class", "FactoryClass", 166 AttrProp.CDATA, 167 null, "com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpl"); 168 this.createAttribute(PERSISTENCE_MANAGER_FACTORY_RESOURCE, "jdbc-resource-jndi-name", "JdbcResourceJndiName", 169 AttrProp.CDATA | AttrProp.IMPLIED, 170 null, null); 171 this.createAttribute(PERSISTENCE_MANAGER_FACTORY_RESOURCE, "object-type", "ObjectType", 172 AttrProp.CDATA, 173 null, "user"); 174 this.createAttribute(PERSISTENCE_MANAGER_FACTORY_RESOURCE, "enabled", "Enabled", 175 AttrProp.CDATA, 176 null, "true"); 177 this.createProperty("admin-object-resource", ADMIN_OBJECT_RESOURCE, Common.SEQUENCE_OR | 178 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 179 AdminObjectResource.class); 180 this.createAttribute(ADMIN_OBJECT_RESOURCE, "jndi-name", "JndiName", 181 AttrProp.CDATA | AttrProp.REQUIRED, 182 null, null); 183 this.createAttribute(ADMIN_OBJECT_RESOURCE, "res-type", "ResType", 184 AttrProp.CDATA | AttrProp.REQUIRED, 185 null, null); 186 this.createAttribute(ADMIN_OBJECT_RESOURCE, "res-adapter", "ResAdapter", 187 AttrProp.CDATA | AttrProp.REQUIRED, 188 null, null); 189 this.createAttribute(ADMIN_OBJECT_RESOURCE, "object-type", "ObjectType", 190 AttrProp.CDATA, 191 null, "user"); 192 this.createAttribute(ADMIN_OBJECT_RESOURCE, "enabled", "Enabled", 193 AttrProp.CDATA, 194 null, "true"); 195 this.createProperty("connector-resource", CONNECTOR_RESOURCE, Common.SEQUENCE_OR | 196 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 197 ConnectorResource.class); 198 this.createAttribute(CONNECTOR_RESOURCE, "jndi-name", "JndiName", 199 AttrProp.CDATA | AttrProp.REQUIRED, 200 null, null); 201 this.createAttribute(CONNECTOR_RESOURCE, "pool-name", "PoolName", 202 AttrProp.CDATA | AttrProp.REQUIRED, 203 null, null); 204 this.createAttribute(CONNECTOR_RESOURCE, "object-type", "ObjectType", 205 AttrProp.CDATA, 206 null, "user"); 207 this.createAttribute(CONNECTOR_RESOURCE, "enabled", "Enabled", 208 AttrProp.CDATA, 209 null, "true"); 210 this.createProperty("resource-adapter-config", RESOURCE_ADAPTER_CONFIG, Common.SEQUENCE_OR | 211 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 212 ResourceAdapterConfig.class); 213 this.createAttribute(RESOURCE_ADAPTER_CONFIG, "name", "Name", 214 AttrProp.CDATA | AttrProp.IMPLIED, 215 null, null); 216 this.createAttribute(RESOURCE_ADAPTER_CONFIG, "thread-pool-ids", "ThreadPoolIds", 217 AttrProp.CDATA | AttrProp.IMPLIED, 218 null, null); 219 this.createAttribute(RESOURCE_ADAPTER_CONFIG, "object-type", "ObjectType", 220 AttrProp.CDATA, 221 null, "user"); 222 this.createAttribute(RESOURCE_ADAPTER_CONFIG, "resource-adapter-name", "ResourceAdapterName", 223 AttrProp.CDATA | AttrProp.REQUIRED, 224 null, null); 225 this.createProperty("jdbc-connection-pool", JDBC_CONNECTION_POOL, Common.SEQUENCE_OR | 226 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 227 JdbcConnectionPool.class); 228 this.createAttribute(JDBC_CONNECTION_POOL, "name", "Name", 229 AttrProp.CDATA | AttrProp.REQUIRED, 230 null, null); 231 this.createAttribute(JDBC_CONNECTION_POOL, "datasource-classname", "DatasourceClassname", 232 AttrProp.CDATA | AttrProp.REQUIRED, 233 null, null); 234 this.createAttribute(JDBC_CONNECTION_POOL, "res-type", "ResType", 235 AttrProp.CDATA | AttrProp.IMPLIED, 236 null, null); 237 this.createAttribute(JDBC_CONNECTION_POOL, "steady-pool-size", "SteadyPoolSize", 238 AttrProp.CDATA, 239 null, "8"); 240 this.createAttribute(JDBC_CONNECTION_POOL, "max-pool-size", "MaxPoolSize", 241 AttrProp.CDATA, 242 null, "32"); 243 this.createAttribute(JDBC_CONNECTION_POOL, "max-wait-time-in-millis", "MaxWaitTimeInMillis", 244 AttrProp.CDATA, 245 null, "60000"); 246 this.createAttribute(JDBC_CONNECTION_POOL, "pool-resize-quantity", "PoolResizeQuantity", 247 AttrProp.CDATA, 248 null, "2"); 249 this.createAttribute(JDBC_CONNECTION_POOL, "idle-timeout-in-seconds", "IdleTimeoutInSeconds", 250 AttrProp.CDATA, 251 null, "300"); 252 this.createAttribute(JDBC_CONNECTION_POOL, "transaction-isolation-level", "TransactionIsolationLevel", 253 AttrProp.CDATA | AttrProp.IMPLIED, 254 null, null); 255 this.createAttribute(JDBC_CONNECTION_POOL, "is-isolation-level-guaranteed", "IsIsolationLevelGuaranteed", 256 AttrProp.CDATA, 257 null, "true"); 258 this.createAttribute(JDBC_CONNECTION_POOL, "is-connection-validation-required", "IsConnectionValidationRequired", 259 AttrProp.CDATA, 260 null, "false"); 261 this.createAttribute(JDBC_CONNECTION_POOL, "connection-validation-method", "ConnectionValidationMethod", 262 AttrProp.CDATA, 263 null, "auto-commit"); 264 this.createAttribute(JDBC_CONNECTION_POOL, "validation-table-name", "ValidationTableName", 265 AttrProp.CDATA | AttrProp.IMPLIED, 266 null, null); 267 this.createAttribute(JDBC_CONNECTION_POOL, "fail-all-connections", "FailAllConnections", 268 AttrProp.CDATA, 269 null, "false"); 270 this.createAttribute(JDBC_CONNECTION_POOL, "non-transactional-connections", "NonTransactionalConnections", 271 AttrProp.CDATA, 272 null, "false"); 273 this.createAttribute(JDBC_CONNECTION_POOL, "allow-non-component-callers", "AllowNonComponentCallers", 274 AttrProp.CDATA, 275 null, "false"); 276 this.createProperty("connector-connection-pool", CONNECTOR_CONNECTION_POOL, Common.SEQUENCE_OR | 277 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 278 ConnectorConnectionPool.class); 279 this.createAttribute(CONNECTOR_CONNECTION_POOL, "name", "Name", 280 AttrProp.CDATA | AttrProp.REQUIRED, 281 null, null); 282 this.createAttribute(CONNECTOR_CONNECTION_POOL, "resource-adapter-name", "ResourceAdapterName", 283 AttrProp.CDATA | AttrProp.REQUIRED, 284 null, null); 285 this.createAttribute(CONNECTOR_CONNECTION_POOL, "connection-definition-name", "ConnectionDefinitionName", 286 AttrProp.CDATA | AttrProp.REQUIRED, 287 null, null); 288 this.createAttribute(CONNECTOR_CONNECTION_POOL, "steady-pool-size", "SteadyPoolSize", 289 AttrProp.CDATA, 290 null, "8"); 291 this.createAttribute(CONNECTOR_CONNECTION_POOL, "max-pool-size", "MaxPoolSize", 292 AttrProp.CDATA, 293 null, "32"); 294 this.createAttribute(CONNECTOR_CONNECTION_POOL, "max-wait-time-in-millis", "MaxWaitTimeInMillis", 295 AttrProp.CDATA, 296 null, "60000"); 297 this.createAttribute(CONNECTOR_CONNECTION_POOL, "pool-resize-quantity", "PoolResizeQuantity", 298 AttrProp.CDATA, 299 null, "2"); 300 this.createAttribute(CONNECTOR_CONNECTION_POOL, "idle-timeout-in-seconds", "IdleTimeoutInSeconds", 301 AttrProp.CDATA, 302 null, "300"); 303 this.createAttribute(CONNECTOR_CONNECTION_POOL, "fail-all-connections", "FailAllConnections", 304 AttrProp.CDATA, 305 null, "false"); 306 this.createAttribute(CONNECTOR_CONNECTION_POOL, "transaction-support", "TransactionSupport", 307 AttrProp.CDATA | AttrProp.IMPLIED, 308 null, null); 309 this.createAttribute(CONNECTOR_CONNECTION_POOL, "is-connection-validation-required", "IsConnectionValidationRequired", 310 AttrProp.CDATA, 311 null, "false"); 312 this.initialize(options); 313 } 314 315 void initialize(int options) { 317 318 } 319 320 public void setCustomResource(int index, CustomResource value) { 322 this.setValue(CUSTOM_RESOURCE, index, value); 323 } 324 325 public CustomResource getCustomResource(int index) { 327 return (CustomResource)this.getValue(CUSTOM_RESOURCE, index); 328 } 329 330 public void setCustomResource(CustomResource[] value) { 332 this.setValue(CUSTOM_RESOURCE, value); 333 } 334 335 public CustomResource[] getCustomResource() { 337 return (CustomResource[])this.getValues(CUSTOM_RESOURCE); 338 } 339 340 public int sizeCustomResource() { 342 return this.size(CUSTOM_RESOURCE); 343 } 344 345 public int addCustomResource(CustomResource value) 347 throws ConfigException{ 348 return addCustomResource(value, true); 349 } 350 351 public int addCustomResource(CustomResource value, boolean overwrite) 353 throws ConfigException{ 354 CustomResource old = getCustomResourceByJndiName(value.getJndiName()); 355 if(old != null) { 356 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "CustomResource")); 357 } 358 return this.addValue(CUSTOM_RESOURCE, value, overwrite); 359 } 360 361 public int removeCustomResource(CustomResource value){ 366 return this.removeValue(CUSTOM_RESOURCE, value); 367 } 368 369 public int removeCustomResource(CustomResource value, boolean overwrite) 375 throws StaleWriteConfigException{ 376 return this.removeValue(CUSTOM_RESOURCE, value, overwrite); 377 } 378 379 public CustomResource getCustomResourceByJndiName(String id) { 380 if (null != id) { id = id.trim(); } 381 CustomResource[] o = getCustomResource(); 382 if (o == null) return null; 383 384 for (int i=0; i < o.length; i++) { 385 if(o[i].getAttributeValue(Common.convertName(ServerTags.JNDI_NAME)).equals(id)) { 386 return o[i]; 387 } 388 } 389 390 return null; 391 392 } 393 public void setExternalJndiResource(int index, ExternalJndiResource value) { 395 this.setValue(EXTERNAL_JNDI_RESOURCE, index, value); 396 } 397 398 public ExternalJndiResource getExternalJndiResource(int index) { 400 return (ExternalJndiResource)this.getValue(EXTERNAL_JNDI_RESOURCE, index); 401 } 402 403 public void setExternalJndiResource(ExternalJndiResource[] value) { 405 this.setValue(EXTERNAL_JNDI_RESOURCE, value); 406 } 407 408 public ExternalJndiResource[] getExternalJndiResource() { 410 return (ExternalJndiResource[])this.getValues(EXTERNAL_JNDI_RESOURCE); 411 } 412 413 public int sizeExternalJndiResource() { 415 return this.size(EXTERNAL_JNDI_RESOURCE); 416 } 417 418 public int addExternalJndiResource(ExternalJndiResource value) 420 throws ConfigException{ 421 return addExternalJndiResource(value, true); 422 } 423 424 public int addExternalJndiResource(ExternalJndiResource value, boolean overwrite) 426 throws ConfigException{ 427 ExternalJndiResource old = getExternalJndiResourceByJndiName(value.getJndiName()); 428 if(old != null) { 429 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "ExternalJndiResource")); 430 } 431 return this.addValue(EXTERNAL_JNDI_RESOURCE, value, overwrite); 432 } 433 434 public int removeExternalJndiResource(ExternalJndiResource value){ 439 return this.removeValue(EXTERNAL_JNDI_RESOURCE, value); 440 } 441 442 public int removeExternalJndiResource(ExternalJndiResource value, boolean overwrite) 448 throws StaleWriteConfigException{ 449 return this.removeValue(EXTERNAL_JNDI_RESOURCE, value, overwrite); 450 } 451 452 public ExternalJndiResource getExternalJndiResourceByJndiName(String id) { 453 if (null != id) { id = id.trim(); } 454 ExternalJndiResource[] o = getExternalJndiResource(); 455 if (o == null) return null; 456 457 for (int i=0; i < o.length; i++) { 458 if(o[i].getAttributeValue(Common.convertName(ServerTags.JNDI_NAME)).equals(id)) { 459 return o[i]; 460 } 461 } 462 463 return null; 464 465 } 466 public void setJdbcResource(int index, JdbcResource value) { 468 this.setValue(JDBC_RESOURCE, index, value); 469 } 470 471 public JdbcResource getJdbcResource(int index) { 473 return (JdbcResource)this.getValue(JDBC_RESOURCE, index); 474 } 475 476 public void setJdbcResource(JdbcResource[] value) { 478 this.setValue(JDBC_RESOURCE, value); 479 } 480 481 public JdbcResource[] getJdbcResource() { 483 return (JdbcResource[])this.getValues(JDBC_RESOURCE); 484 } 485 486 public int sizeJdbcResource() { 488 return this.size(JDBC_RESOURCE); 489 } 490 491 public int addJdbcResource(JdbcResource value) 493 throws ConfigException{ 494 return addJdbcResource(value, true); 495 } 496 497 public int addJdbcResource(JdbcResource value, boolean overwrite) 499 throws ConfigException{ 500 JdbcResource old = getJdbcResourceByJndiName(value.getJndiName()); 501 if(old != null) { 502 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "JdbcResource")); 503 } 504 return this.addValue(JDBC_RESOURCE, value, overwrite); 505 } 506 507 public int removeJdbcResource(JdbcResource value){ 512 return this.removeValue(JDBC_RESOURCE, value); 513 } 514 515 public int removeJdbcResource(JdbcResource value, boolean overwrite) 521 throws StaleWriteConfigException{ 522 return this.removeValue(JDBC_RESOURCE, value, overwrite); 523 } 524 525 public JdbcResource getJdbcResourceByJndiName(String id) { 526 if (null != id) { id = id.trim(); } 527 JdbcResource[] o = getJdbcResource(); 528 if (o == null) return null; 529 530 for (int i=0; i < o.length; i++) { 531 if(o[i].getAttributeValue(Common.convertName(ServerTags.JNDI_NAME)).equals(id)) { 532 return o[i]; 533 } 534 } 535 536 return null; 537 538 } 539 public void setMailResource(int index, MailResource value) { 541 this.setValue(MAIL_RESOURCE, index, value); 542 } 543 544 public MailResource getMailResource(int index) { 546 return (MailResource)this.getValue(MAIL_RESOURCE, index); 547 } 548 549 public void setMailResource(MailResource[] value) { 551 this.setValue(MAIL_RESOURCE, value); 552 } 553 554 public MailResource[] getMailResource() { 556 return (MailResource[])this.getValues(MAIL_RESOURCE); 557 } 558 559 public int sizeMailResource() { 561 return this.size(MAIL_RESOURCE); 562 } 563 564 public int addMailResource(MailResource value) 566 throws ConfigException{ 567 return addMailResource(value, true); 568 } 569 570 public int addMailResource(MailResource value, boolean overwrite) 572 throws ConfigException{ 573 MailResource old = getMailResourceByJndiName(value.getJndiName()); 574 if(old != null) { 575 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "MailResource")); 576 } 577 return this.addValue(MAIL_RESOURCE, value, overwrite); 578 } 579 580 public int removeMailResource(MailResource value){ 585 return this.removeValue(MAIL_RESOURCE, value); 586 } 587 588 public int removeMailResource(MailResource value, boolean overwrite) 594 throws StaleWriteConfigException{ 595 return this.removeValue(MAIL_RESOURCE, value, overwrite); 596 } 597 598 public MailResource getMailResourceByJndiName(String id) { 599 if (null != id) { id = id.trim(); } 600 MailResource[] o = getMailResource(); 601 if (o == null) return null; 602 603 for (int i=0; i < o.length; i++) { 604 if(o[i].getAttributeValue(Common.convertName(ServerTags.JNDI_NAME)).equals(id)) { 605 return o[i]; 606 } 607 } 608 609 return null; 610 611 } 612 public void setPersistenceManagerFactoryResource(int index, PersistenceManagerFactoryResource value) { 614 this.setValue(PERSISTENCE_MANAGER_FACTORY_RESOURCE, index, value); 615 } 616 617 public PersistenceManagerFactoryResource getPersistenceManagerFactoryResource(int index) { 619 return (PersistenceManagerFactoryResource)this.getValue(PERSISTENCE_MANAGER_FACTORY_RESOURCE, index); 620 } 621 622 public void setPersistenceManagerFactoryResource(PersistenceManagerFactoryResource[] value) { 624 this.setValue(PERSISTENCE_MANAGER_FACTORY_RESOURCE, value); 625 } 626 627 public PersistenceManagerFactoryResource[] getPersistenceManagerFactoryResource() { 629 return (PersistenceManagerFactoryResource[])this.getValues(PERSISTENCE_MANAGER_FACTORY_RESOURCE); 630 } 631 632 public int sizePersistenceManagerFactoryResource() { 634 return this.size(PERSISTENCE_MANAGER_FACTORY_RESOURCE); 635 } 636 637 public int addPersistenceManagerFactoryResource(PersistenceManagerFactoryResource value) 639 throws ConfigException{ 640 return addPersistenceManagerFactoryResource(value, true); 641 } 642 643 public int addPersistenceManagerFactoryResource(PersistenceManagerFactoryResource value, boolean overwrite) 645 throws ConfigException{ 646 PersistenceManagerFactoryResource old = getPersistenceManagerFactoryResourceByJndiName(value.getJndiName()); 647 if(old != null) { 648 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "PersistenceManagerFactoryResource")); 649 } 650 return this.addValue(PERSISTENCE_MANAGER_FACTORY_RESOURCE, value, overwrite); 651 } 652 653 public int removePersistenceManagerFactoryResource(PersistenceManagerFactoryResource value){ 658 return this.removeValue(PERSISTENCE_MANAGER_FACTORY_RESOURCE, value); 659 } 660 661 public int removePersistenceManagerFactoryResource(PersistenceManagerFactoryResource value, boolean overwrite) 667 throws StaleWriteConfigException{ 668 return this.removeValue(PERSISTENCE_MANAGER_FACTORY_RESOURCE, value, overwrite); 669 } 670 671 public PersistenceManagerFactoryResource getPersistenceManagerFactoryResourceByJndiName(String id) { 672 if (null != id) { id = id.trim(); } 673 PersistenceManagerFactoryResource[] o = getPersistenceManagerFactoryResource(); 674 if (o == null) return null; 675 676 for (int i=0; i < o.length; i++) { 677 if(o[i].getAttributeValue(Common.convertName(ServerTags.JNDI_NAME)).equals(id)) { 678 return o[i]; 679 } 680 } 681 682 return null; 683 684 } 685 public void setAdminObjectResource(int index, AdminObjectResource value) { 687 this.setValue(ADMIN_OBJECT_RESOURCE, index, value); 688 } 689 690 public AdminObjectResource getAdminObjectResource(int index) { 692 return (AdminObjectResource)this.getValue(ADMIN_OBJECT_RESOURCE, index); 693 } 694 695 public void setAdminObjectResource(AdminObjectResource[] value) { 697 this.setValue(ADMIN_OBJECT_RESOURCE, value); 698 } 699 700 public AdminObjectResource[] getAdminObjectResource() { 702 return (AdminObjectResource[])this.getValues(ADMIN_OBJECT_RESOURCE); 703 } 704 705 public int sizeAdminObjectResource() { 707 return this.size(ADMIN_OBJECT_RESOURCE); 708 } 709 710 public int addAdminObjectResource(AdminObjectResource value) 712 throws ConfigException{ 713 return addAdminObjectResource(value, true); 714 } 715 716 public int addAdminObjectResource(AdminObjectResource value, boolean overwrite) 718 throws ConfigException{ 719 AdminObjectResource old = getAdminObjectResourceByJndiName(value.getJndiName()); 720 if(old != null) { 721 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "AdminObjectResource")); 722 } 723 return this.addValue(ADMIN_OBJECT_RESOURCE, value, overwrite); 724 } 725 726 public int removeAdminObjectResource(AdminObjectResource value){ 731 return this.removeValue(ADMIN_OBJECT_RESOURCE, value); 732 } 733 734 public int removeAdminObjectResource(AdminObjectResource value, boolean overwrite) 740 throws StaleWriteConfigException{ 741 return this.removeValue(ADMIN_OBJECT_RESOURCE, value, overwrite); 742 } 743 744 public AdminObjectResource getAdminObjectResourceByJndiName(String id) { 745 if (null != id) { id = id.trim(); } 746 AdminObjectResource[] o = getAdminObjectResource(); 747 if (o == null) return null; 748 749 for (int i=0; i < o.length; i++) { 750 if(o[i].getAttributeValue(Common.convertName(ServerTags.JNDI_NAME)).equals(id)) { 751 return o[i]; 752 } 753 } 754 755 return null; 756 757 } 758 public void setConnectorResource(int index, ConnectorResource value) { 760 this.setValue(CONNECTOR_RESOURCE, index, value); 761 } 762 763 public ConnectorResource getConnectorResource(int index) { 765 return (ConnectorResource)this.getValue(CONNECTOR_RESOURCE, index); 766 } 767 768 public void setConnectorResource(ConnectorResource[] value) { 770 this.setValue(CONNECTOR_RESOURCE, value); 771 } 772 773 public ConnectorResource[] getConnectorResource() { 775 return (ConnectorResource[])this.getValues(CONNECTOR_RESOURCE); 776 } 777 778 public int sizeConnectorResource() { 780 return this.size(CONNECTOR_RESOURCE); 781 } 782 783 public int addConnectorResource(ConnectorResource value) 785 throws ConfigException{ 786 return addConnectorResource(value, true); 787 } 788 789 public int addConnectorResource(ConnectorResource value, boolean overwrite) 791 throws ConfigException{ 792 ConnectorResource old = getConnectorResourceByJndiName(value.getJndiName()); 793 if(old != null) { 794 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "ConnectorResource")); 795 } 796 return this.addValue(CONNECTOR_RESOURCE, value, overwrite); 797 } 798 799 public int removeConnectorResource(ConnectorResource value){ 804 return this.removeValue(CONNECTOR_RESOURCE, value); 805 } 806 807 public int removeConnectorResource(ConnectorResource value, boolean overwrite) 813 throws StaleWriteConfigException{ 814 return this.removeValue(CONNECTOR_RESOURCE, value, overwrite); 815 } 816 817 public ConnectorResource getConnectorResourceByJndiName(String id) { 818 if (null != id) { id = id.trim(); } 819 ConnectorResource[] o = getConnectorResource(); 820 if (o == null) return null; 821 822 for (int i=0; i < o.length; i++) { 823 if(o[i].getAttributeValue(Common.convertName(ServerTags.JNDI_NAME)).equals(id)) { 824 return o[i]; 825 } 826 } 827 828 return null; 829 830 } 831 public void setResourceAdapterConfig(int index, ResourceAdapterConfig value) { 833 this.setValue(RESOURCE_ADAPTER_CONFIG, index, value); 834 } 835 836 public ResourceAdapterConfig getResourceAdapterConfig(int index) { 838 return (ResourceAdapterConfig)this.getValue(RESOURCE_ADAPTER_CONFIG, index); 839 } 840 841 public void setResourceAdapterConfig(ResourceAdapterConfig[] value) { 843 this.setValue(RESOURCE_ADAPTER_CONFIG, value); 844 } 845 846 public ResourceAdapterConfig[] getResourceAdapterConfig() { 848 return (ResourceAdapterConfig[])this.getValues(RESOURCE_ADAPTER_CONFIG); 849 } 850 851 public int sizeResourceAdapterConfig() { 853 return this.size(RESOURCE_ADAPTER_CONFIG); 854 } 855 856 public int addResourceAdapterConfig(ResourceAdapterConfig value) 858 throws ConfigException{ 859 return addResourceAdapterConfig(value, true); 860 } 861 862 public int addResourceAdapterConfig(ResourceAdapterConfig value, boolean overwrite) 864 throws ConfigException{ 865 ResourceAdapterConfig old = getResourceAdapterConfigByResourceAdapterName(value.getResourceAdapterName()); 866 if(old != null) { 867 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "ResourceAdapterConfig")); 868 } 869 return this.addValue(RESOURCE_ADAPTER_CONFIG, value, overwrite); 870 } 871 872 public int removeResourceAdapterConfig(ResourceAdapterConfig value){ 877 return this.removeValue(RESOURCE_ADAPTER_CONFIG, value); 878 } 879 880 public int removeResourceAdapterConfig(ResourceAdapterConfig value, boolean overwrite) 886 throws StaleWriteConfigException{ 887 return this.removeValue(RESOURCE_ADAPTER_CONFIG, value, overwrite); 888 } 889 890 public ResourceAdapterConfig getResourceAdapterConfigByResourceAdapterName(String id) { 891 if (null != id) { id = id.trim(); } 892 ResourceAdapterConfig[] o = getResourceAdapterConfig(); 893 if (o == null) return null; 894 895 for (int i=0; i < o.length; i++) { 896 if(o[i].getAttributeValue(Common.convertName(ServerTags.RESOURCE_ADAPTER_NAME)).equals(id)) { 897 return o[i]; 898 } 899 } 900 901 return null; 902 903 } 904 public void setJdbcConnectionPool(int index, JdbcConnectionPool value) { 906 this.setValue(JDBC_CONNECTION_POOL, index, value); 907 } 908 909 public JdbcConnectionPool getJdbcConnectionPool(int index) { 911 return (JdbcConnectionPool)this.getValue(JDBC_CONNECTION_POOL, index); 912 } 913 914 public void setJdbcConnectionPool(JdbcConnectionPool[] value) { 916 this.setValue(JDBC_CONNECTION_POOL, value); 917 } 918 919 public JdbcConnectionPool[] getJdbcConnectionPool() { 921 return (JdbcConnectionPool[])this.getValues(JDBC_CONNECTION_POOL); 922 } 923 924 public int sizeJdbcConnectionPool() { 926 return this.size(JDBC_CONNECTION_POOL); 927 } 928 929 public int addJdbcConnectionPool(JdbcConnectionPool value) 931 throws ConfigException{ 932 return addJdbcConnectionPool(value, true); 933 } 934 935 public int addJdbcConnectionPool(JdbcConnectionPool value, boolean overwrite) 937 throws ConfigException{ 938 JdbcConnectionPool old = getJdbcConnectionPoolByName(value.getName()); 939 if(old != null) { 940 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "JdbcConnectionPool")); 941 } 942 return this.addValue(JDBC_CONNECTION_POOL, value, overwrite); 943 } 944 945 public int removeJdbcConnectionPool(JdbcConnectionPool value){ 950 return this.removeValue(JDBC_CONNECTION_POOL, value); 951 } 952 953 public int removeJdbcConnectionPool(JdbcConnectionPool value, boolean overwrite) 959 throws StaleWriteConfigException{ 960 return this.removeValue(JDBC_CONNECTION_POOL, value, overwrite); 961 } 962 963 public JdbcConnectionPool getJdbcConnectionPoolByName(String id) { 964 if (null != id) { id = id.trim(); } 965 JdbcConnectionPool[] o = getJdbcConnectionPool(); 966 if (o == null) return null; 967 968 for (int i=0; i < o.length; i++) { 969 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 970 return o[i]; 971 } 972 } 973 974 return null; 975 976 } 977 public void setConnectorConnectionPool(int index, ConnectorConnectionPool value) { 979 this.setValue(CONNECTOR_CONNECTION_POOL, index, value); 980 } 981 982 public ConnectorConnectionPool getConnectorConnectionPool(int index) { 984 return (ConnectorConnectionPool)this.getValue(CONNECTOR_CONNECTION_POOL, index); 985 } 986 987 public void setConnectorConnectionPool(ConnectorConnectionPool[] value) { 989 this.setValue(CONNECTOR_CONNECTION_POOL, value); 990 } 991 992 public ConnectorConnectionPool[] getConnectorConnectionPool() { 994 return (ConnectorConnectionPool[])this.getValues(CONNECTOR_CONNECTION_POOL); 995 } 996 997 public int sizeConnectorConnectionPool() { 999 return this.size(CONNECTOR_CONNECTION_POOL); 1000 } 1001 1002 public int addConnectorConnectionPool(ConnectorConnectionPool value) 1004 throws ConfigException{ 1005 return addConnectorConnectionPool(value, true); 1006 } 1007 1008 public int addConnectorConnectionPool(ConnectorConnectionPool value, boolean overwrite) 1010 throws ConfigException{ 1011 ConnectorConnectionPool old = getConnectorConnectionPoolByName(value.getName()); 1012 if(old != null) { 1013 throw new ConfigException(StringManager.getManager(Resources.class).getString("cannotAddDuplicate", "ConnectorConnectionPool")); 1014 } 1015 return this.addValue(CONNECTOR_CONNECTION_POOL, value, overwrite); 1016 } 1017 1018 public int removeConnectorConnectionPool(ConnectorConnectionPool value){ 1023 return this.removeValue(CONNECTOR_CONNECTION_POOL, value); 1024 } 1025 1026 public int removeConnectorConnectionPool(ConnectorConnectionPool value, boolean overwrite) 1032 throws StaleWriteConfigException{ 1033 return this.removeValue(CONNECTOR_CONNECTION_POOL, value, overwrite); 1034 } 1035 1036 public ConnectorConnectionPool getConnectorConnectionPoolByName(String id) { 1037 if (null != id) { id = id.trim(); } 1038 ConnectorConnectionPool[] o = getConnectorConnectionPool(); 1039 if (o == null) return null; 1040 1041 for (int i=0; i < o.length; i++) { 1042 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 1043 return o[i]; 1044 } 1045 } 1046 1047 return null; 1048 1049 } 1050 1054 public CustomResource newCustomResource() { 1055 return new CustomResource(); 1056 } 1057 1058 1062 public ExternalJndiResource newExternalJndiResource() { 1063 return new ExternalJndiResource(); 1064 } 1065 1066 1070 public JdbcResource newJdbcResource() { 1071 return new JdbcResource(); 1072 } 1073 1074 1078 public MailResource newMailResource() { 1079 return new MailResource(); 1080 } 1081 1082 1086 public PersistenceManagerFactoryResource newPersistenceManagerFactoryResource() { 1087 return new PersistenceManagerFactoryResource(); 1088 } 1089 1090 1094 public AdminObjectResource newAdminObjectResource() { 1095 return new AdminObjectResource(); 1096 } 1097 1098 1102 public ConnectorResource newConnectorResource() { 1103 return new ConnectorResource(); 1104 } 1105 1106 1110 public ResourceAdapterConfig newResourceAdapterConfig() { 1111 return new ResourceAdapterConfig(); 1112 } 1113 1114 1118 public JdbcConnectionPool newJdbcConnectionPool() { 1119 return new JdbcConnectionPool(); 1120 } 1121 1122 1126 public ConnectorConnectionPool newConnectorConnectionPool() { 1127 return new ConnectorConnectionPool(); 1128 } 1129 1130 1135 protected String getRelativeXPath() { 1136 String ret = null; 1137 ret = "resources"; 1138 return (null != ret ? ret.trim() : null); 1139 } 1140 1141 1144 public static String getDefaultAttributeValue(String attr) { 1145 if(attr == null) return null; 1146 attr = attr.trim(); 1147 return null; 1148 } 1149 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 1151 comparators.add(c); 1152 } 1153 1154 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 1156 comparators.remove(c); 1157 } 1158 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 1159 } 1160 1161 public void dump(StringBuffer str, String indent){ 1163 String s; 1164 Object o; 1165 org.netbeans.modules.schema2beans.BaseBean n; 1166 str.append(indent); 1167 str.append("CustomResource["+this.sizeCustomResource()+"]"); for(int i=0; i<this.sizeCustomResource(); i++) 1169 { 1170 str.append(indent+"\t"); 1171 str.append("#"+i+":"); 1172 n = (org.netbeans.modules.schema2beans.BaseBean) this.getCustomResource(i); 1173 if (n != null) 1174 n.dump(str, indent + "\t"); else 1176 str.append(indent+"\tnull"); this.dumpAttributes(CUSTOM_RESOURCE, i, str, indent); 1178 } 1179 1180 str.append(indent); 1181 str.append("ExternalJndiResource["+this.sizeExternalJndiResource()+"]"); for(int i=0; i<this.sizeExternalJndiResource(); i++) 1183 { 1184 str.append(indent+"\t"); 1185 str.append("#"+i+":"); 1186 n = (org.netbeans.modules.schema2beans.BaseBean) this.getExternalJndiResource(i); 1187 if (n != null) 1188 n.dump(str, indent + "\t"); else 1190 str.append(indent+"\tnull"); this.dumpAttributes(EXTERNAL_JNDI_RESOURCE, i, str, indent); 1192 } 1193 1194 str.append(indent); 1195 str.append("JdbcResource["+this.sizeJdbcResource()+"]"); for(int i=0; i<this.sizeJdbcResource(); i++) 1197 { 1198 str.append(indent+"\t"); 1199 str.append("#"+i+":"); 1200 n = (org.netbeans.modules.schema2beans.BaseBean) this.getJdbcResource(i); 1201 if (n != null) 1202 n.dump(str, indent + "\t"); else 1204 str.append(indent+"\tnull"); this.dumpAttributes(JDBC_RESOURCE, i, str, indent); 1206 } 1207 1208 str.append(indent); 1209 str.append("MailResource["+this.sizeMailResource()+"]"); for(int i=0; i<this.sizeMailResource(); i++) 1211 { 1212 str.append(indent+"\t"); 1213 str.append("#"+i+":"); 1214 n = (org.netbeans.modules.schema2beans.BaseBean) this.getMailResource(i); 1215 if (n != null) 1216 n.dump(str, indent + "\t"); else 1218 str.append(indent+"\tnull"); this.dumpAttributes(MAIL_RESOURCE, i, str, indent); 1220 } 1221 1222 str.append(indent); 1223 str.append("PersistenceManagerFactoryResource["+this.sizePersistenceManagerFactoryResource()+"]"); for(int i=0; i<this.sizePersistenceManagerFactoryResource(); i++) 1225 { 1226 str.append(indent+"\t"); 1227 str.append("#"+i+":"); 1228 n = (org.netbeans.modules.schema2beans.BaseBean) this.getPersistenceManagerFactoryResource(i); 1229 if (n != null) 1230 n.dump(str, indent + "\t"); else 1232 str.append(indent+"\tnull"); this.dumpAttributes(PERSISTENCE_MANAGER_FACTORY_RESOURCE, i, str, indent); 1234 } 1235 1236 str.append(indent); 1237 str.append("AdminObjectResource["+this.sizeAdminObjectResource()+"]"); for(int i=0; i<this.sizeAdminObjectResource(); i++) 1239 { 1240 str.append(indent+"\t"); 1241 str.append("#"+i+":"); 1242 n = (org.netbeans.modules.schema2beans.BaseBean) this.getAdminObjectResource(i); 1243 if (n != null) 1244 n.dump(str, indent + "\t"); else 1246 str.append(indent+"\tnull"); this.dumpAttributes(ADMIN_OBJECT_RESOURCE, i, str, indent); 1248 } 1249 1250 str.append(indent); 1251 str.append("ConnectorResource["+this.sizeConnectorResource()+"]"); for(int i=0; i<this.sizeConnectorResource(); i++) 1253 { 1254 str.append(indent+"\t"); 1255 str.append("#"+i+":"); 1256 n = (org.netbeans.modules.schema2beans.BaseBean) this.getConnectorResource(i); 1257 if (n != null) 1258 n.dump(str, indent + "\t"); else 1260 str.append(indent+"\tnull"); this.dumpAttributes(CONNECTOR_RESOURCE, i, str, indent); 1262 } 1263 1264 str.append(indent); 1265 str.append("ResourceAdapterConfig["+this.sizeResourceAdapterConfig()+"]"); for(int i=0; i<this.sizeResourceAdapterConfig(); i++) 1267 { 1268 str.append(indent+"\t"); 1269 str.append("#"+i+":"); 1270 n = (org.netbeans.modules.schema2beans.BaseBean) this.getResourceAdapterConfig(i); 1271 if (n != null) 1272 n.dump(str, indent + "\t"); else 1274 str.append(indent+"\tnull"); this.dumpAttributes(RESOURCE_ADAPTER_CONFIG, i, str, indent); 1276 } 1277 1278 str.append(indent); 1279 str.append("JdbcConnectionPool["+this.sizeJdbcConnectionPool()+"]"); for(int i=0; i<this.sizeJdbcConnectionPool(); i++) 1281 { 1282 str.append(indent+"\t"); 1283 str.append("#"+i+":"); 1284 n = (org.netbeans.modules.schema2beans.BaseBean) this.getJdbcConnectionPool(i); 1285 if (n != null) 1286 n.dump(str, indent + "\t"); else 1288 str.append(indent+"\tnull"); this.dumpAttributes(JDBC_CONNECTION_POOL, i, str, indent); 1290 } 1291 1292 str.append(indent); 1293 str.append("ConnectorConnectionPool["+this.sizeConnectorConnectionPool()+"]"); for(int i=0; i<this.sizeConnectorConnectionPool(); i++) 1295 { 1296 str.append(indent+"\t"); 1297 str.append("#"+i+":"); 1298 n = (org.netbeans.modules.schema2beans.BaseBean) this.getConnectorConnectionPool(i); 1299 if (n != null) 1300 n.dump(str, indent + "\t"); else 1302 str.append(indent+"\tnull"); this.dumpAttributes(CONNECTOR_CONNECTION_POOL, i, str, indent); 1304 } 1305 1306 } 1307 public String dumpBeanNode(){ 1308 StringBuffer str = new StringBuffer (); 1309 str.append("Resources\n"); this.dump(str, "\n "); return str.toString(); 1312 }} 1313 1314 1316 | Popular Tags |