-3

ホットデプロイメント以外にjbossサーバーにデプロイする方法を知りたいです。

4

2 に答える 2

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;
}
于 2012-12-18T17:43:24.747 に答える
0

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

[1] https://community.jboss.org/wiki/ConfiguringTheDeploymentScannerInConfjbossSystemxml
于 2012-04-14T00:56:33.567 に答える