Engine 本质是一个容器,因此它继承了 ContainerBase 基类,并且实现了 Engine 接口。
Engine 的子容器是 Host,所以它持有了一个 Host 容器的数组,这些功能都被抽象到了 ContainerBase 中,ContainerBase 中有这样一个数据结构:
ContainerBase 用 HashMap 保存了它的子容器,并且 ContainerBase 还实现了子容器的“增删改查”,甚至连子组件的启动和停止都提供了默认实现,比如 ContainerBase 会用专门的线程池来启动子容器。
javapublic class StandardEngine extends ContainerBase implements Engine {
private static final Log log = LogFactory.getLog(StandardEngine.class);