(Container child)
| 557 | |
| 558 | |
| 559 | @Override |
| 560 | public void addChild(Container child) { |
| 561 | if (log.isDebugEnabled()) { |
| 562 | log.debug(sm.getString("containerBase.child.add", child, this)); |
| 563 | } |
| 564 | |
| 565 | childrenLock.writeLock().lock(); |
| 566 | try { |
| 567 | if (children.get(child.getName()) != null) { |
| 568 | throw new IllegalArgumentException(sm.getString("containerBase.child.notUnique", child.getName())); |
| 569 | } |
| 570 | child.setParent(this); // May throw IAE |
| 571 | children.put(child.getName(), child); |
| 572 | } finally { |
| 573 | childrenLock.writeLock().unlock(); |
| 574 | } |
| 575 | |
| 576 | fireContainerEvent(ADD_CHILD_EVENT, child); |
| 577 | |
| 578 | // Start child |
| 579 | // Don't do this inside sync block - start can be a slow process and |
| 580 | // locking the children object can cause problems elsewhere |
| 581 | try { |
| 582 | if ((getState().isAvailable() || LifecycleState.STARTING_PREP.equals(getState())) && startChildren) { |
| 583 | child.start(); |
| 584 | } |
| 585 | } catch (LifecycleException e) { |
| 586 | throw new IllegalStateException(sm.getString("containerBase.child.start"), e); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | |
| 591 | @Override |
no test coverage detected