2012-04-12 10 views

答えて

0

デプロイメントは、JBossの実行中にのみホットと見なされます。ホットデプロイメントが必要ない場合、デプロイメントスキャナ[1]をオフにするか、JBossを停止してアーティファクトをデプロイできます。

[1] https://community.jboss.org/wiki/ConfiguringTheDeploymentScannerInConfjbossSystemxml 
3

クライアントや計画を構築するビルダー取得:

ModelControllerClient client = ModelControllerClient.Factory.create(host, port); 
ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client); 
DeploymentPlanBuilder builder = manager.newDeploymentPlan(); 

と操作のいずれかの種類を実行するための方法(ここではいくつかのものが実装されています):

public DeployementActionStatus execute(Type deploy) throws IOException 
{ 
    List<Throwable> errors = new LinkedList<Throwable>(); 
    DeployementActionStatus status = DeployementActionStatus.SUCCESS; 

    switch (deploy) 
    { 
    case DEPLOY: 
     if (archive != null) 
     { 
      plan = builder.add(archive).deploy(archive.getName()).build(); 
     } 
     else 
     { 
      return DeployementActionStatus.FAILURE; 
     } 

     break; 
    case REDEPLOY: 
    { 
     if (archive != null) 
     { 
      plan = builder.redeploy(archive.getName()).build(); 
     } 
     else 
     { 
      return DeployementActionStatus.FAILURE; 
     } 

     break; 
    } 
    case UNDEPLOY: 
    { 
     plan = builder.undeploy(getApplicationName()).build(); 
     break; 
    } 
    case REMOVE: 
    { 
     plan = builder.remove(getApplicationName()).build(); 
     break; 
    } 

    default: 
     plan = null; 
     break; 
    } 
    if (plan == null) 
    { 
     throw new IllegalStateException("Invalid type: " + deploy); 
    } 

    if (plan.getDeploymentActions().size() > 0) 
    { 
     try 
     { 
      final ServerDeploymentPlanResult planResult = manager.execute(plan).get(); 

      // Check the results 
      for (DeploymentAction action : plan.getDeploymentActions()) 
      { 
       final ServerDeploymentActionResult actionResult = planResult.getDeploymentActionResult(action 
         .getId()); 
       final ServerUpdateActionResult.Result result = actionResult.getResult(); 
       switch (result) 
       { 
       case FAILED: 
       case NOT_EXECUTED: 
       case ROLLED_BACK: 
       { 
        log.error(actionResult.getDeploymentException()); 
        if (actionResult.getDeploymentException().getMessage() != null 
          && actionResult.getDeploymentException().getMessage().contains("Duplicate")) 
        { 
         status = DeployementActionStatus.FAILURE_ALREADY_DEPLOYED; 
        } 
        else 
        { 
         status = DeployementActionStatus.FAILURE; 
        } 
        break; 
       } 
       case CONFIGURATION_MODIFIED_REQUIRES_RESTART: 
        // Should show warning 
        break; 
       default: 
        break; 
       } 
      } 

     } 
     catch (InterruptedException e) 
     { 
      errors.add(e); 
      status = DeployementActionStatus.FAILURE; 
     } 
     catch (ExecutionException e) 
     { 
      errors.add(e); 
      status = DeployementActionStatus.FAILURE; 
     } 
     catch (Exception e) 
     { 
      if (e instanceof RuntimeException) 
      { 
       status = DeployementActionStatus.CONNECTION_TO_SERVER_FAILED; 
      } 
     } 
    } 
    return status; 
} 
関連する問題