Resource Managers
1. Introduction
The resource manager is the PresentationServer component responsible for reading
and writing XML and other resources like binary and text documents. The resource
manager abstracts the actual mechanisms used to store resources. An important
benefit of using such an abstraction is that it is possible to store all your
application files in a sandbox which can be moved at will within a filesystem or
between storage mechanisms. For instance, resources can be stored in:
- files on disk (using your operating system's file system)
- a WAR file
- a WebDAV server
The resource manager is both used:
- internally by PresentationServer
- in PresentationServer applications through URLs with the oxf: protocol
This section describes the different types of resource managers and explains their
configuration.
2. General Configuration
The resource manager is initialized in the PresentationServer main servlet.
Configuration is handled in the Web application descriptor (web.xml)
by setting a number of properties. The first property indicates the resource manager
factory:
<context-param> <param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.DefaultResourceManagerFactory
</param-value> </context-param>
3. Flat File Resource Manager
Purpose |
Loading resources from a directory structure |
Factory |
org.orbeon.oxf.resources.FlatFileResourceManagerFactory
|
Properties |
oxf.resources.flatfile.rootdir
|
The flat file resource manager loads resources from the file system. This is
especially useful during development, since no packaging is necessary. The
oxf.resources.flatfile.rootdir is required and must point to a valid
directory on the local system.
3.1 Example
<context-param> <param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.FlatFileResourceManagerFactory
</param-value> </context-param> <context-param> <param-name>oxf.resources.flatfile.rootdir</param-name>
<param-value>/home/user/oxf/myapp/resources</param-value>
</context-param>
4. ClassLoader Resource Manager
Purpose |
Loading resources from a JAR file in the classpath |
Factory |
org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory
|
Properties |
None |
The class loader resource manager can load resource from a JAR file or from a
directory in the classpath. This resource manager is required to load internal
resources for PresentationServer.
4.1 Example
<context-param> <param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory
</param-value> </context-param>
5. Webapp Resource Manager
Purpose |
Loading resources from a WAR file or deployed Web Application |
Factory |
org.orbeon.oxf.resources.WebAppResourceManagerFactory
|
Properties |
oxf.resources.webapp.rootdir
|
This resource manager is useful when you want to package an application into a
single WAR file for distribution and deployment. The configuration property
indicates the path prefix of the resources directory inside a WAR file. It is
recommended to store resources under the WEB-INF directory to make sure that the
resources are not exposed to remote clients.
5.1 Example
<context-param> <param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.WebAppResourceManagerFactory
</param-value> </context-param> <context-param> <param-name>oxf.resources.webapp.rootdir</param-name>
<param-value>/WEB-INF/resources</param-value>
</context-param>
6. URL Resource Manager
Purpose |
Loading resources from a URL |
Factory |
org.orbeon.oxf.resources.URLResourceManagerFactory
|
Properties |
oxf.resources.url.base
|
This resource manager is able to load resources form any URL (http or ftp). It can
be used if your resources are located on a Web server or a content management
system with an HTTP interface.
6.1 Example
<context-param> <param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.URLResourceManagerFactory</param-value>
</context-param> <context-param> <param-name>oxf.resources.url.base</param-name>
<param-value>http://www.somwhere.com/base/</param-value>
</context-param>
7. WebDAV Resource Manager
Purpose |
Loading resources from a WebDAV repository |
Factory |
org.orbeon.oxf.resources.WebDAVResourceManagerFactory
|
Properties |
oxf.resources.webdav.base
oxf.resources.webdav.username
oxf.resources.webdav.password
|
This resource manager is able to load resources form a WebDAV repository through
HTTP. Examples of WebDAV repositories include:
For more information about WebDAV, please consult WebDAV Resources.
7.1 Example
<context-param> <param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.WebDAVResourceManagerFactory
</param-value> </context-param> <context-param> <param-name>oxf.resources.webdav.base</param-name>
<param-value>http://www.somwhere.com/base/</param-value>
</context-param> <context-param> <param-name>oxf.resources.webdav.username</param-name>
<param-value>joe</param-value>
</context-param> <context-param> <param-name>oxf.resources.webdav.password</param-name>
<param-value>password</param-value>
</context-param>
Warning
The WebDAV resource manager is considered experimental.
8. Priority Resource Manager
Purpose |
Chains several resource managers in order |
Factory |
org.orbeon.oxf.resources.PriorityResourceManagerFactory
|
Properties |
oxf.resources.priority.1
oxf.resources.priority.2
oxf.resources.priority.n
|
With the priority resource manager you can chain several resource managers. It is
crucial to be able to load resources from multiple sources since some resources are
bundled in the PresentationServer JAR file. Thus, the class loader resource
manager must always be in the priority chain. It usually has the lowest priority so
the application developer can override system resources.
There can be any number of chained resource managers. They are configured by adding
a oxf.resources.priority.n property, where n is an
integer.
8.1 Example
<context-param> <param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.PriorityResourceManagerFactory
</param-value> </context-param> <context-param> <param-name>oxf.resources.webapp.rootdir</param-name>
<param-value>/WEB-INF/resources</param-value>
</context-param> <context-param> <param-name>oxf.resources.priority.1</param-name>
<param-value>org.orbeon.oxf.resources.WebAppResourceManagerFactory
</param-value> </context-param> <context-param> <param-name>oxf.resources.priority.2</param-name>
<param-value>org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory
</param-value> </context-param>
9. Caché Database Resource Manager
Purpose |
Loading resources from the Caché database |
Factory |
org.orbeon.oxf.resources.CacheResourceManagerFactory
|
Properties |
oxf.resources.cache.url
oxf.resources.cache.username
oxf.resources.cache.password
|
This resource manager loads XML documents from InterSystems Caché Object Database.
eXtc provides a W3C DOM
interface to Caché and allows PresentationServer to store and retrieve XML
documents. This section assumes Caché and eXtc are already installed on your
system.
Note
To enable this Resource Manager, you must copy CacheDB.jar from
Caché distribution into PresentationServer WEB-INF/lib
directory.
Warning
The Caché Resource Manager only supports XML document. To serve other
document types (like text, images), you must cascade a second resource manager with
the help of the Priority Resource Manager.
9.1 Importing XML Files into Caché
PresentationServer ships with CacheImport to populate the
database with resource from a directory. Set your CLASSPATH
environment variable to include the following JAR files to run
CacheImport:
- orbeon.jar
- CacheDB.jar
- commons-cli.jar
- xercesImpl-2_2_1_orbeon.jar
- xml-apis-2_5_1.jar
- dom4j-1_4.jar
The options below are available:
Option |
Meaning |
-u,--url arg |
Caché URL |
-l,--login arg |
Caché Login |
-p,--password arg |
Caché Password |
-r,--root arg |
Resource Root |
You run CacheImport with the following command:
java org.orbeon.oxf.resources.CacheImport
9.2 Example
<context-param> <param-name>oxf.resources.factory</param-name>
<param-value>org.orbeon.oxf.resources.CacheResourceManagerFactory
</param-value> </context-param> <context-param> <param-name>oxf.resources.cache.url</param-name>
<param-value>jdbc:Cache://localhost:1972/OXF</param-value>
</context-param> <context-param> <param-name>oxf.resources.cache.username</param-name>
<param-value>_SYSTEM</param-value>
</context-param> <context-param> <param-name>oxf.resources.cache.password</param-name>
<param-value>sys</param-value>
</context-param>