public void registerListenersForServer(Server server) throws RemoteException, RemoteException {
   for (Service service : server.findServices()) {
     Engine engine = (Engine) service.getContainer();
     engine.addContainerListener(this);
     registerListenersForEngine(engine);
   }
 }
  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());
  }
Esempio n. 3
0
 @Override
 public void start() throws LifecycleException {
   // Use fast, insecure session ID generation for all tests
   Server server = getServer();
   for (Service service : server.findServices()) {
     Container e = service.getContainer();
     for (Container h : e.findChildren()) {
       for (Container c : h.findChildren()) {
         StandardManager m = (StandardManager) c.getManager();
         if (m == null) {
           m = new StandardManager();
           m.setSecureRandomClass("org.apache.catalina.startup.FastNonSecureRandom");
           c.setManager(m);
         }
       }
     }
   }
   super.start();
 }
  public void configure(Map<String, String> params) {
    String serviceId = params.get("service");

    Server server = ServerFactory.getServer();
    if (server == null) throw new NullPointerException("Could not get Tomcat server");

    Service service = null;
    if (serviceId != null) service = server.findService(serviceId);
    else {
      Service[] services = server.findServices();
      if (services != null && services.length > 0) service = services[0];
    }
    if (service == null)
      throw new NullPointerException(
          "Could not find Tomcat service for: " + (serviceId != null ? serviceId : "(default)"));

    engine = (Engine) service.getContainer();
    if (engine == null)
      throw new NullPointerException(
          "Could not find Tomcat container for: " + (serviceId != null ? serviceId : "(default)"));
  }