private void lookup(Method method, ResultCallback callback) {
    DeploymentTargetDescription deploymentTarget = locateDeployment(method);

    ContainerRegistry containerRegistry = this.containerRegistry.get();
    DeploymentScenario deploymentScenario = this.deploymentScenario.get();

    Deployment deployment = deploymentScenario.deployment(deploymentTarget);
    if (deployment == null && deploymentTarget != DeploymentTargetDescription.DEFAULT) {
      // trying to operate on a non existing DeploymentTarget (which is not the DEFAULT)
      throw new IllegalStateException(
          "No deployment found in "
              + DeploymentScenario.class.getSimpleName()
              + " for defined target: "
              + deploymentTarget.getName()
              + ". "
              + "Please verify that the @"
              + OperateOnDeployment.class.getSimpleName()
              + " annotation on method "
              + method.getName()
              + " match a defined "
              + "@"
              + org.jboss.arquillian.container.test.api.Deployment.class.getSimpleName()
              + ".name");
    }
    if (deployment != null) {
      Container container = containerRegistry.getContainer(deployment.getDescription().getTarget());
      callback.call(container, deployment);
    }
  }
  /**
   * Check is this should run as client.
   *
   * <p>Verify @Deployment.testable vs @RunAsClient on Class or Method level
   *
   * @param deployment
   * @param testClass
   * @param testMethod
   * @return
   */
  public static boolean isRunAsClient(
      Deployment deployment, Class<?> testClass, Method testMethod) {
    boolean runAsClient = true;
    if (deployment != null) {
      runAsClient = !deployment.getDescription().testable();
      runAsClient = !deployment.isDeployed() || runAsClient;

      if (testMethod.isAnnotationPresent(RunAsClient.class)) {
        runAsClient = true;
      } else if (testClass.isAnnotationPresent(RunAsClient.class)) {
        runAsClient = true;
      }
    }
    return runAsClient;
  }
  /**
   * @see
   *     org.jboss.arquillian.container.test.impl.client.container.ClientContainerController#stop(java.lang.String)
   */
  @Override
  public void stop(String containerQualifier, int timeout) {
    {
      DeploymentScenario scenario = getDeploymentScenario().get();
      if (scenario == null) {
        throw new IllegalArgumentException("No deployment scenario in context");
      }

      ContainerRegistry registry = getContainerRegistry().get();
      if (registry == null) {
        throw new IllegalArgumentException("No container registry in context");
      }

      if (!containerExists(registry.getContainers(), containerQualifier)) {
        throw new IllegalArgumentException("No container with the specified name exists");
      }

      if (!isControllableContainer(registry.getContainers(), containerQualifier)) {
        throw new IllegalArgumentException(
            "Could not start "
                + containerQualifier
                + " container. The container life cycle is controlled by Arquillian");
      }

      Container container =
          getContainerRegistry().get().getContainer(new TargetDescription(containerQualifier));

      List<Deployment> managedDeployments =
          scenario.startupDeploymentsFor(new TargetDescription(containerQualifier));

      for (Deployment d : managedDeployments) {
        if (d.isDeployed()) {
          log.info(
              "Automatic undeploying of the managed deployment with name "
                  + d.getDescription().getName()
                  + " from the container with name "
                  + container.getName());
          getContainerControllerEvent().fire(new UnDeployDeployment(container, d));
        }
      }

      log.info("Manual stopping of a server instance with timeout=" + timeout);

      getContainerControllerEvent().fire(new StopContainerWithTimeout(container, timeout));
    }
  }