/**
   * Updates each ThreadPoolExecutor with the current time, which is the time when a context is
   * being stopped.
   *
   * @param context the context being stopped, used to discover all the Connectors of its parent
   *     Service.
   */
  public void stopIdleThreads(Context context) throws RemoteException, RemoteException {
    if (serverStopping) return;

    if (!(context instanceof StandardContextRemoteInterface)
        || !((StandardContextRemoteInterface) context).getRenewThreadsWhenStoppingContext()) {
      log.debug(
          "Not renewing threads when the context is stopping. " + "It is not configured to do it.");
      return;
    }

    Engine engine = (Engine) context.getParent().getParent();
    Service service = engine.getService();
    ConnectorRemoteInterface[] connectors = service.findConnectors();
    if (connectors != null) {
      for (ConnectorRemoteInterface connector : connectors) {
        ProtocolHandler handler = connector.getProtocolHandler();
        Executor executor = null;
        if (handler != null) {
          executor = handler.getExecutor();
        }

        if (executor instanceof ThreadPoolExecutor2RemoteInterface) {
          ThreadPoolExecutor2RemoteInterface threadPoolExecutor =
              (ThreadPoolExecutor2RemoteInterface) executor;
          threadPoolExecutor.contextStopping();
        } else if (executor instanceof StandardThreadExecutorRemoteInterface) {
          StandardThreadExecutorRemoteInterface stdThreadExecutor =
              (StandardThreadExecutorRemoteInterface) executor;
          stdThreadExecutor.contextStopping();
        }
      }
    }
  }
Exemplo n.º 2
0
  public void setServer(Server server) {
    Service[] findServices = server.findServices();
    for (Service service : findServices) {
      Service existingService = getServer().findService(service.getName());
      if (existingService != null) {
        for (Connector connector : service.findConnectors()) {
          existingService.addConnector(connector);
        }
        for (Executor executor : service.findExecutors()) {
          existingService.addExecutor(executor);
        }
        for (LifecycleListener lifecycleListener : service.findLifecycleListeners()) {
          existingService.addLifecycleListener(lifecycleListener);
        }
        existingService.getContainer().setRealm(service.getContainer().getRealm());
        existingService
            .getContainer()
            .setBackgroundProcessorDelay(service.getContainer().getBackgroundProcessorDelay());
        existingService.getContainer().setCluster(service.getContainer().getCluster());
        // existingService.getContainer().setResources(
        // service.getContainer().getResources());
      } else {
        getServer().addService(service);
      }
    }
    this.setHostname(server.getAddress());

    this.setPort(server.getPort());
  }
 private void removeServiceConnectors() {
   for (Service service : this.tomcat.getServer().findServices()) {
     Connector[] connectors = service.findConnectors().clone();
     this.serviceConnectors.put(service, connectors);
     for (Connector connector : connectors) {
       service.removeConnector(connector);
     }
   }
 }
  private String internalPickPort() {

    Service catalinaService = ServerFactory.getServer().findService("Catalina");
    for (Connector connector : catalinaService.findConnectors()) {
      if (connector.getProtocol().equals("HTTP/1.1")) {
        return new Integer(connector.getPort()).toString();
      }
    }

    throw new UnsupportedOperationException(
        "WSAT has test againest Tomcat 6.0, Please change to it.");
  }