|
|||||||||
| Home >> All >> com >> lutris >> [ classloader overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lutris.classloader
Class ClassPathEntry

java.lang.Objectcom.lutris.classloader.ClassPathEntry
- public class ClassPathEntry
- extends java.lang.Object
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");
- Version:
- $Revision : 1.0 $
| Field Summary | |
private java.net.URL |
entryURL
The class path entry represented by a URL. |
private boolean |
isZipFile
Cache this information as it is accessed quite a bit |
private com.lutris.logging.LogChannel |
logChannel
Log channel to write messages to |
private boolean |
loggingEnabled
Is logging enabled? |
private int |
logLevel
Numeric log level number for LOGLEVEL string |
private java.util.zip.ZipFile |
zipFile
The ZipFile for this class path entry, if appropriate. |
| Constructor Summary | |
ClassPathEntry(java.io.File entry,
com.lutris.logging.LogChannel loadLogChannel)
Constructs class path entry with specified File. |
|
ClassPathEntry(java.lang.String entry,
com.lutris.logging.LogChannel loadLogChannel)
Constructs class path entry with specified String. |
|
ClassPathEntry(java.net.URL entry,
com.lutris.logging.LogChannel loadLogChannel)
Constructs class path entry with specified URL. |
|
| Method Summary | |
private static java.net.URL |
cleanUpURL(java.net.URL url)
Cleans up URL by fixing slashes. |
private static java.net.URL |
convertEntryToURL(java.lang.Object object)
Converts Object to URL. |
private static java.net.URL |
convertEntryToURL(java.lang.String string)
Converts String to URL. |
private static java.lang.String |
convertSlashes(java.lang.String string)
Converts all system path separators to "/". |
private java.util.zip.ZipFile |
doGetZipFile()
Gets zip file associated with class path entry if appropriate. |
boolean |
equals(java.lang.Object o)
Determines if specified class path entry is equal to this entry. |
java.lang.String |
getLocation()
Gets location of class path entry. |
java.lang.String |
getName()
Gets file name of class path entry. |
Resource |
getResource(java.lang.String name)
Gets resource with the specified name from class path entry. |
java.net.URL |
getURL()
Gets class path entry set previously by constructor. |
java.util.zip.ZipFile |
getZipFile()
Gets zip file associated with class path entry if appropriate. |
private void |
initIsZipFile()
Called at init time or when ever the entryURL can change. |
boolean |
isDirectory()
Determines if class path entry is a directory. |
boolean |
isLocal()
Determines if class path entry is local. |
boolean |
isRemote()
Determines if class path entry is remote. |
boolean |
isZipFile()
Determines if class path entry is a zip file. |
java.lang.String |
toString()
Stringifies class path entry set previously by constructor. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
entryURL
private java.net.URL entryURL
- The class path entry represented by a URL.
zipFile
private java.util.zip.ZipFile zipFile
- The ZipFile for this class path entry, if appropriate.
loggingEnabled
private boolean loggingEnabled
- Is logging enabled?
logChannel
private com.lutris.logging.LogChannel logChannel
- Log channel to write messages to
logLevel
private int logLevel
- Numeric log level number for LOGLEVEL string
isZipFile
private boolean isZipFile
- Cache this information as it is accessed quite a bit
| Constructor Detail |
ClassPathEntry
public ClassPathEntry(java.lang.String entry, com.lutris.logging.LogChannel loadLogChannel)
- Constructs class path entry with specified String.
The String is assumed to be either a directory or zip file on
the local machine or a remote machine, which can be represented by the
absolute file name, the relative file name, or a URL.
Examples:
ClassPathEntry("../../java/classes"); ClassPathEntry("/users/kristen/java/classes"); ClassPathEntry("/users/kristen/java/classes/"); ClassPathEntry("/users/kristen/java/MyClasses.zip"); ClassPathEntry("/users/kristen/java/MyClasses.jar"); ClassPathEntry("ftp://www.foo.com/pub/classes/"); ClassPathEntry("file://www.foo.com/web/classes/"); ClassPathEntry("http://www.foo.com/web/classes/"); ClassPathEntry("http://www.foo.com:8080/web/classes/"); ClassPathEntry("http://www.foo.com/web/classes/MyClasses.jar");
ClassPathEntry
public ClassPathEntry(java.io.File entry, com.lutris.logging.LogChannel loadLogChannel)
- Constructs class path entry with specified File.
The File can represent a directory or zip file on the local machine.
Examples:
ClassPathEntry(new File("../../java/classes")); ClassPathEntry(new File("/users/kristen/java/classes")); ClassPathEntry(new File("/users/kristen/java/classes/")); ClassPathEntry(new File("/users/kristen/java/MyClasses.zip")); ClassPathEntry(new File("/users/kristen/java/MyClasses.jar"));
ClassPathEntry
public ClassPathEntry(java.net.URL entry, com.lutris.logging.LogChannel loadLogChannel)
- Constructs class path entry with specified URL.
The URL can represent a directory or zip file on the local machine
or a remote machine.
Examples:
ClassPathEntry(new URL("ftp://www.foo.com/pub/classes/")); ClassPathEntry(new URL("file://www.foo.com/web/classes/")); ClassPathEntry(new URL("http://www.foo.com/web/classes/")); ClassPathEntry(new URL("http://www.foo.com:8080/web/classes/")); ClassPathEntry(new URL("http://www.foo.com/web/MyClasses.jar"));
| Method Detail |
getURL
public java.net.URL getURL()
- Gets class path entry set previously by constructor.
getName
public java.lang.String getName()
- Gets file name of class path entry. For example, if the entry is
"http://www.foo.com:8080/java/classes/MyClasses.jar", the name is
"/java/classes/MyClasses.jar". The beginning slash does not mean
that its an absolute file name on its host machine. The file name
is always relative to the location.
getLocation
public java.lang.String getLocation()
- Gets location of class path entry. For example, if the entry is
"http://www.foo.com:8080/java/classes/MyClasses.jar", the location is
"http://www.foo.com:8080/".
toString
public java.lang.String toString()
- Stringifies class path entry set previously by constructor.
getResource
public Resource getResource(java.lang.String name)
- Gets resource with the specified name from class path entry.
The result will be null if the resource can not be found.
isZipFile
public boolean isZipFile()
- Determines if class path entry is a zip file. Anything ending
in ".zip" or ".jar" is considered a zip file.
initIsZipFile
private void initIsZipFile()
- Called at init time or when ever the entryURL can change.
isDirectory
public boolean isDirectory()
- Determines if class path entry is a directory. Anything that is
not a zip file is considered a directory.
isLocal
public boolean isLocal()
- Determines if class path entry is local. Anything that has
no host name or a host name of "localhost" is considered local.
isRemote
public boolean isRemote()
- Determines if class path entry is remote. Anything that is not
local is considered remote.
equals
public boolean equals(java.lang.Object o)
- Determines if specified class path entry is equal to this entry.
The entries are considered equal if the URLs are the same.
getZipFile
public java.util.zip.ZipFile getZipFile()
- Gets zip file associated with class path entry if appropriate. If
a zip file is not found, null will be returned.
doGetZipFile
private java.util.zip.ZipFile doGetZipFile()
- Gets zip file associated with class path entry if appropriate. If
a zip file is not found, null will be returned.
cleanUpURL
private static java.net.URL cleanUpURL(java.net.URL url)
- Cleans up URL by fixing slashes. All back slashes are converted to
forward slashes ("/"). A slash is added to the end of the URL if
it is a directory and does not already have an ending slash.
convertEntryToURL
private static java.net.URL convertEntryToURL(java.lang.Object object)
- Converts Object to URL. Only URLs, Files, and Strings
can be successfully converted. All other object types will
result in a null return.
convertEntryToURL
private static java.net.URL convertEntryToURL(java.lang.String string)
- Converts String to URL.
convertSlashes
private static java.lang.String convertSlashes(java.lang.String string)
- Converts all system path separators to "/". This is to accommodate
both Windows and Unix for URL generation and searching zip files.
|
|||||||||
| Home >> All >> com >> lutris >> [ classloader overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.lutris.classloader.ClassPathEntry