-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 回答