org.apache.catalina.Engine.findChildren()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.apache.catalina.Engine.findChildren()方法的一些代码示例,展示了Engine.findChildren()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Engine.findChildren()方法的具体详情如下:
包路径:org.apache.catalina.Engine
类名称:Engine
方法名:findChildren

Engine.findChildren介绍

暂无

代码示例

代码示例来源:origin: line/armeria

@Override
public Connector apply(String hostname) {
  // Create the connector with our protocol handler. Tomcat will call ProtocolHandler.setAdapter()
  // on its startup with the Coyote Adapter which gives an access to Tomcat's HTTP service pipeline.
  final Class<?> protocolType = TomcatService.PROTOCOL_HANDLER_CLASS;
  final Connector connector = new Connector(protocolType.getName());
  // We do not really open a port - just trying to stop the Connector from complaining.
  connector.setPort(0);
  final StandardServer server = newServer(hostname, connector, config);
  // Retrieve the components configured by newServer(), so we can use it in checkConfiguration().
  final Service service = server.findServices()[0];
  final Engine engine = TomcatUtil.engine(service, hostname);
  final StandardHost host = (StandardHost) engine.findChildren()[0];
  final Context context = (Context) host.findChildren()[0];
  // Apply custom configurators set via TomcatServiceBuilder.configurator()
  try {
    config.configurators().forEach(c -> c.accept(server));
  } catch (Throwable t) {
    throw new TomcatServiceException("failed to configure an embedded Tomcat", t);
  }
  // Make sure the configurators did not ruin what we have configured in this method.
  checkConfiguration(server, service, connector, engine, host, context);
  assert connector.getService().getServer() != null;
  return connector;
}

代码示例来源:origin: line/armeria

