Overview
A far file is a versioned package containing java archives (jar/zip files), native code dynamic libraries (dll/so files) and other support files that can be shared between several fabric applications. This package is deployed to a running fabric. In addition, libraries listed in the far XML file will be visible to any fabric application that references that far file in its fabric application definition XML. Java jars listed in the java-libs element will be seen by the fabric application's Java class loader. Native dynamic libraries listed in the libs element will be loadable by the fabric application.
All files included by the far must be in the same directory or a subdirectory as the far XML, and the pathname must be a relative path.
Far XML sample
<?xml version="1.0"?>
<far name="deployable_misc_stuff" verison="1.2.3">
<java-libs>
<file name="somejar.jar"/>
<file name="some_subdir/someOtherJar.jar"/>
</java-libs>
<libs>
<file name="some_dependency.dll"/>
<file name="subdir/some_other_dependency.dll"/>
</libs>
<support-files>
<file name="something.txt"/>
<file name="subdir/something_else.txt"/>
</support-files>
</far>
Tag descriptions
| Element |
Description |
| far |
This is the root element for the far definition file.
| Attribute |
Description |
| name |
This is the name of the far and the handle used by app xml. This element is required and must be a FabricIdentifier. |
| version |
The version is used for spreading new versions of the far file to all nodes on the fabric; deploying a far with an incremented version will result in that far file replacing previous versions on all nodes of the fabric |
The far element defines the following child elements:
| Element |
Cardinality |
Description |
| libs |
0..1 |
Native code and .Net libraries to be included in the far. |
| java-libs |
0..1 |
Java libraries (jars) to be included in the far. |
| support-files |
0..1 |
Extraneous files to be included in the far. |
|
| libs |
This tag holds a file list for DLLs (on Windows) and shared libraries (Linux) that are to be included in the far package. The runtime environment of fabric applications that reference the far will be updated (i.e., the PATH environment variable on Windows and the LD_LIBRARY_PATH environment variable on Linux) with the containing directory of the library.
The libs element defines a single child element:
| Element |
Cardinality |
Description |
| file |
1..n |
File to be added to the package and PATH/LD_LIBRARY_PATH. |
Simple libs example:
<libs>
<file name="some_dependency.dll"/>
<file name="subdir/some_other_dependency.dll"/>
</libs>
|
| java-libs |
Like the libs tag above, this tag holds a file list for jars to be included in far package. Any jar files listed here will be visible to the user's Java code as if they were listed in the classpath.
The java-libs tag defines a single child element:
| Element |
Cardinality |
Description |
| file |
1..n |
Jar file to be added to the package. |
Sample java-libs tag:
<java-libs>
<file name="some_dependency.jar"/>
<file name="subdir/some_other_dependency.jar"/>
</java-libs>
|
| support-files |
Similar in function to the support-files tag in the application xml, except that the files are packaged with the far.
The support-files tag defines a single child element:
| Element |
Cardinality |
Description |
| file |
1..n |
Miscellaneous file to be added to the package. From within the fabric, these files can be found by fabric application by prepending '../../fars/far-name' to the pathname of the file, where far-name is the far name. |
<support-files>
<file name="data_file.txt"/>
<file name="subdir/other_data_file.dat"/>
</support-files>
|
| file |
This element is the listing for a single file in the far definition. It has a single attribute:
| Attribute |
Description |
| name |
This is name of the file, or more specifically, the path to the file relative to the directory containing the far xml definition. The file can reside in a subdirectory of the far's directory, but my not reside in directories above it. |
|
Far file creation
The far is packaged with fabric_pkg. After the far xml file has been created and the files moved into the appropriate directory hierarchy, the deployable far file can be created with fabric_pkg create. Once created, the .far file can be deployed to the fabric using the fabric_ctl command, in the same manner as deploying a .fabric file.
App packaging with far dependency
When packaging an application with a reference to a far, one should take care to provide the location of the .far to fabric_pkg. By default, fabric_pkg will look in $FABRIC_HOME/fars for any far files it needs for packaging; the far lookup directory can be changed by using the -fars-dir option in fabric_pkg. If, for some reason, a far file listed in App XML is not present, fabric_pkg will print a warning message, but will continue to try packaging the application. In the case that the CLASSPATH or LD_LIBRARY_PATH/PATH are already set properly on the user's development environment, the application should package. Otherwise, errors will occur later in the packaging process due to unsatisfied dependencies. Once the application is deployed, however, the application will refuse to start unless its far dependencies are met and the correct fars are deployed.
Far XML Schema
<?xml version='1.0' encoding='utf-8'?>
<xs:schema id='FabricArchive' targetNamespace='http://www.appistry.com/far'
elementFormDefault='qualified' xmlns='http://www.appistry.com/far'
xmlns:mstns='http://www.appistry.com/far'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='far'>
<xs:complexType>
<xs:all>
<xs:element ref='java-libs' minOccurs='0' maxOccurs='1' />
<xs:element ref='libs' minOccurs='0' maxOccurs='1' />
<xs:element ref='support-files' minOccurs='0' maxOccurs='1' />
</xs:all>
<xs:attribute name='name' type='xs:string' use='required'/>
<xs:attribute name='version' type='xs:string' use='required'/>
</xs:complexType>
</xs:element>
<xs:element name='java-libs'>
<xs:complexType>
<xs:sequence>
<xs:element ref='file' minOccurs='1' maxOccurs='unbounded' />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='libs'>
<xs:complexType>
<xs:sequence>
<xs:element ref='file' minOccurs='1' maxOccurs='unbounded' />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='support-files'>
<xs:complexType>
<xs:sequence>
<xs:element ref='file' minOccurs='1' maxOccurs='unbounded' />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name='file'>
<xs:complexType>
<xs:attribute name='name' type='xs:string' use='required'/>
</xs:complexType>
</xs:element>
</xs:schema>