コード例 #1
0
 @Test
 public void testDistributeEjbApp() throws Exception {
   ProgressObject progress = jsr88Deploy(getEjbArchive());
   TargetModuleID[] targetModules = progress.getResultTargetModuleIDs();
   try {
     DeploymentStatus state = progress.getDeploymentStatus();
     assertEquals(StateType.COMPLETED, state.getState());
   } finally {
     jsr88Undeploy(targetModules);
   }
 }
コード例 #2
0
 @Test
 public void testDistributeEARApp() throws Exception {
   ProgressObject progress = jsr88Deploy(getEarArchive());
   TargetModuleID[] targetModules = progress.getResultTargetModuleIDs();
   try {
     DeploymentStatus state = progress.getDeploymentStatus();
     assertEquals(StateType.COMPLETED, state.getState());
     assertServletAccess("custom-context");
   } finally {
     jsr88Undeploy(targetModules);
   }
   try {
     assertServletAccess("custom-context");
     fail("Test deployment not undeployed");
   } catch (Exception e) {
     // ignore
   }
 }
コード例 #3
0
  private StateType awaitCompletion(ProgressObject progress, long timeout)
      throws InterruptedException {
    DeploymentStatus status = progress.getDeploymentStatus();
    if (status.isCompleted()) return null;

    final CountDownLatch latch = new CountDownLatch(1);
    progress.addProgressListener(
        new ProgressListener() {
          public void handleProgressEvent(ProgressEvent event) {
            DeploymentStatus status = event.getDeploymentStatus();
            if (status.isCompleted() || status.isFailed()) {
              latch.countDown();
            }
          }
        });

    if (latch.await(timeout, TimeUnit.MILLISECONDS) == false)
      throw new IllegalStateException("Deployment timeout: " + progress);

    return status.getState();
  }
コード例 #4
0
  public void handleProgressEvent(ProgressEvent progressEvent) {
    DeploymentStatus deploymentStatus = progressEvent.getDeploymentStatus();

    if (_log.isInfoEnabled()) {
      _log.info(deploymentStatus.getMessage());
    }

    if (deploymentStatus.isCompleted()) {
      try {
        TargetModuleID[] targetModuleIDs =
            _deploymentManager.getNonRunningModules(
                ModuleType.WAR, _deploymentManager.getTargets());

        if ((targetModuleIDs != null) && (targetModuleIDs.length > 0)) {
          for (TargetModuleID targetModuleID : targetModuleIDs) {
            if (!_warContext.equals(targetModuleID.getModuleID())) {
              continue;
            }

            ProgressObject startProgress =
                _deploymentManager.start(new TargetModuleID[] {targetModuleID});

            startProgress.addProgressListener(new StartProgressListener(_deploymentHandler));

            _deploymentHandler.setError(false);
            _deploymentHandler.setStarted(true);

            break;
          }
        } else {
          targetModuleIDs =
              _deploymentManager.getAvailableModules(
                  ModuleType.WAR, _deploymentManager.getTargets());

          for (TargetModuleID targetModuleID : targetModuleIDs) {
            if (!_warContext.equals(targetModuleID.getModuleID())) {
              continue;
            }

            ProgressObject startProgress =
                _deploymentManager.start(new TargetModuleID[] {targetModuleID});

            startProgress.addProgressListener(new StartProgressListener(_deploymentHandler));

            _deploymentHandler.setError(false);
            _deploymentHandler.setStarted(true);

            break;
          }
        }
      } catch (Exception e) {
        _log.error(e, e);

        _deploymentHandler.setError(true);
        _deploymentHandler.setStarted(false);
      }
    } else if (deploymentStatus.isFailed()) {
      _deploymentHandler.setError(true);
      _deploymentHandler.setStarted(false);
    }
  }