此内容没有您所选择的语言版本。

16.2. Updating Applications


Updating an application is simpler than creating one because the bundle definition already exists.
To update an application, give the path to the updated bundle archive, any tokens or properties to set, and the existing bundle destination.
rhqadmin@localhost:7080$ var bundleZipFile = /export/bundles/myBundle.zip 
rhqadmin@localhost:7080$ var deploymentConfiguration = null
rhqadmin@localhost:7080$ var jbasDestination = "My App - JBoss EAP 6 Destination"
rhqadmin@localhost:7080$ updateAppAndRestartJBAS(bundleZipFile, jbasDestination, deploymentConfiguration)
Copy to Clipboard Toggle word wrap
If the bundle requires any tokens to be realized, like a port number to be entered, then you must create a configuration object and pass the values to that. In this example, no properties are passed, so the value is null. Details about the configuration are in the comments in the bundles.js file and general configuration information is in Section 12.5.2, “Changing Simple Configuration Properties”.
The destination identifier — which could be the destination name or the ID — is used in a criteria search to fetch the resource type for the compatible group. This, as with the create function, identifies which version of JBoss EAP is being used.
function updateAppAndRestartJBAS(bundleZipFile, jbasDestination, deploymentConfiguration) {
    // first figure out the jbas version we are deploying to
    var destinationId = jbasDestination;
    if (typeof(jbasDestination) == 'object') {
        destinationId = jbasDestination.id;
    }

    var destCrit = new BundleDestinationCriteria
    destCrit.fetchGroup(true)
Copy to Clipboard Toggle word wrap
It uses the name to search for the destination ID. When it retrieves the destination entry (in the get(0) call), the destination configuration contains the resource type.
    var destinations = BundleManager.findBundleDestinationsByCriteria(destCrit);

    if (destinations.empty) {
        throw "No destinations corresponding to " + jbasDestination + " found on the server.";
    }

    var destination = destinations.get(0);

    var targetResourceType = destination.group.resourceType;

    if (targetResourceType == null) {
        throw "This function expects a compatible group of JBoss AS (4,5,6 or 7) resources but the provided destination is connected with " + destination.group;
    }
Copy to Clipboard Toggle word wrap
Then, it uploads the new bundle archive as a new bundle version, in the createBundleVersion method.
    var deployFn = function(restartFn) {
	var bundleVersion = createBundleVersion(bundleZipFile);
Copy to Clipboard Toggle word wrap
Then, it deploys the new bundle version to the existing destination, along with any defined or required tokens in a configuration object (deploymentConfiguration). When the deployment completes, it restarts the JBoss resources in the group and prints the deployment information.
        var deployment = deployBundle(destination,bundleVersion, deploymentConfiguration, "Web application", false);

        if (deployment.status != BundleDeploymentStatus.SUCCESS) {
            throw "Deployment wasn't successful: " + deployment;
        }

        restartFn(destination.group);

        return deployment;
    };
Copy to Clipboard Toggle word wrap
As with the creation function, there are version-specific restart methods for any supported version of JBoss EAP: 4, 5, or 6. The bundle system uses the configuration defined in the resource plug-in, based on the resource type of the group.
    if (targetResourceType.plugin == "JBossAS" && targetResourceType.name == "JBossAS Server") {
        return deployFn(_restartAS4);
    } else if (targetResourceType.plugin == "JBossAS5" && targetResourceType.name == "JBossAS Server") {
        return deployFn(_restartAS5);
    } else if (targetResourceType.plugin == "JBossAS7" &&
            (targetResourceType.name == "JBossAS7 Standalone Server" ||
                    targetResourceType.name == "JBossAS-Managed")) {
        return deployFn(_restartAS7);
    }

    throw "The resource group the destination targets doesn't seem to be a JBoss AS server group.";
}
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat