api:import
Version 23.0.9145
Version 23.0.9145
api:import
Use the api:import
keyword to select the correct version of a library when more than one is available. You can also use it 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
api:import
allows you to load multiple versions, 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 Cross-Platform 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. You can then use api:import
to select which JAR file to load.
Name Simplification
The api:import
keyword can also help 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, specify the assembly name (preferably a fully qualified one). In the Cross-Platform edition, specify the path to the JAR file.
- ns: The namespace that the operation or formatter name is bound to. The specified namespace is given priority during the lookup. If not specified, the normal rules for finding the implementation class are 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 with 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]"/>