The arc: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 arc:import to import a library from the Global Assembly Cache (GAC) or from outside the classpath.
The arc: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 arc: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 arc:import keyword can then be used to select the JAR file to load.
The arc: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 arc:import to prefix the complete class name to a shorter name.
- 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.
Load version 2.0 of a library:
<arc:import lib="myops, Version=22.214.171.124" ns="MyCompany.MyOps" prefix="my2"/> <arc:call op="my2.Operation" ...>
Apply a custom “count” formatter defined in CustomFormatters.jar:
<arc:import lib="CustomFormatters.jar" ns="com.mycompany.Formatters" prefix="cust"/> <arc:set attr="size" value="[elem.number | cust.count]"/>