除了热部署之外,在jboss服务器中部署的任何其他选项?

时间:2012-04-12 07:03:14

标签: deployment jboss

我想知道除了热部署之外在jboss服务器中部署的方法是什么。

2 个答案:

答案 0 :(得分: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;
}

答案 1 :(得分:0)

只有在JBoss运行时才会认为部署很热。如果您不想进行热部署,可以关闭部署扫描程序[1]或停止JBoss并部署工件。

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