WebNFS Developer's Guide

Chapter 4 The XFileAccessor Interface Class and Methods

Overview

The WebNFS Extended File (XFile) API provides a common multiple-filesystem-type access method for Java developers. The XFileAccessor interface, which allows filesystem developers to supply pluggable filesystem implementations in Java, is the back-end counterpart to the XFile API. The XFileAccessor interface is implemented by filesystems that need to be accessed via the XFile API. The XFileAccessor interface features are as follows:

The XFileAccessor interface strengthens the XFile API strategy, encouraging the growth of filesystem implementations from software partners.

The XFileAccessor Interface

The XFileAccessor interface is implemented by filesystems that need to be accessed by way of the XFile API. Classes that implement this interface must be associated with a URL scheme that is structured according to the Common Internet Scheme syntax described in RFC 1738, an optional location part followed by a hierarchical set of slash-separated directories.

A class file that implements this interface must be named XFileAccessor and be installed in a directory named after the URL scheme that it implements. For instance, an XFileAccessor that provides file access through the HTTP protocol would be associated with the http URL and its class file would be called:



http.XFileAccessor

A class prefix is added to this name. The default prefix is com.sun and this composite name is located by the classLoader using the CLASSPATH. For instance, Sun's NFS XFileAccessor is installed as:



com.sun.nfs.XFileAccessor

The default class prefix com.sun can be changed by setting the system property java.protocols.xfile to any desired prefix or list of prefixes separated by vertical bars. Each prefix in the list will be used to construct a package name and the classLoader will attempt to load that package by way of the CLASSPATH. This process will continue until the XFileAccessor is successfully loaded.

Example

For instance, if you want to use the ftp XFileAccessor from Acme, Inc. and the NFS XFileAccessor from ABC Inc., then you can set the java.protocols.xfile system property as follows:



java.protocols.xfile=com.acme|com.abc

When an ftp URL is used, the following package names will be constructed:



com.acme.ftp.XFileAccessor  
com.abc.ftp.XFileAccessor  
com.sun.ftp.XFileAccessor

(The default com.sun prefix is automatically added to the end of the property list.)

The classLoader attempts to load each of the constructed package names in turn relative to the CLASSPATH until it is successful.

A subsequent reference to an NFS URL will result in the following list of candidate package names:



com.acme.nfs.XFileAccessor
com.abc.nfs.XFileAccessor
com.sun.nfs.XFileAccessor

In this case, the NFS XFileAccessor from ABC, Inc. will be loaded in preference to Sun's NFS.

For the XFile interface documentation, refer to the XFile javadocs included with this release.

Methods