Shared libraries
Shared libraries are files used by multiple applications. You can use shared libraries and global libraries to reduce the number of duplicate library files on your system.
Library elements
Liberty libraries have three elements: <folder>, <file>,
and <fileset>. For
example:
<library>
<folder dir="..." />
<file name="..." />
<fileset dir="..." includes="*.jar" scanInterval="5s" />
</library>
A specified file must be a container for the resource (for example a JAR file) rather than the resource itself.
If an element in the list is a file, the contents of that JAR or compressed .zip file are searched. If a folder is specified then resources are loaded from that directory.
Global libraries
Global libraries can be used by any application. JAR files are placed in a global library directory, and then are specified in the class loader configuration for each application.
You can place global libraries in two
locations:
- ${shared.config.dir}/lib/global
- ${server.config.dir}/lib/global
For more information, see Providing global libraries for all Java EE applications.
Resource files
Within Liberty libraries, you can have resource files defined in the library element. For
example,
<library>
<folder dir="..." />
<file name="..." />
<fileset dir="..." includes="*.jar" scanInterval="5s" />
<folder dir="${server.config.dir}/mylibs" />
<file name="${server.config.dir}/otherlibs/my.jar" />
</library>
The
folder setting in the example, allows all files under the mylibs directory to
be available on the classpath. You can use this style of entry to have your
.xml and .properties available.Library elements
Liberty libraries have three child elements, <folder>,
<file> and <fileset>. For
example,
<library>
<folder dir="..." />
<file name="..." />
<fileset dir="..." includes="*.jar" scanInterval="5s" />
</library>
- <folder>: All resources under each configured folder will be loadable
- <file>: Each configured file should be either a native library or a container for resources (such as a JAR or a ZIP file). All resources within a container are loadable and any other filetype that is specified will have no effect.
- <fileset>: Each configured fileset is effectively a collection of files. Each file in the fileset should be a native library or a container for resources (such as a JAR or a ZIP file). All resources within a container are loadable and any other filetype that is specified will have no effect.
For
example,
<library id="someLibrary">
<!-- Location of XML and .properties files in the file system for easy editing -->
<folder dir="${server.config.dir}/editableConfig" />
<!-- Location of some classes and resources in the file system -->
<folder dir="${server.config.dir}/extraStuff" />
<!-- A zip file containing some resources -->
<file name="${server.config.dir}/lib/someResources.zip" />
<!-- All the jar files in ther servers lib folder -->
<fileset dir="${server.config.dir}/lib" includes="*.jar" scanInterval="5s" />
</library>
<application location ="webStore.war">
<classloader commonLibraryRef="someLibrary" />
</application>
The
configuration snippet in the example, allows all resources under the editableConfig
directory to be loaded by the webStore application.