previous next trail start tutorial home feedback openwings.org

Dependency Substitution

Openwings has a substitution feature that you can use when describing component dependencies in your InstallableComponentDescriptorPolicy. Most often this mechanism is used to inherit dependencies from other components.

At this point in the tutorial it is assumed you have been introduced to the new Installer properties feature (introduced in Openwings 0.9.2) and you have been introduced to the notion of component dependencies. This tutorial tells you how dependencies can be specified. As you may have guessed, they are specified by using the Properties object in the InstallableComponentDescriptorPolicy.

To use this mechanism, the variable must be of the form ${variable}. For the beta release, dependencies in the Resolvable Codebase and Resolvable Classpath attributes can be listed as:

  • ${componentName[-version].classpath}
  • ${componentName[-version].codebase}
  • ${componentName[-version].property.propertyKey}/[someFile.jar]
  • a URL

Alternatively, consider using a key/value pair found in the properties file of Openwings. You can find these key/value pairs in the properties.txt file. If you put an entry in the resolvable classpath like this:

http://$(net.openwings.hostport}/gd_openwings_dl.jar

the policy loader in Container Services will substitute ${variable} as:

http://<host name>:<port>/gd_openwings_dl.jar

It's important to know what happens during substitution. Briefly, the values listed in one component are substituted in another component.

Consider the following:

CompXService has no dependencies and its Resolvable Classpath array contains references to itself:

${CompXService.property.net.openwings.install.libDir}/CompXService.jar
${CompXService.property.net.openwings.install.libDir}/CompXServiceSynchronous_cns.jar
${CompXService.property.net.openwings.install.libDir}/CompXServiceAsynchronous_cna.jar

When the Resolvable Classpath array is substituted for CompX, it will substitute everything of the form ${variable} and create the following URLs in its classpath.

file:/c:/openwings/CompXService/lib/CompXService.jar
file:/c:/openwings/CompXService/lib/CompXServiceSynchronous_cns.jar
file:/c:/openwings/CompXService/lib/CompXServiceAsynchronous_cna.jar

Now consider the next component that has a dependency on CompXService. CompY lists in its Resolvable Classpath array:

${CompY.property.net.openwings.install.libDir}/CompY.jar
${CompXService.classpath}
${openwings.classpath}

When the Resolvable Classpath array is substituted for CompY, it will substitute everything of the form ${variable} and create the following URLs in its classpath :

file:/c:/openwings/CompY/lib/CompY.jar
file:/c:/openwings/CompXService/lib/CompXService.jar
file:/c:/openwings/CompXService/lib/CompXServiceSynchronous_cns.jar
file:/c:/openwings/CompXService/lib/CompXServiceAsynchronous_cna.jar
file:/c:/openwings/openwings-1.0/lib/gd_openwings.jar

Everything listed in the classpath array for CompXService was substituted and added to the classpath array for CompY. Notice the number of entries increased. Also the order of dependencies were preserved. This approach allows for the best control of the ordering of dependencies as well as automated resolution.

Generally, when building dependencies in the Resolvable Codebase and Resolvable Classpath, the following conventions are encouraged.

  • refer to your own component first
  • refer to any dependent components
  • add ${openwings.classpath}/${openwings.codebase} last

Substitutions will only take place if the dependent component is in a RESOLVED state. If the dependent component is in an INSTALLED state, substitution will not take place and the component itself will not be able to be resolved.

You can specify a particular version of a component if more than one version of a component exists. If you do not specify a particular version, Install Service will use the most recently installed version that is in a RESOLVED state. Click here for more thorough explanation of this concept.

Finally, be aware of creating circular dependencies. Components cannot reach a RESOLVED state if circular dependencies exist.

The dependency substitution mechanism does not only apply to the codebase and classpath fields. Substitution can also take place in these InstallableComponentDescriptorPolicy fields:

Click here for a summary table of what key/value pairs are recognized by the Openwings install service and how it conducts substitution.

Next: Component Packaging

back to top

Copyright 2002, General Dynamics Decision Systems. All rights reserved.

previous next trail start tutorial home feedback openwings.org