api:import
Version 23.0.8844
api:import
Version 23.0.8844
The api:import keyword allows you to select the correct version of a library when more than one is available. Optionally, it also allows you to bind the specified version to a namespace prefix.
You can use api:import to import a library from the Global Assembly Cache (GAC) or from outside the classpath.
Connector Versioning
The api:import keyword allows you to load multiple versions and then explicitly choose which version to use.
For the .NET edition, you can put connector and formatter assemblies into the GAC and use api:import to load the version you want in your scripts.
For the Java edition, you can put connector and formatter JAR files outside of the normal classpath (for example, in a subdirectory of your WEB-INF/lib folder), thus providing a way to keep multiple concurrent versions of the same JAR. The api:import keyword can then be used to select the JAR file to load.
Name Simplification
The api:import keyword can also help to simplify the name of an operation or formatter. For example, while custom formatters require the complete class name, you can use api:import to prefix the complete class name to a shorter name.
Parameters
- lib: The name of the library to import. In the .NET edition, this specifies the assembly name (preferably a fully qualified one). In the Java edition, this specifies the path to the JAR file.
- ns: The namespace that the operation or formatter name will be bound to. The specified namespace will be given priority during the lookup. If not specified, the normal rules for finding the implementation class will be used.
- prefix: The prefix to use to avoid name collisions when using operations or formatters that have the same name but are implemented in different libraries, different namespaces, or both. The ns attribute must be specified in addition to this parameter.
Control Attributes
None
Examples
Load version 2.0 of a library:
<api:import lib="myops, Version=2.0.0.0" ns="MyCompany.MyOps" prefix="my2"/>
<api:call op="my2.Operation" ...>
Apply a custom “count” formatter defined in CustomFormatters.jar:
<api:import lib="CustomFormatters.jar" ns="com.mycompany.Formatters" prefix="cust"/>
<api:set attr="size" value="[elem.number | cust.count]"/>