Summary:
A class path entry which is a URL representing either a local or a
remote directory or zip file. Manages all the details for zip file support.
For example, local zip files (once opened) are kept open for the lifetime
of the entry for increased performance.
Features:
- Supports absolute and relative file names
- Creates URL entry from given String, File, or URL
- Adds "/" to end of URL for directories if necessary
- Knows if URL is zip local or remote
- Knows if URL is a zip file or directory
- Keeps ZipFile open if the zip file is local
Note: "zip files" are files with ".zip" or ".jar" extensions.
Class Path Entries:
Example valid class path entries are:
Files and directories on the local file system
../../java/classes
/users/kristen/java/classes
/users/kristen/java/classes/
/users/kristen/java/zipfiles/MyClasses.zip
/users/kristen/java/jarfiles/MyClasses.jar
file:///users/kristen/java/classes
file://localhost/users/kristen/java/classes
Files and directories on a remote file system
(must be in URL format)
ftp://www.foo.com/pub/java/classes
file://www.foo.com/pub/java/classes/
http://www.foo.com/web/java/classes/
file://www.foo.com:8080/pub/java/zipfiles/MyClasses.zip
http://www.foo.com:8080/web/java/jarfiles/MyClasses.jar
Note that the location of the entry includes the protocol, the host name,
and the port while the file name is everything else. For example,
http://www.foo.com:8080/web/java/jarfiles/MyClasses.jar
has the form [location][name] or
[http://www.foo.com:8080/][/web/java/jarfiles/MyClasses.jar]
so the location is "http://www.foo.com:8080/" and the name is
"/web/java/jarfiles/MyClasses.jar".
Note that the two references
/users/kristen/java/classes/
file:///users/kristen/java/classes/
represent the same directory on a Unix machine, and
C|/windows/java/classes/
file:///C|/windows/java/classes/
are equivalent directories on a Windows box.
But the two references
/users/kristen/java/classes/
file://monet.lutris.com/users/kristen/java/classes/
are not equivalent even if the directory
/users/kristen/java/classes/ lives
on the machine named monet.lutris.com and all development
is on this machine. Why? Because the web (browser?) protocol is different
for URLs with host information and those without. If no host is
specified, the file is assumed to be on the local machine and the
path is determined from the ROOT of the machine. If the
host is specified, then the ftp protocol is used and the path
is determined from the ftp ROOT (e.g. /users/ftp/) rather
than the machine's ROOT. Thus, on a machine that support's anonymous
ftp, the following two directories are the same:
/users/ftp/pub/classes/
file://picasso.lutris.com/pub/classes/
assuming the development is being done on picasso.lutris.com.
System Class Path Entries
The system class path is the system-dependent path of directories
and files (e.g. CLASSPATH on Unix and Windows) used by the system
class loader to load classes. Valid system class path entries are
directories and zip files, specified by absolute path or relative path
on the system. Any valid system class path entry is also valid to
create a ClassPathEntry .
Example
Here is an example of how to use a ClassPathEntry:
ClassPathEntry entry = new ClassPathEntry("/home/java/Test.jar");
System.out.println("My entry URL is " + entry.get());
System.out.println("My entry string is " + entry.toString());
System.out.println("My entry name " + entry.getName());
System.out.println("My entry location " + entry.getLocation());
System.out.println("My entry is a zip file? " + entry.isZipFile());
Resource resource = entry.getResource("foo.gif");
author: Kristen Pol, Lutris Technologies version: $Revision : 1.0 $ See Also: com.lutris.classloader.Resource See Also: java.net.URL |