1 24 25 package org.objectweb.cjdbc.console.wizard; 26 27 import java.util.ArrayList ; 28 import java.util.Enumeration ; 29 import java.util.Hashtable ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 33 import javax.swing.JComboBox ; 34 import javax.swing.JTabbedPane ; 35 36 import org.dom4j.Document; 37 import org.dom4j.DocumentFactory; 38 import org.dom4j.DocumentType; 39 import org.dom4j.Element; 40 import org.dom4j.Node; 41 import org.objectweb.cjdbc.common.i18n.WizardTranslate; 42 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 43 import org.objectweb.cjdbc.console.wizard.listeners.WizardListener; 44 import org.objectweb.cjdbc.console.wizard.objects.Backend; 45 import org.objectweb.cjdbc.console.wizard.objects.ConnectionInfo; 46 import org.objectweb.cjdbc.console.wizard.objects.ConnectionTypeInfo; 47 import org.objectweb.cjdbc.console.wizard.objects.User; 48 import org.objectweb.cjdbc.console.wizard.tab.AuthenticationTab; 49 import org.objectweb.cjdbc.console.wizard.tab.BackendTab; 50 import org.objectweb.cjdbc.console.wizard.tab.CachingTab; 51 import org.objectweb.cjdbc.console.wizard.tab.DistributionTab; 52 import org.objectweb.cjdbc.console.wizard.tab.RecoveryTab; 53 import org.objectweb.cjdbc.console.wizard.tab.RequestManagerTab; 54 import org.objectweb.cjdbc.console.wizard.tab.VirtualDatabaseTab; 55 56 63 public class WizardTabs extends JTabbedPane implements WizardListener 64 { 65 66 private VirtualDatabaseTab virtualDatabaseTab; 67 private DistributionTab distributionTab; 68 private AuthenticationTab authenticationTab; 69 private BackendTab backendsTab; 70 private RequestManagerTab requestManagerTab; 71 private ArrayList tabs; 72 private CachingTab cachingTab; 73 private RecoveryTab recoveryTab; 74 75 78 public WizardTabs() 79 { 80 this.setVisible(true); 81 tabs = new ArrayList (); 82 83 virtualDatabaseTab = (VirtualDatabaseTab) this 84 .addTab(new VirtualDatabaseTab(this)); 85 authenticationTab = (AuthenticationTab) this.addTab(new AuthenticationTab( 86 this)); 87 backendsTab = (BackendTab) this.addTab(new BackendTab(this)); 88 requestManagerTab = (RequestManagerTab) this.addTab(new RequestManagerTab( 89 this)); 90 91 distributionTab = new DistributionTab(this); 92 cachingTab = new CachingTab(this); 93 recoveryTab = new RecoveryTab(this); 94 tabs.add(distributionTab); 95 } 96 97 103 public WizardTab addTab(WizardTab tab) 104 { 105 this.addTab(tab.getName(), tab); 106 tabs.add(tab); 107 return tab; 108 } 109 110 116 public void setTabEnabled(String tab, boolean enabled) 117 { 118 String translatedTab = WizardTranslate.get(tab); 119 int index = 0; 120 WizardTab componentTab; 121 if (tab.equalsIgnoreCase(WizardConstants.TAB_DISTRIBUTION)) 122 { 123 index = 1; 124 componentTab = distributionTab; 125 } 126 else if (tab.equalsIgnoreCase(WizardConstants.TAB_CACHING)) 127 { 128 index = this.getTabCount(); 129 componentTab = cachingTab; 130 } 131 else if (tab.equalsIgnoreCase(WizardConstants.TAB_RECOVERY)) 132 { 133 index = this.getTabCount(); 134 componentTab = recoveryTab; 135 } 136 else 137 return; 138 139 if (enabled) 140 this.insertTab(translatedTab, null, componentTab, translatedTab, index); 141 else 142 this.remove(componentTab); 143 } 144 145 150 public ArrayList getUsers() 151 { 152 return authenticationTab.getUsers(); 153 } 154 155 160 public ArrayList getBackends() 161 { 162 return backendsTab.getBackends(); 163 } 164 165 170 public boolean isDistributedDatabase() 171 { 172 return virtualDatabaseTab.isDistributedDB(); 173 } 174 175 178 public void backendListChanged() 179 { 180 for (int i = 0; i < tabs.size(); i++) 181 ((WizardListener) tabs.get(i)).backendListChanged(); 182 } 183 184 187 public void distributionChanged() 188 { 189 setTabEnabled(WizardConstants.TAB_DISTRIBUTION, isDistributedDatabase()); 190 191 for (int i = 0; i < tabs.size(); i++) 192 ((WizardListener) tabs.get(i)).distributionChanged(); 193 } 194 195 198 public void usersChanged() 199 { 200 for (int i = 0; i < tabs.size(); i++) 201 ((WizardListener) tabs.get(i)).usersChanged(); 202 } 203 204 211 public void importDocumentFromXml(Document doc) 212 { 213 Node virtualDabase = doc.selectSingleNode("//" + DatabasesXmlTags.ELT_CJDBC 217 + "/" + DatabasesXmlTags.ELT_VirtualDatabase); 218 virtualDatabaseTab.vdbName.setText(virtualDabase.valueOf("@" 219 + DatabasesXmlTags.ATT_name)); 220 virtualDatabaseTab.maxNbOfConnections.setValue(Integer 221 .parseInt(virtualDabase.valueOf("@" 222 + DatabasesXmlTags.ATT_maxNbOfConnections))); 223 224 String pool = virtualDabase.valueOf("@" + DatabasesXmlTags.ATT_poolThreads); 225 if (!Boolean.valueOf(pool).booleanValue()) 226 virtualDatabaseTab.pool.doClick(); 227 virtualDatabaseTab.minNbOfThreads.setValue(Integer.parseInt(virtualDabase 228 .valueOf("@" + DatabasesXmlTags.ATT_minNbOfThreads))); 229 virtualDatabaseTab.maxNbOfThreads.setValue(Integer.parseInt(virtualDabase 230 .valueOf("@" + DatabasesXmlTags.ATT_maxNbOfThreads))); 231 virtualDatabaseTab.maxThreadIdleTime.setValue(Integer 232 .parseInt(virtualDabase.valueOf("@" 233 + DatabasesXmlTags.ATT_maxThreadIdleTime))); 234 virtualDatabaseTab.sqlDumpLength.setValue(Integer.parseInt(virtualDabase 235 .valueOf("@" + DatabasesXmlTags.ATT_sqlDumpLength))); 236 virtualDatabaseTab.blob.setSelectedItem((virtualDabase.valueOf("@" 237 + DatabasesXmlTags.ATT_blobEncodingMethod))); 238 239 Node distribution = virtualDabase 243 .selectSingleNode(DatabasesXmlTags.ELT_Distribution); 244 if (distribution != null) 245 { 246 virtualDatabaseTab.distributed.doClick(); 247 distributionTab.groupName.setText(distribution.valueOf("@" 248 + DatabasesXmlTags.ATT_groupName)); 249 distributionTab.macroClock.setSelectedItem(distribution.valueOf("@" 250 + DatabasesXmlTags.ATT_macroClock)); 251 distributionTab.castTimeout.setValue(Integer.parseInt(distribution 252 .valueOf("@" + DatabasesXmlTags.ATT_castTimeout))); 253 } 254 255 Node authentication = virtualDabase 259 .selectSingleNode(DatabasesXmlTags.ELT_AuthenticationManager); 260 Node userNode; 261 User user; 262 Iterator iter; 263 264 List admins = authentication.selectNodes(DatabasesXmlTags.ELT_Admin + "/" 265 + DatabasesXmlTags.ELT_User); 266 iter = admins.iterator(); 267 while (iter.hasNext()) 268 { 269 userNode = (Node) iter.next(); 270 user = new User(); 271 user.setUsername(userNode.valueOf("@" + DatabasesXmlTags.ATT_username)); 272 user.setPassword(userNode.valueOf("@" + DatabasesXmlTags.ATT_password)); 273 authenticationTab.admin.getUsersCombo().addItem(user); 274 } 275 276 List users = authentication.selectNodes(DatabasesXmlTags.ELT_VirtualUsers 277 + "/" + DatabasesXmlTags.ELT_VirtualLogin); 278 iter = users.iterator(); 279 while (iter.hasNext()) 280 { 281 userNode = (Node) iter.next(); 282 user = new User(); 283 user.setUsername(userNode.valueOf("@" + DatabasesXmlTags.ATT_vLogin)); 284 user.setPassword(userNode.valueOf("@" + DatabasesXmlTags.ATT_vPassword)); 285 authenticationTab.users.getUsersCombo().addItem(user); 286 } 287 this.usersChanged(); 288 289 List backends = virtualDabase 293 .selectNodes(DatabasesXmlTags.ELT_DatabaseBackend); 294 iter = backends.iterator(); 295 JComboBox backendsCombo = backendsTab.backendsCombo; 296 Node backendNode; 297 Node schemaNode; 298 while (iter.hasNext()) 299 { 300 backendNode = (Node) iter.next(); 301 schemaNode = backendNode 302 .selectSingleNode(DatabasesXmlTags.ELT_DatabaseSchema); 303 Backend backend = new Backend(); 304 backend.setName(backendNode.valueOf("@" + DatabasesXmlTags.ATT_name)); 305 backend.setDriver(backendNode.valueOf("@" + DatabasesXmlTags.ATT_driver)); 306 backend.setDriverPath(backendNode.valueOf("@" 307 + DatabasesXmlTags.ATT_driverPath)); 308 backend.setUrl(backendNode.valueOf("@" + DatabasesXmlTags.ATT_url)); 309 backend.setConnectionTestStatement(backendNode.valueOf("@" 310 + DatabasesXmlTags.ATT_connectionTestStatement)); 311 if (schemaNode != null) 312 { 313 backend.setGatherSystemTables(schemaNode.valueOf("@" 314 + DatabasesXmlTags.ATT_gatherSystemTables)); 315 backend.setDynamicPrecision(schemaNode.valueOf("@" 316 + DatabasesXmlTags.ATT_dynamicPrecision)); 317 } 318 Hashtable managers = new Hashtable (); 322 backend.setConnectionManagers(managers); 323 List connectionManagers = backendNode 324 .selectNodes(DatabasesXmlTags.ELT_ConnectionManager); 325 Iterator iterator = connectionManagers.iterator(); 326 while (iterator.hasNext()) 327 { 328 Node connect = (Node) iterator.next(); 329 User user2 = getUser(connect.valueOf("@" + DatabasesXmlTags.ATT_vLogin)); 330 if (user2 != null) 331 { 332 ConnectionInfo info = new ConnectionInfo(); 333 info.setRLogin(connect.valueOf("@" + DatabasesXmlTags.ATT_rLogin)); 334 info.setRPassword(connect.valueOf("@" 335 + DatabasesXmlTags.ATT_rPassword)); 336 info.setUrlParameters(connect.valueOf("@" 337 + DatabasesXmlTags.ATT_urlParameters)); 338 ConnectionTypeInfo cti = new ConnectionTypeInfo(); 339 ArrayList values = new ArrayList (); 340 341 Node simple = connect 342 .selectSingleNode(DatabasesXmlTags.ELT_SimpleConnectionManager); 343 if (simple != null) 344 { 345 cti.setType(WizardConstants.CONNECTION_MANAGERS[0]); 346 } 347 Node failfast = connect 348 .selectSingleNode(DatabasesXmlTags.ELT_FailFastPoolConnectionManager); 349 if (failfast != null) 350 { 351 cti.setType(WizardConstants.CONNECTION_MANAGERS[1]); 352 values.add(failfast.valueOf("@" + DatabasesXmlTags.ATT_poolSize)); 353 } 354 Node random = connect 355 .selectSingleNode(DatabasesXmlTags.ELT_RandomWaitPoolConnectionManager); 356 if (random != null) 357 { 358 cti.setType(WizardConstants.CONNECTION_MANAGERS[2]); 359 values.add(random.valueOf("@" + DatabasesXmlTags.ATT_poolSize)); 360 values.add(random.valueOf("@" + DatabasesXmlTags.ATT_timeout)); 361 } 362 Node variable = connect 363 .selectSingleNode(DatabasesXmlTags.ELT_VariablePoolConnectionManager); 364 if (variable != null) 365 { 366 cti.setType(WizardConstants.CONNECTION_MANAGERS[3]); 367 values.add(variable 368 .valueOf("@" + DatabasesXmlTags.ATT_initPoolSize)); 369 values 370 .add(variable.valueOf("@" + DatabasesXmlTags.ATT_minPoolSize)); 371 values 372 .add(variable.valueOf("@" + DatabasesXmlTags.ATT_maxPoolSize)); 373 values 374 .add(variable.valueOf("@" + DatabasesXmlTags.ATT_idleTimeout)); 375 values 376 .add(variable.valueOf("@" + DatabasesXmlTags.ATT_waitTimeout)); 377 } 378 379 cti.setValues(values); 380 info.setConnectionTypeInfo(cti); 381 managers.put(user2, info); 382 } 383 } 384 backendsCombo.addItem(backend); 385 } 386 backendsCombo.setSelectedIndex(0); 387 388 Node requestManager = virtualDabase 392 .selectSingleNode(DatabasesXmlTags.ELT_RequestManager); 393 394 if (requestManager.valueOf("@" + DatabasesXmlTags.ATT_caseSensitiveParsing) 395 .equals("true")) 396 requestManagerTab.caseSensitiveParsing.doClick(); 397 requestManagerTab.beginTimeout.setValue(Integer.parseInt(requestManager 398 .valueOf("@" + DatabasesXmlTags.ATT_beginTimeout))); 399 requestManagerTab.commitTimeout.setValue(Integer.parseInt(requestManager 400 .valueOf("@" + DatabasesXmlTags.ATT_commitTimeout))); 401 requestManagerTab.rollbackTimeout.setValue(Integer.parseInt(requestManager 402 .valueOf("@" + DatabasesXmlTags.ATT_rollbackTimeout))); 403 404 Element scheduler = (Element) requestManager 408 .selectSingleNode(DatabasesXmlTags.ELT_RequestScheduler); 409 Element schedulerElement = (Element) scheduler.elements().iterator().next(); 410 requestManagerTab.scheduler.setSelectedItem(schedulerElement.getName()); 411 requestManagerTab.schedulerLevel.setSelectedItem(schedulerElement 412 .valueOf("@" + DatabasesXmlTags.ATT_level)); 413 414 Element loadbalancer = (Element) requestManager 418 .selectSingleNode(DatabasesXmlTags.ELT_LoadBalancer); 419 Element loadElement = (Element) loadbalancer.elements().iterator().next(); 420 String raidbLoad = loadElement.getName(); 421 if (raidbLoad.startsWith(DatabasesXmlTags.ELT_RAIDb_1) 422 || raidbLoad.startsWith(DatabasesXmlTags.ELT_RAIDb_2)) 423 { 424 Element wait = (Element) loadElement 425 .selectSingleNode(DatabasesXmlTags.ELT_WaitForCompletion); 426 if (wait != null) 427 requestManagerTab.wait4completion.setSelectedItem(wait.valueOf("@" 428 + DatabasesXmlTags.ATT_policy)); 429 430 Iterator raidb = loadElement.elements().iterator(); 431 while (raidb.hasNext()) 432 { 433 Element raid = (Element) raidb.next(); 434 String name = raid.getName(); 435 if (name.startsWith(DatabasesXmlTags.ELT_RAIDb_1) 436 || name.startsWith(DatabasesXmlTags.ELT_RAIDb_2)) 437 { 438 requestManagerTab.loadbalancer.setSelectedItem(name); 439 } 440 } 441 } 442 else 443 requestManagerTab.loadbalancer.setSelectedItem(loadElement.getName()); 444 445 Element cache = (Element) requestManager 449 .selectSingleNode(DatabasesXmlTags.ELT_RequestCache); 450 if (cache != null) 451 { 452 requestManagerTab.usecaching.doClick(); 453 454 List cacheElements = cache.elements(); 455 iter = cacheElements.iterator(); 456 while (iter.hasNext()) 457 { 458 Element celem = (Element) iter.next(); 459 if (celem.getName() 460 .equalsIgnoreCase(DatabasesXmlTags.ELT_MetadataCache)) 461 { 462 cachingTab.metadataenable.doClick(); 463 cachingTab.maxNbOfMetadata.setValue(Integer.parseInt(celem 464 .valueOf("@" + DatabasesXmlTags.ATT_maxNbOfMetadata))); 465 cachingTab.maxNbOfField.setValue(Integer.parseInt(celem.valueOf("@" 466 + DatabasesXmlTags.ATT_maxNbOfField))); 467 } 468 else if (celem.getName().equalsIgnoreCase( 469 DatabasesXmlTags.ELT_ParsingCache)) 470 { 471 cachingTab.parsingenable.doClick(); 472 boolean background = Boolean.valueOf( 473 celem.valueOf("@" + DatabasesXmlTags.ATT_backgroundParsing)) 474 .booleanValue(); 475 if (background) 476 cachingTab.backgroundParsing.doClick(); 477 cachingTab.maxNbOfEntries.setValue(Integer.parseInt(celem.valueOf("@" 478 + DatabasesXmlTags.ATT_maxNbOfEntries))); 479 } 480 else if (celem.getName().equalsIgnoreCase( 481 DatabasesXmlTags.ELT_ResultCache)) 482 { 483 cachingTab.resultenable.doClick(); 484 cachingTab.granularity.setSelectedItem(celem.valueOf("@" 485 + DatabasesXmlTags.ATT_granularity)); 486 cachingTab.resultMaxNbOfEntries.setValue(Integer.parseInt(celem 487 .valueOf("@" + DatabasesXmlTags.ATT_maxNbOfEntries))); 488 cachingTab.pendingTimeout.setValue(Integer.parseInt(celem.valueOf("@" 489 + DatabasesXmlTags.ATT_pendingTimeout))); 490 } 491 } 492 } 493 494 Node recovery = requestManager 498 .selectSingleNode(DatabasesXmlTags.ELT_RecoveryLog); 499 if (recovery != null) 500 { 501 Node jdbcRecovery = recovery 502 .selectSingleNode(DatabasesXmlTags.ELT_RecoveryLog); 503 requestManagerTab.userecoverylog.doClick(); 504 recoveryTab.driver.setText(jdbcRecovery.valueOf("@" 505 + DatabasesXmlTags.ATT_driver)); 506 recoveryTab.driverPath.setText(jdbcRecovery.valueOf("@" 507 + DatabasesXmlTags.ATT_driverPath)); 508 recoveryTab.url.setText(jdbcRecovery.valueOf("@" 509 + DatabasesXmlTags.ATT_url)); 510 recoveryTab.login.setText(jdbcRecovery.valueOf("@" 511 + DatabasesXmlTags.ATT_login)); 512 recoveryTab.password.setText(jdbcRecovery.valueOf("@" 513 + DatabasesXmlTags.ATT_password)); 514 recoveryTab.requestTimeout.setValue(Integer.parseInt(jdbcRecovery 515 .valueOf("@" + DatabasesXmlTags.ATT_requestTimeout))); 516 } 517 518 this.validate(); 519 this.repaint(); 520 } 521 522 private User getUser(String userName) 523 { 524 JComboBox box = authenticationTab.users.getUsersCombo(); 525 int count = box.getItemCount(); 526 for (int i = 0; i < count; i++) 527 { 528 User user = (User) box.getItemAt(i); 529 if (user.getUsername().equals(userName)) 530 return user; 531 } 532 return null; 533 } 534 535 541 public Document exportDocumentToXml() 542 { 543 544 DocumentType doctype = DocumentFactory.getInstance().createDocType( 551 DatabasesXmlTags.ELT_CJDBC, "-//ObjectWeb//DTD C-JDBC 1.1//EN", 552 "http://c-jdbc.objectweb.org/dtds/c-jdbc-1.1.dtd"); 553 Document document = DocumentFactory.getInstance().createDocument(); 554 document.setDocType(doctype); 555 Element root = document.addElement(DatabasesXmlTags.ELT_CJDBC); 556 557 561 Element virtualDatabase = root 562 .addElement(DatabasesXmlTags.ELT_VirtualDatabase); 563 virtualDatabase.addAttribute(DatabasesXmlTags.ATT_name, 564 virtualDatabaseTab.vdbName.getText()); 565 virtualDatabase.addAttribute(DatabasesXmlTags.ATT_maxNbOfConnections, "" 566 + virtualDatabaseTab.maxNbOfConnections.getValue()); 567 virtualDatabase.addAttribute(DatabasesXmlTags.ATT_poolThreads, "" 568 + (virtualDatabaseTab.pool.getSelectedObjects() != null)); 569 virtualDatabase.addAttribute(DatabasesXmlTags.ATT_minNbOfThreads, "" 570 + virtualDatabaseTab.minNbOfThreads.getValue()); 571 virtualDatabase.addAttribute(DatabasesXmlTags.ATT_maxNbOfThreads, "" 572 + virtualDatabaseTab.maxNbOfThreads.getValue()); 573 virtualDatabase.addAttribute(DatabasesXmlTags.ATT_maxThreadIdleTime, "" 574 + virtualDatabaseTab.maxThreadIdleTime.getValue()); 575 virtualDatabase.addAttribute(DatabasesXmlTags.ATT_sqlDumpLength, "" 576 + virtualDatabaseTab.sqlDumpLength.getValue()); 577 virtualDatabase.addAttribute(DatabasesXmlTags.ATT_blobEncodingMethod, "" 578 + virtualDatabaseTab.blob.getSelectedItem()); 579 580 if (isDistributedDatabase()) 584 { 585 Element distribution = virtualDatabase 586 .addElement(DatabasesXmlTags.ELT_Distribution); 587 distribution.addAttribute(DatabasesXmlTags.ATT_groupName, 588 distributionTab.groupName.getText()); 589 distribution.addAttribute(DatabasesXmlTags.ATT_macroClock, 590 distributionTab.macroClock.getSelectedItem().toString()); 591 distribution.addAttribute(DatabasesXmlTags.ATT_castTimeout, "" 592 + distributionTab.castTimeout.getValue()); 593 } 594 595 Element authentication = virtualDatabase 599 .addElement(DatabasesXmlTags.ELT_AuthenticationManager); 600 Element admin = authentication.addElement(DatabasesXmlTags.ELT_Admin); 601 JComboBox adminBox = authenticationTab.admin.getUsersCombo(); 602 int count = adminBox.getItemCount(); 603 for (int i = 0; i < count; i++) 604 { 605 User user = (User) adminBox.getItemAt(i); 606 admin.addElement(DatabasesXmlTags.ELT_User).addAttribute( 607 DatabasesXmlTags.ATT_username, user.getUsername()).addAttribute( 608 DatabasesXmlTags.ATT_password, user.getPassword()); 609 } 610 611 Element users = authentication 612 .addElement(DatabasesXmlTags.ELT_VirtualUsers); 613 JComboBox virtualBox = authenticationTab.users.getUsersCombo(); 614 count = virtualBox.getItemCount(); 615 for (int i = 0; i < count; i++) 616 { 617 User user = (User) virtualBox.getItemAt(i); 618 users.addElement(DatabasesXmlTags.ELT_VirtualLogin).addAttribute( 619 DatabasesXmlTags.ATT_vLogin, user.getUsername()).addAttribute( 620 DatabasesXmlTags.ATT_vPassword, user.getPassword()); 621 } 622 623 JComboBox backends = backendsTab.backendsCombo; 627 int backcount = backends.getItemCount(); 628 for (int i = 0; i < backcount; i++) 629 { 630 Backend backend = (Backend) backends.getItemAt(i); 631 Element backende = virtualDatabase 632 .addElement(DatabasesXmlTags.ELT_DatabaseBackend); 633 backende.addAttribute(DatabasesXmlTags.ATT_name, backend.getName()); 634 backende.addAttribute(DatabasesXmlTags.ATT_driver, backend.getDriver()); 635 backende.addAttribute(DatabasesXmlTags.ATT_driverPath, backend 636 .getDriverPath()); 637 backende.addAttribute(DatabasesXmlTags.ATT_url, backend.getUrl()); 638 backende.addAttribute(DatabasesXmlTags.ATT_connectionTestStatement, 639 backend.getConnectionTestStatement()); 640 641 Element schema = backende.addElement(DatabasesXmlTags.ELT_DatabaseSchema); 642 schema.addAttribute(DatabasesXmlTags.ATT_dynamicPrecision, backend 643 .getDynamicPrecision()); 644 if (Boolean.valueOf(backend.getGatherSystemTables()).booleanValue()) 645 schema.addAttribute(DatabasesXmlTags.ATT_gatherSystemTables, backend 646 .getGatherSystemTables()); 647 648 Hashtable managers = backend.getConnectionManagers(); 652 Enumeration keys = managers.keys(); 653 while (keys.hasMoreElements()) 654 { 655 User user = (User) keys.nextElement(); 656 ConnectionInfo info = (ConnectionInfo) managers.get(user); 657 Element connection = backende 658 .addElement(DatabasesXmlTags.ELT_ConnectionManager); 659 connection 660 .addAttribute(DatabasesXmlTags.ATT_vLogin, user.getUsername()); 661 connection.addAttribute(DatabasesXmlTags.ATT_rLogin, info.getRLogin()); 662 connection.addAttribute(DatabasesXmlTags.ATT_rPassword, info 663 .getRPassword()); 664 connection.addAttribute(DatabasesXmlTags.ATT_urlParameters, info 665 .getUrlParameters()); 666 ConnectionTypeInfo cti = info.getConnectionTypeInfo(); 667 668 String type = cti.getType(); 669 if (type == WizardConstants.CONNECTION_MANAGERS[0]) 670 connection.addElement(DatabasesXmlTags.ELT_SimpleConnectionManager); 671 else if (type == WizardConstants.CONNECTION_MANAGERS[1]) 672 { 673 Element manager = connection 674 .addElement(DatabasesXmlTags.ELT_FailFastPoolConnectionManager); 675 manager.addAttribute(DatabasesXmlTags.ATT_poolSize, "" 676 + cti.getValue(0)); 677 } 678 else if (type == WizardConstants.CONNECTION_MANAGERS[2]) 679 { 680 Element manager = connection 681 .addElement(DatabasesXmlTags.ELT_RandomWaitPoolConnectionManager); 682 manager.addAttribute(DatabasesXmlTags.ATT_poolSize, "" 683 + cti.getValue(0)); 684 manager.addAttribute(DatabasesXmlTags.ATT_timeout, "" 685 + cti.getValue(1)); 686 } 687 else if (type == WizardConstants.CONNECTION_MANAGERS[3]) 688 { 689 Element manager = connection 690 .addElement(DatabasesXmlTags.ELT_VariablePoolConnectionManager); 691 manager.addAttribute(DatabasesXmlTags.ATT_initPoolSize, "" 692 + cti.getValue(0)); 693 manager.addAttribute(DatabasesXmlTags.ATT_minPoolSize, "" 694 + cti.getValue(1)); 695 manager.addAttribute(DatabasesXmlTags.ATT_maxPoolSize, "" 696 + cti.getValue(2)); 697 manager.addAttribute(DatabasesXmlTags.ATT_idleTimeout, "" 698 + cti.getValue(3)); 699 manager.addAttribute(DatabasesXmlTags.ATT_waitTimeout, "" 700 + cti.getValue(4)); 701 } 702 } 703 } 704 705 Element requestManager = virtualDatabase 709 .addElement(DatabasesXmlTags.ELT_RequestManager); 710 711 requestManager.addAttribute(DatabasesXmlTags.ATT_caseSensitiveParsing, 712 Boolean.toString(requestManagerTab.caseSensitiveParsing 713 .getSelectedObjects() != null)); 714 requestManager.addAttribute(DatabasesXmlTags.ATT_beginTimeout, 715 requestManagerTab.beginTimeout.getValue() + ""); 716 requestManager.addAttribute(DatabasesXmlTags.ATT_commitTimeout, 717 requestManagerTab.commitTimeout.getValue() + ""); 718 requestManager.addAttribute(DatabasesXmlTags.ATT_rollbackTimeout, 719 requestManagerTab.rollbackTimeout.getValue() + ""); 720 721 Element scheduler = requestManager 725 .addElement(DatabasesXmlTags.ELT_RequestScheduler); 726 int ischeduler = requestManagerTab.scheduler.getSelectedIndex(); 727 String level = (String ) requestManagerTab.schedulerLevel.getSelectedItem(); 728 switch (ischeduler) 729 { 730 case 0 : 731 scheduler.addElement(DatabasesXmlTags.ELT_SingleDBScheduler) 732 .addAttribute(DatabasesXmlTags.ATT_level, level); 733 break; 734 case 1 : 735 scheduler.addElement(DatabasesXmlTags.ELT_RAIDb0Scheduler) 736 .addAttribute(DatabasesXmlTags.ATT_level, level); 737 break; 738 case 2 : 739 scheduler.addElement(DatabasesXmlTags.ELT_RAIDb1Scheduler) 740 .addAttribute(DatabasesXmlTags.ATT_level, level); 741 break; 742 case 3 : 743 scheduler.addElement(DatabasesXmlTags.ELT_RAIDb2Scheduler) 744 .addAttribute(DatabasesXmlTags.ATT_level, level); 745 break; 746 default : 747 break; 748 } 749 750 if (requestManagerTab.usecaching.getSelectedObjects() != null) 754 { 755 Element cache = requestManager 756 .addElement(DatabasesXmlTags.ELT_RequestCache); 757 if (cachingTab.metadataenable.getSelectedObjects() != null) 758 { 759 Element metadata = cache.addElement(DatabasesXmlTags.ELT_MetadataCache); 760 metadata.addAttribute(DatabasesXmlTags.ATT_maxNbOfMetadata, "" 761 + cachingTab.maxNbOfMetadata.getValue()); 762 metadata.addAttribute(DatabasesXmlTags.ATT_maxNbOfField, "" 763 + cachingTab.maxNbOfField.getValue()); 764 } 765 if (cachingTab.parsingenable.getSelectedObjects() != null) 766 { 767 Element parsing = cache.addElement(DatabasesXmlTags.ELT_ParsingCache); 768 parsing 769 .addAttribute(DatabasesXmlTags.ATT_backgroundParsing, 770 Boolean.toString(cachingTab.backgroundParsing 771 .getSelectedObjects() != null)); 772 parsing.addAttribute(DatabasesXmlTags.ATT_maxNbOfEntries, "" 773 + cachingTab.maxNbOfEntries.getValue()); 774 } 775 if (cachingTab.resultenable.getSelectedObjects() != null) 776 { 777 Element result = cache.addElement(DatabasesXmlTags.ELT_ResultCache); 778 result.addAttribute(DatabasesXmlTags.ATT_granularity, "" 779 + cachingTab.granularity.getSelectedItem()); 780 result.addAttribute(DatabasesXmlTags.ATT_maxNbOfEntries, "" 781 + cachingTab.resultMaxNbOfEntries.getValue()); 782 result.addAttribute(DatabasesXmlTags.ATT_pendingTimeout, "" 783 + cachingTab.pendingTimeout.getValue()); 784 result.addComment(WizardTranslate.get("not.supported.caching.rules")); 785 } 786 } 787 788 Element loadbalancer = requestManager 792 .addElement(DatabasesXmlTags.ELT_LoadBalancer); 793 String loadElement = (String ) requestManagerTab.loadbalancer 794 .getSelectedItem(); 795 796 Element currentLoadbalancer = loadbalancer; 797 798 if (loadElement.startsWith(DatabasesXmlTags.ELT_RAIDb_0)) 799 currentLoadbalancer = loadbalancer 800 .addElement(DatabasesXmlTags.ELT_RAIDb_0); 801 if (loadElement.startsWith(DatabasesXmlTags.ELT_RAIDb_1)) 802 { 803 currentLoadbalancer = loadbalancer 804 .addElement(DatabasesXmlTags.ELT_RAIDb_1); 805 currentLoadbalancer.addElement(DatabasesXmlTags.ELT_WaitForCompletion) 806 .addAttribute(DatabasesXmlTags.ATT_policy, 807 (String ) requestManagerTab.wait4completion.getSelectedItem()); 808 } 809 if (loadElement.startsWith(DatabasesXmlTags.ELT_RAIDb_2)) 810 { 811 currentLoadbalancer = loadbalancer 812 .addElement(DatabasesXmlTags.ELT_RAIDb_2); 813 currentLoadbalancer.addElement(DatabasesXmlTags.ELT_WaitForCompletion) 814 .addAttribute(DatabasesXmlTags.ATT_policy, 815 (String ) requestManagerTab.wait4completion.getSelectedItem()); 816 } 817 if (loadElement.startsWith(DatabasesXmlTags.ELT_ParallelDB)) 818 currentLoadbalancer = loadbalancer 819 .addElement(DatabasesXmlTags.ELT_ParallelDB); 820 821 currentLoadbalancer.addElement(loadElement); 822 currentLoadbalancer.addComment(WizardTranslate 823 .get("not.supported.macro.handling")); 824 currentLoadbalancer.addComment(WizardTranslate 825 .get("not.supported.create.policy")); 826 827 if (requestManagerTab.userecoverylog.getSelectedObjects() != null) 831 { 832 Element recovery = requestManager 833 .addElement(DatabasesXmlTags.ELT_RecoveryLog); 834 Element jdbc = recovery.addElement(DatabasesXmlTags.ELT_RecoveryLog); 835 jdbc.addAttribute(DatabasesXmlTags.ATT_driver, recoveryTab.driver 836 .getText()); 837 jdbc.addAttribute(DatabasesXmlTags.ATT_driverPath, recoveryTab.driverPath 838 .getText()); 839 jdbc.addAttribute(DatabasesXmlTags.ATT_url, recoveryTab.url.getText()); 840 jdbc 841 .addAttribute(DatabasesXmlTags.ATT_login, recoveryTab.login.getText()); 842 jdbc.addAttribute(DatabasesXmlTags.ATT_password, recoveryTab.password 843 .getText()); 844 jdbc.addAttribute(DatabasesXmlTags.ATT_requestTimeout, "" 845 + recoveryTab.requestTimeout.getValue()); 846 847 jdbc.addElement(DatabasesXmlTags.ELT_RecoveryLogTable); 848 jdbc.addElement(DatabasesXmlTags.ELT_CheckpointTable); 849 jdbc.addElement(DatabasesXmlTags.ELT_BackendTable); 850 } 851 852 return document; 853 } 854 } | Popular Tags |