Managing composition units using wsadmin scripting
Use the commands in the BLAManagement command group to manage composition units. Use the examples in this topic to add, remove, edit, export, and view composition units.
Before you begin
There are two ways to complete the examples in this task. Use the BLAManagement command group for the AdminTask object to manage composition units. Alternatively, you can use the scripts in the AdminBLA script library to administer your composition unit configurations.
About this task
Composition units can represent deployed assets, other business-level applications, or external artifacts that are deployed on non-WebSphere® Application Server runtime environments without associated assets. Business-level applications contain zero or more composition units. You cannot add the same composition unit to more than one business-level application, but you can use one asset to create more than one composition unit.
Procedure
- Add composition units.
- Start the wsadmin scripting tool.
- Add composition units. Use the addCompUnit command to add composition units to business-level applications.Note: If the asset is an enterprise bundle archive (EBA) asset, there are additional parameters to set. For more information, see information about adding an EBA asset to a composition unit using the addCompUnit command.Use the following command example to add the
asset1
asset as a composition unit in themyBLA
business-level application, and map the deployment to theserver1
server:AdminTask.addCompUnit('-blaID myBLA -cuSourceID
asset1
-CUOptions [[.* .*compositionUnit1
"composition unit that is backed by asset1
"0
]] -MapTargets [[.*server1
]] -ActivationPlanOptions [.*specname=actplan0+specname=actplan1
]')Use the following command to add theasset2
asset as a composition unit in themyBLA
business-level application, and map the deployment to theserver1
andtestServer
servers:AdminTask.addCompUnit('-blaID myBLA -cuSourceID
asset2
-CUOptions [[.* .*compositionUnit2
"composition unit that is backed by asset2
"0
]] -MapTargets [[.*server1+testServer
]] -ActivationPlanOptions [.*specname=actplan0+specname=actplan1
]')Use the following command to add theJ2EEAsset
asset as a composition unit in themyBLA
business-level application, and map the deployment to theserver1
andtestServer
servers:AdminTask.addCompUnit('[-blaID myBLA -cuSourceID
J2EEAsset
-defaultBindingOptionsdefaultbinding.ejbjndi.prefix=ejb# defaultbinding.virtual.host=default_host# defaultbinding.force=yes
-AppDeploymentOptions [-appnamedefaultapp
-installed.ear.destinationapplication_root/myCell/defaultapp.ear
] -MapModulesToServers [[defaultapp.war
.*WebSphere:cell=cellName,node=nodeName,server=server1
][Increment.jar
.*Websphere:cell=cellName,node=nodeName,server=testServer
]] -CtxRootForWebMod [[defaultapp.war .* myctx/
]]]')If you are editing a composition unit to update a shared library, you must first manually stop all Java EE applications that depend on that shared library. After updating the shared library, manually restart the Java EE applications. Java EE applications do not automatically restart when a shared library is updated.
The command returns the configuration IDs of the composition unit and the new composition unit created for the asset in the asset relationship, as the following example displays:WebSphere:cuname=compositionUnit1 WebSphere:cuname=compositionUnit2 WebSphere:cuname=J2EEAsset
- Save your configuration changes. Use the following command example to save your configuration changes:
AdminConfig.save()
- Display composition units and configuration settings.
Use the listCompUnits and viewCompUnits commands to display the configuration IDs of each composition unit that matches a specific search scope.
You can use the listCompUnits command to display each composition unit in your configuration or within a specific business-level application. The following example displays each composition unit in themyBLA
business-level application:AdminTask.listCompUnits('-blaID
blaname=myBLA
')The command returns the configuration IDs and type of backing asset for each composition unit that matches the search scope, as the following sample displays:Websphere:cuname=cu1 asset Websphere:cuname=cu4 bla WebSphere:cuname=defaultapp __j2ee
You can use the viewCompUnits command to display additional configuration information about a specific composition unit of a business-level application. For example, the following example displays additional information about thecu1
composition unit for themyBLA
business-level application:AdminTask.viewCompUnit('-blaID myBLA -cuID
cu1
')The command returns detailed configuration information for the composition unit, as the following sample displays:Specify Composition Unit options (CUOptions) Specify name, description options for Composition Unit. Parent BLA (parentBLA): [WebSphere:blaname=myBLA] Backing Id (backingId): [WebSphere:assetname=asset1.zip] Name (name): [cu1] Description (description): [my description of cu1 composition unit] Starting Weight (startingWeight): [0] Specify servers (MapTargets) Specify targets such as application servers or clusters of application servers where you want to deploy the composition unit contained in the application. Deployable Unit (deplUnit): [default] *Servers (server): [WebSphere:node=myNode,server=server1] Specify Composition Unit activation plan options (ActivationPlanOptions) Specify composition unit activation plan optionsDeployableUnit Name (deplUnit): [default] Activation Plan (activationPlan): [WebSphere:specname=actplan0+WebSphere:specname=actplan1]
If the composition unit contains an enterprise bundle archive (EBA) asset, the composition unit status is also displayed. This status is one of the following values:- Using latest OSGi application deployment.
- New OSGi application deployment not yet available because it requires bundles that are still downloading.
- New OSGi application deployment available.
- New OSGi application deployment cannot be applied because bundle downloads have failed.
- Edit composition units.
- Start the wsadmin scripting tool.
- Modify the composition unit. Use the editCompUnit command to modify composition unit options. You can use this command to modify the starting weight of the composition unit, deployment targets, activation plan options, and relationship settings. See the documentation for the BLAManagement command group for the AdminTask object to view descriptions of each option that you can modify.Note: If the composition unit contains an enterprise bundle archive (EBA) asset, there are additional parameters that you can modify. For more information, see information about modifying the configuration of an OSGi composition unit using the editCompUnit command.The following example edits a composition unit, which is associated with an asset, and replaces the deployment target:
AdminTask.editCompUnit('-blaID myBLA -cuID
cu1
-CUOptions [[.* .*cu1 cudesc 1
]] -MapTargets [[.*server2
]] -ActivationPlanOptions [.* #specname=actplan0+specname=actplan2
]')The command returns the configuration ID of the composition unit that the system edits, as the following sample displays:WebSphere:cuname=cu1
- Save your configuration changes. Use the following command example to save your configuration changes:
AdminConfig.save()
- Remove composition units.
- Start the wsadmin scripting tool.
- Remove composition units. Use the deleteCompUnit command to remove a composition unit. Both parameters for the following command accept incomplete configuration IDs, as long as the system can match the string to a unique ID:
AdminTask.deleteCompUnit('-blaID myBLA -cuID
cu1
')The command returns the configuration ID of the composition unit that the system deletes, as the following sample demonstrates:WebSphere:cuname=cu1
- Save your configuration changes. Use the following command example to save your configuration changes:
AdminConfig.save()