Network Deployment (Distributed operating systems), v8.0 > Administer applications and their environment > Administer OSGi applications > Maintain an OSGi composition unit > Modify the configuration of an OSGi composition unit
Modify the configuration of an OSGi composition unit using wsadmin commands
We can use the editCompUnit command and the AdminConfig commands to modify the configuration information for a composition unit that contains an enterprise OSGi application. An OSGi composition unit consists of an EBA asset, (optionally) one or more composite bundle extensions, and configuration information for running the asset and composite bundle extensions in a business-level application. The configuration information can include HTTP session management, context roots, virtual hosts, security roles, run-as roles, and web application or Blueprint resource reference bindings for your OSGi application.
Before you begin
We can modify the configuration of an OSGi composition unit by using wsadmin as described in this topic, or by using the administrative console as described in Modify the configuration of an OSGi composition unit.
About this task
An OSGi composition unit consists of an EBA asset, (optionally) one or more composite bundle extensions, and some or all of the following configuration information:
- Maps from the composition unit to a target application server, web server or cluster.
- Configuration of the application's session manager, context roots or virtual hosts.
- Bindings to any associated web applications or blueprint resource references.
- Maps from security roles to particular users or groups.
You first specify the configuration of an EBA asset or composite bundle extension when you add it to a composition unit. If bundles in the asset or composite bundle extension are subsequently changed, or if remap resources, you can update the configuration. For example, if you update a bundle in an EBA asset, or replace a composite bundle extension, you might introduce a resource that requires additional configuration, such as a new or changed Blueprint resource reference, or security role mapping.
To configure all elements of the composition unit except the HTTP session manager, you use the editCompUnit command.
To configure the HTTP session manager, you use the AdminConfig commands to configure the deployed object represented by the appDeploy variable.
In the following procedure, all the steps and substeps are optional. You only need to re-configure the elements that have changed.
Procedure
- Configure all elements of the composition unit except the HTTP session manager.
Each of the following substeps describes the syntax for modifying a single element of the composition unit using the editCompUnit command. We can run the command once for each element, or you can modify several elements in a batch.
For several of the elements, the values you specify include bundle identifiers. If your EBA asset includes or references composite bundles, the command syntax is slightly different. For clarity, the differences for composite bundles are described, step by step, in a linked topic.
- Identify the composition unit to edit.
You identify a particular composition unit by specifying its business-level application ID and composition unit ID. Whenever you run the editCompUnit command, always include these two parameters in the command.
- -blaID
- Configuration ID of the business-level application.
- -cuID
- ID of the composition unit.
The jython syntax for this aspect of the command is as follows:
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name ... ]')For example:AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba ... ]')- Map the target node and server, or the target cluster.
We cannot edit the deployable unit URI (which, for a composition unit that contains an OSGi application, is ebaDeploymentUnit). We can edit the target node and server, or the target cluster.
To add an additional target, you use the plus sign character ( + ) as a prefix.
If the target is one cluster, the jython syntax for this aspect of the command is as follows:
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -MapTargets [[ebaDeploymentUnit WebSphere:cluster=cluster_name]] ]')For example:AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -MapTargets [[ebaDeploymentUnit WebSphere:cluster=cluster1]] ]')If the target is two servers, the jython syntax for this aspect of the command is as follows::
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -MapTargets [ [ebaDeploymentUnit WebSphere:node=node_name,server=server_nameFor example:WebSphere:node=node2_name,server=server2_name]] ]')
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -MapTargets [ [ebaDeploymentUnit WebSphere:node=node01,server=server1+ WebSphere:node=node01,server=web1]] ]')- Define WAB context roots.
Context roots determine where the web pages of a particular web application bundle (WAB) are found at run time. The context root that you specify here is combined with the defined server mapping to compose the full URL that you enter to access the pages of the WAB. For example, if the application server default host is www.example.com:8080 and the context root of the WAB is /sample, the web pages are available at www.example.com:8080/sample.
The jython syntax for this aspect of the command is as follows. The bundles listed under the ContextRootStep need to be all the WABs contained in the OSGi application.
For composite bundles, the syntax is slightly different. See Step: Define context roots for web application bundles (WABs) in composite bundles.
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -ContextRootStep [ [bundle_symbolic_name_1 bundle_version_1 context_root_1] [bundle_symbolic_name_2 bundle_version_2 context_root_2]] ]')For example, for an EBA file that contains two WABs (com.ibm.ws.eba.helloWorldService.web at version 1.0.0, which is to be mapped to /hello/web, and com.ibm.ws.eba.helloWorldService.withContextRoot at version 0.9.0, which is to be mapped to /hello/service), this aspect of the command is as follows:AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -ContextRootStep [ [com.ibm.ws.eba.helloWorldService.web 1.0.0 "/hello/web"] [com.ibm.ws.eba.helloWorldService.withContextRoot 0.9.0 "/hello/service"]] ]')- Map WABs to virtual hosts.
You use a virtual host to associate a unique port with a web application. The aliases of a virtual host identify the port numbers defined for that virtual host. A port number specified in a virtual host alias is used in the URL used to access artifacts such as servlets and JavaServer Page (JSP) files in a web application. For example, the alias myhost:8080 is the host_name:port_number portion of the URL //publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/ ://myhost:8080/sample.
Each WAB that is contained in a deployed asset must be mapped to a virtual host. WABs can be installed on the same virtual host, or dispersed among several virtual hosts.
If you specify an existing virtual host in the ibm-web-bnd.xml or .xmi file for a given WAB, the specified virtual host is set by default. Otherwise, the default virtual host setting is default_host, which provides several port numbers through its aliases:
- 80
- An internal, insecure port used when no port number is specified
- 9080
- An internal port
- 9443
- An external, secure port
Unless to isolate your WAB from other WABs or resources on the same node, default_host is a suitable virtual host. In addition to default_host, WAS provides admin_host, which is the virtual host for the administrative console system application. admin_host is on port 9060. Its secure port is 9043. Do not select admin_host unless the WAB relates to system administration.
The jython syntax for this aspect of the command is as follows.
For composite bundles, the syntax is slightly different. See Step: Map WABs in composite bundles to virtual hosts.
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -VirtualHostMappingStep [ [bundle_symbolic_name_1 bundle_version_1 web_module_name_1 virtual_host_1] [bundle_symbolic_name_2 bundle_version_2 web_module_name_2 virtual_host_2]] ]')For example, for an EBA file containing two WABs (com.ibm.ws.eba.helloWorldService.web at version 1.0.0, which is to be mapped to default_host, and com.ibm.ws.eba.helloWorldService.withContextRoot at version 0.9.0, which is to be mapped to test_host), this aspect of the command is as follows:AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -VirtualHostMappingStep [ [com.ibm.ws.eba.helloWorldService.web 1.0.0 "HelloWorld service" default_host] [com.ibm.ws.eba.helloWorldService.withContextRoot 0.9.0 "HelloWorld second service" test_host]] ]')- Map security roles to users or groups.
The jython syntax for this aspect of the command is as follows:
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -MapRolesToUsersStep [ [role_name everyone? all_authenticated_in_realm? usernames groups]] ]')Key:
- role_name is a role name defined in the application.
- everyone? is set to Yes or No, to specify whether or not everyone is in the role.
- all_authenticated_in_realm? is set to Yes or No, to specify whether or not all authenticated users can access the application realm.
- usernames is a list of WAS user names, separated by the "|" character.
- groups is a list of WAS groups, separated by the "|" character.
For usernames, and groups, the empty string "" means "use the default or existing value". The default value is usually that no users or groups are bound to the role. However, when an application contains an ibm-application-bnd.xmi file, the default value for usernames is obtained from this file. If you are deploying an application that contains an ibm-application-bnd.xmi file, and to remove the bound users, specify just the "|" character (which is the separator for multiple user names). This explicitly specifies "no users", and therefore guarantees that no users are bound to the role. For example:
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -MapRolesToUsersStep [ [ROLE1 No Yes "" ""] [ROLE2 No No WABTestUser1 ""] [ROLE3 No No "" WABTestGroup1] [ROLE4 Yes No "" ""]] ]')For more information about the -MapRolesToUsersStep option, see the information for the $AdminApp install command "MapRolesToUsers" option. This is the equivalent option for Java EE applications. For more general information, see Security role to user or group mapping.- Map RunAs roles to users
We can map a specified user identity and password to a RunAs role. This enables you to specify application-specific privileges for individual users, so that they can run specific tasks using another user identity. The jython syntax for this aspect of the command is as follows:
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -MapRunAsRolesToUsersStep [ [role_name user_name password]] ]')For example:AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -MapRunAsRolesToUsersStep [ [Role1 User1 password1] [AdminRole User3 password3]] ]')For more information about the -MapRunAsRolesToUsers option, see the information for the $AdminApp install command "MapRunAsRolesToUsers" option. This is the equivalent option for Java EE applications. For more general information, see Map RunAs roles to users.
- Add authentication aliases to Blueprint resource references.
Blueprint components can access WAS resource references. Each reference is declared in a Blueprint XML file, and can be secured using a Java EE Connector Architecture (JCA) authentication alias. Each bundle in an OSGi application can contain any number of resource reference declarations in its various Blueprint XML files.
When you secure resource references, those resource references can be bound only to JCA authentication aliases that exist on every server or cluster on which the application is deployed. An OSGi application can be deployed to multiple servers and clusters that are in the same security domain. Therefore, each JCA authentication alias must exist in either the security domain of the target servers and clusters, or the global security domain.
We must declare the resource references in the Blueprint XML file. For example:
<blueprint xmlns="//publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/ ://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:rr="//publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/ ://www.ibm.com/appserver/schemas/8.0/blueprint/resourcereference"> <!-- Other Blueprint declarations ... --> <rr:resource-reference id="resourceRef" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=jdbc/Account)"> <rr:res-auth>Container </rr:res-auth> <rr:res-sharing-scope>Shareable </rr:res-sharing-scope> </rr:resource-reference> </blueprint>This declaration includes the resource reference ID (for example resourceRef), the service filter (for example jdbc/Account), the authentication type (for example Container), and the sharing setting (for example Shareable).The Blueprint resource references to authentication alias bindings for each bundle are stored in a file ibm-eba-bnd.xml in the META-INF directory of that bundle. If an OSGi application contains any of these files when it is deployed as an asset, these files provide the default authentication alias values that are used when binding the resource references. For example:
<eba-bnd xmlns="//publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=/ ://www.ibm.com/blueprintbinding.xsd"> <resource-ref> <jndi-name>jdbc/Acount </jndi-name> <authentication-alias>Alias1 </authentication-alias> <interface>javax.sql.DataSource </interface> <authentication>Container </authentication> <sharing-scope>Shareable </sharing-scope> <id>resourceRef </id> </resource-ref> </eba-bnd>The jython syntax for this aspect of the command is as follows.
For composite bundles, the syntax is slightly different. See Step: Add authentication aliases to Blueprint resource references in composite bundles.
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -BlueprintResourceRefPostDeployStep [ [ bundle_symbolic_name bundle_version blueprint_resource_reference_id interface_name jndi_name authentication_type sharing_setting authentication_alias_name ]] ]')The value for jndi_name must match the jndi name that you declare in the filter attribute of the resource reference element in the Blueprint XML file. For example, for an EBA file that contains a bundle com.ibm.ws.eba.helloWorldService.properties.bundle.jar at v1.0.0, which is to be bound to authentication alias alias1, the command is as follows:
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -BlueprintResourceRefPostDeployStep[ [com.ibm.ws.eba.helloWorldService.properties.bundle 1.0.0 resourceRef javax.sql.DataSource jdbc/Account Container Shareable alias1]] ]')- Bind web module message destination and resource environment references.
Binding a resource reference maps a resource dependency of the web application to an actual resource available in the server runtime environment. At a minimum, this can be achieved by using a mapping that specifies the JNDI name under which the resource is known in the runtime environment. By default, the JNDI name is the resource ID specified in the web.xml file during development of the web application bundle (WAB). Use this option to bind resources of type message-destination-ref (message destination reference) or resource-env-ref (resource environment reference), as defined in the Java specification JSR-250: Common Annotations for the Java Platform.
The jython syntax for this aspect of the command is as follows.
For composite bundles, the syntax is slightly different. See Step: Bind web module message destination and resource environment references in composite bundles.
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -WebModuleMsgDestRefs [ [ bundle_symbolic_name bundle_version resource_reference_id resource_type target_jndi_name ]] ]')For example:AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -WebModuleMsgDestRefs [ [com.ibm.ws.eba.helloWorldService.web 1.0.0 jms/myQ javax.jms.Queue jms/workQ] [com.ibm.ws.eba.helloWorldService.web 1.0.0 jms/myT javax.jms.Topic jms/notificationTopic]] ]')- Bind web module resource references.
Binding a resource reference maps a resource dependency of the web application to an actual resource available in the server runtime environment. At a minimum, this can be achieved by using a mapping that specifies the JNDI name under which the resource is known in the runtime environment. By default, the JNDI name is the resource ID specified in the web.xml file during development of the web application bundle (WAB). Use this option to bind resources of type resource-ref (resource reference), as defined in the Java specification JSR-250: Common Annotations for the Java Platform.
The jython syntax for this aspect of the command is as follows.
For composite bundles, the syntax is slightly different. See Step: Bind web module resource references in composite bundles.
AdminTask.editCompUnit('[ -blaID WebSphere:blaname=bla_name -cuID WebSphere:cuname=cu_name -WebModuleResourceRefs [ [ bundle_symbolic_name bundle_version resource_reference_id resource_type target_jndi_name login_configuration login_properties extended_properties ]] ]')For example:AdminTask.editCompUnit('[ -blaID WebSphere:blaname=helloWorldService -cuID WebSphere:cuname=com.ibm.ws.eba.helloWorldService_0001.eba -WebModuleResourceRefs [ [com.ibm.ws.eba.helloWorldService.web 1.0.0 jdbc/jtaDs javax.sql.DataSource jdbc/helloDs "" "" ""] [com.ibm.ws.eba.helloWorldService.web 1.0.0 jdbc/nonJtaDs javax.sql.DataSource jdbc/helloDsNonJta "" "" "extprop1=extval1"]] ]')If you use multiple extended properties, the jython syntax is "extprop1=extval1,extprop2=extval2".
- Configure the HTTP session manager.
To configure the HTTP session manager, you use the AdminConfig commands to configure the deployed object represented by the appDeploy variable. Session management for OSGi applications is configured in the same way as for enterprise applications, except for a minor difference in syntax when getting the deployed object.
- Get the deployed object.
Use the instructions given in Configure applications for session management using scripting. Note that, for enterprise applications, you use the following two line script:
deployments = AdminConfig.getid('/Deployment:myApp/') appDeploy = AdminConfig.showAttribute(deployments, 'deployedObject')For OSGi applications, the equivalent script is the following single line:appDeploy = AdminTask.getOSGiApplicationDeployedObject('-cuName cu_name')where cu_name is the name of the composition unit. For example:appDeploy = AdminTask.getOSGiApplicationDeployedObject(' -cuName com.ibm.ws.eba.helloWorldService_0001.eba')
- Create or modify the session management options.
Use the instructions given in Configure applications for session management using scripting. The command usage for creating and modifying session management options is exactly the same for enterprise applications and OSGi applications.
What to do next
After using these commands, save changes to the master configuration by using the following command:
AdminConfig.save()
When you save the changes to the composition unit, the associated business-level application is updated to use the new configuration. If the business-level application is running, the bundle and configuration updates are applied immediately. If possible (that is, depending on the nature of the updates) the system applies the updates without restarting the application. If you update a bundle that provides only OSGi services to the rest of the application, then only that bundle is restarted. If you update a bundle that provides one or more packages to other bundles, then those bundles and any bundles to which they provide packages are restarted. If, however, a new package or service dependency is added, or an existing package or service dependency is removed, then the application is restarted; a newly added package and service can come from a newly-provisioned bundle, or from a bundle that has already been provisioned. Messages relating to any restart operations are written to the WAS SystemOut.log file.
Subtopics
- Modify the configuration of an OSGi composition unit that includes composite bundles using the editCompUnit command
We can use the editCompUnit command to modify the configuration information for a composition unit that contains an enterprise bundle archive (EBA) asset. If the EBA asset includes composite bundles, the command syntax is slightly different.
Parent topic: Modify the configuration of an OSGi composition unit
Related concepts:
About OSGi ApplicationsRelated tasks:
Secure OSGi Applications
Manage composition units using wsadmin.sh
Configure applications for session management using scriptingRelated reference:
OSGi Applications: Troubleshooting tips
BLAManagement command group using wsadmin.sh
Task topic Feedback
Copyright IBM Corporation 2009, 2011. All Rights Reserved.
This information center is powered by Eclipse technology.