(Realm realm)
| 510 | } |
| 511 | |
| 512 | @Override |
| 513 | public void setRealm(Realm realm) { |
| 514 | |
| 515 | Realm oldRealm; |
| 516 | Lock l = realmLock.writeLock(); |
| 517 | l.lock(); |
| 518 | try { |
| 519 | // Change components if necessary |
| 520 | oldRealm = this.realm; |
| 521 | if (oldRealm == realm) { |
| 522 | return; |
| 523 | } |
| 524 | this.realm = realm; |
| 525 | |
| 526 | // Start the new component if necessary |
| 527 | if (realm != null) { |
| 528 | realm.setContainer(this); |
| 529 | } |
| 530 | } finally { |
| 531 | l.unlock(); |
| 532 | } |
| 533 | |
| 534 | // Stop the old component if necessary |
| 535 | if (getState().isAvailable() && oldRealm instanceof Lifecycle) { |
| 536 | try { |
| 537 | ((Lifecycle) oldRealm).stop(); |
| 538 | } catch (LifecycleException e) { |
| 539 | log.error(sm.getString("containerBase.realm.stop"), e); |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | if (getState().isAvailable() && realm instanceof Lifecycle) { |
| 544 | try { |
| 545 | ((Lifecycle) realm).start(); |
| 546 | } catch (LifecycleException e) { |
| 547 | log.error(sm.getString("containerBase.realm.start"), e); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | // Report this property change to interested listeners |
| 552 | support.firePropertyChange("realm", oldRealm, this.realm); |
| 553 | } |
| 554 | |
| 555 | |
| 556 | // ------------------------------------------------------ Container Methods |
nothing calls this directly
no test coverage detected