final Container[] engineChildren = expectedEngine.findChildren();
if (engineChildren == null || Arrays.stream(engineChildren).noneMatch(c -> c == expectedHost)) {
  throw new TomcatServiceException("A configurator should never remove the default host.");

代码示例来源:origin: org.mobicents.arquillian.container/mss-tomcat-embedded-6

private boolean isContextExists(Context context) {
  // Is this Context actually among those that are defined?
  for (int i = 0; i < engines.length; i++) {
    Container hosts[] = engines[i].findChildren();
    for (int j = 0; j < hosts.length; j++) {
      Container contexts[] = hosts[j].findChildren();
      for (int k = 0; k < contexts.length; k++) {
        if (context == (Context) contexts[k]) {
          return true;
        }
      }                
    }           
  }
  return false;
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

private void registerListenersForEngine(Engine engine) {
  for (Container hostContainer : engine.findChildren()) {
    Host host = (Host) hostContainer;
    host.addContainerListener(this);
    registerListenersForHost(host);
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

private void registerListenersForEngine(Engine engine) {
  for (Container hostContainer : engine.findChildren()) {
    Host host = (Host) hostContainer;
    host.addContainerListener(this);
    registerListenersForHost(host);
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

private void registerListenersForEngine(Engine engine) {
  for (Container hostContainer : engine.findChildren()) {
    Host host = (Host) hostContainer;
    host.addContainerListener(this);
    registerListenersForHost(host);
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

private void registerListenersForEngine(Engine engine) {
  for (Container hostContainer : engine.findChildren()) {
    Host host = (Host) hostContainer;
    host.addContainerListener(this);
    registerListenersForHost(host);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

private void registerListenersForEngine(Engine engine) {
  for (Container hostContainer : engine.findChildren()) {
    Host host = (Host) hostContainer;
    host.addContainerListener(this);
    registerListenersForHost(host);
  }
}

代码示例来源:origin: org.glassfish.web/web-glue

/**
 * Reconfigures the access log valve of each virtual server with the
 * updated attributes of the <access-log> element from domain.xml.
 */
public void updateAccessLog(HttpService httpService) {
  Container[] virtualServers = getEngine().findChildren();
  for (Container virtualServer : virtualServers) {
    ((VirtualServer) virtualServer).reconfigureAccessLog(
        httpService, webContainerFeatureFactory);
  }
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

private void registerListenersForEngine(Engine engine) {
  for (Container hostContainer : engine.findChildren()) {
    Host host = (Host) hostContainer;
    host.addContainerListener(this);
    registerListenersForHost(host);
  }
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

private void registerListenersForEngine(Engine engine) {
  for (Container hostContainer : engine.findChildren()) {
    Host host = (Host) hostContainer;
    host.addContainerListener(this);
    registerListenersForHost(host);
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

private void registerListenersForEngine(Engine engine) {
  for (Container hostContainer : engine.findChildren()) {
    Host host = (Host) hostContainer;
    host.addContainerListener(this);
    registerListenersForHost(host);
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

public Host getHost() {
  Engine engine = getEngine();
  if (engine.findChildren().length > 0) {
    return (Host) engine.findChildren()[0];
  }
  Host host = new StandardHost();
  host.setName(hostname);
  getEngine().addChild(host);
  return host;
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

public Host getHost() {
  Engine engine = getEngine();
  if (engine.findChildren().length > 0) {
    return (Host) engine.findChildren()[0];
  }
  Host host = new StandardHost();
  host.setName(hostname);
  getEngine().addChild(host);
  return host;
}

代码示例来源:origin: org.gatein.wci/wci-tomcat7

void start()
{
 ServletContainerFactory.registerContext(this);
 //
 Container[] childrenContainers = engine.findChildren();
 for (Container childContainer : childrenContainers)
 {
   if (childContainer instanceof Host)
   {
    Host host = (Host)childContainer;
    registerHost(host);
   }
 }
 //
 engine.addContainerListener(this);
}

代码示例来源:origin: org.apache.openejb/webdeployer

private void check() {
  final StandardServer server = TomcatHelper.getServer();
  for (final Service service : server.findServices()) {
    if (service.getContainer() instanceof Engine) {
      final Engine engine = (Engine) service.getContainer();
      for (final Container engineChild : engine.findChildren()) {
        if (engineChild instanceof StandardHost) {
          final StandardHost host = (StandardHost) engineChild;
          webappBuilder.checkHost(host);
        }
      }
    }
  }
}

代码示例来源:origin: org.apache.tomee/webdeployer

private void check() {
  final StandardServer server = TomcatHelper.getServer();
  for (final Service service : server.findServices()) {
    if (service.getContainer() instanceof Engine) {
      final Engine engine = (Engine) service.getContainer();
      for (final Container engineChild : engine.findChildren()) {
        if (engineChild instanceof StandardHost) {
          final StandardHost host = (StandardHost) engineChild;
          webappBuilder.checkHost(host);
        }
      }
    }
  }
}

代码示例来源:origin: modcluster/mod_cluster

@Test
public void getHosts() {
  org.apache.catalina.Host host = mock(org.apache.catalina.Host.class);
  HostFactory hostFactory = mock(HostFactory.class);
  Host expected = mock(Host.class);
  when(this.engine.findChildren()).thenReturn(new Container[] { host });
  when(this.registry.getHostFactory()).thenReturn(hostFactory);
  when(hostFactory.createHost(same(this.registry), same(host), same(this.catalinaEngine))).thenReturn(expected);
  Iterable<Host> result = this.catalinaEngine.getHosts();
  Iterator<Host> hosts = result.iterator();
  assertTrue(hosts.hasNext());
  assertSame(expected, hosts.next());
  assertFalse(hosts.hasNext());
}

代码示例来源:origin: codefollower/Tomcat-Research

@Override
public void startInternal() throws LifecycleException {
  setState(LifecycleState.STARTING);
  // Find any components that have already been initialized since the
  // MBean listener won't be notified as those components will have
  // already registered their MBeans
  findDefaultHost();
  Engine engine = (Engine) service.getContainer();
  addListeners(engine);
  Container[] conHosts = engine.findChildren();
  for (Container conHost : conHosts) {
    Host host = (Host) conHost;
    if (!LifecycleState.NEW.equals(host.getState())) {
      // Registering the host will register the context and wrappers
      registerHost(host);
    }
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

@Override
public void startInternal() {
  setState(LifecycleState.STARTING);
  // Find any components that have already been initialized since the
  // MBean listener won't be notified as those components will have
  // already registered their MBeans
  findDefaultHost();
  
  Engine engine = (Engine) connector.getService().getContainer();
  addListeners(engine);
  
  Container[] conHosts = engine.findChildren();
  for (Container conHost : conHosts) {
    Host host = (Host) conHost;
    if (!LifecycleState.NEW.equals(host.getState())) {
      // Registering the host will register the context and wrappers
      registerHost(host);
    }
  }
}

相关文章