MCPcopy Create free account
hub / github.com/apache/tomcat / addChild

Method addChild

java/org/apache/catalina/core/ContainerBase.java:559–588  ·  view source on GitHub ↗
(Container child)

Source from the content-addressed store, hash-verified

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

Callers 1

addChildMethod · 0.95

Calls 15

fireContainerEventMethod · 0.95
writeLockMethod · 0.80
isDebugEnabledMethod · 0.65
debugMethod · 0.65
getStringMethod · 0.65
lockMethod · 0.65
getMethod · 0.65
getNameMethod · 0.65
setParentMethod · 0.65
putMethod · 0.65
unlockMethod · 0.65
isAvailableMethod · 0.65

Tested by

no test coverage detected