Show Table of Contents
15.3. Deploying the New Resource
At this point, existing application can be updated. The next step is to create the resource through the CLI and then deploy it to the JBoss server.
First, get the resource type for the application. This depends on several parameters:
- The type of the application (e.g., WAR or EAR)
- The type of the container the app needs to be deployed on (such as Tomcat or JBoss AS 5)
NOTE
All of the information about the resource type, such as the appType and appTypeName, is defined in the resource agent plug-in, in the
rhq-plugin.xml descriptor. The attributes, configuration parameters, operations, and metrics for each default resource type are listed in the Resource Monitoring and Operations Reference.
For example:
var appType = ResourceTypeManager.getResourceTypeByNameAndPlugin( appTypeName, "JBossAS5" );
if( appType == null ) {
println(" Could not find application type. Exit.");
usage();
}
Then get the package type of the application.
var realPackageType = ContentManager.findPackageTypes( appTypeName, "JBossAS5" );
if( realPackageType == null ) {
println(" Could not find JBoss ON's packageType. Exit.");
usage();
}
Each resource in JBoss ON has some configuration parameters, including the WARs or EARs deployed on a JBoss AS 5 resource. As with the descriptive information, this is defined in the resource type's agent plug-in, in the
rhq-plugin.xml descriptor. To be able to create a new resource, these parameters need to be filled in.
// create deployConfig
var deployConfig = new Configuration();
deployConfig.put( new PropertySimple("deployExploded", "false"));
deployConfig.put( new PropertySimple("deployFarmed", "false"));
The property names can be retrieved by calling a list of supported properties by the package type by calling this method:
var deployConfigDef = ConfigurationManager.getPackageTypeConfigurationDefinition(realPackageType.getId());
Provide the package bits as a byte array:
var inputStream = new java.io.FileInputStream(file);
var fileLength = file.length();
var fileBytes = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, fileLength);
for (numRead=0, offset=0; ((numRead >= 0) && (offset < fileBytes.length)); offset += numRead ) {
numRead = inputStream.read(fileBytes, offset, fileBytes.length - offset);
}
Then, create the resource. The information is defined in the resource type's agent plug-in, in the
rhq-plugin.xml descriptor. For example:
ResourceFactoryManager.createPackageBackedResource(
server.id,
appType.id,
packageName,
null, // pluginConfiguration
packageName,
packageVersion,
null, // architectureId
deployConfig,
fileBytes,
null // timeout
);
Make sure that the given JBoss AS 5 server instance is still running and that JBoss ON knows that it is running, or it will throw an exception saying that the JBoss ON agent is not able to upload the binary content to the server.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.