|
EAF 7.4 Util | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lutris.classloader.ClassPathEntry
public class ClassPathEntry
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.
Note: "zip files" are files with ".zip" or ".jar" extensions.
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.jarhas 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.
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
.
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");
Resource
,
URL
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 | |
---|---|
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. |
com.lutris.classloader.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. |
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 |
Constructor Detail |
---|
public ClassPathEntry(java.lang.String entry, com.lutris.logging.LogChannel loadLogChannel)
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");
entry
- The class path entry.loadLogChannel
- The log channel.public ClassPathEntry(java.io.File entry, com.lutris.logging.LogChannel loadLogChannel)
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"));
entry
- The class path entry.loadLogChannel
- The log channel.public ClassPathEntry(java.net.URL entry, com.lutris.logging.LogChannel loadLogChannel)
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"));
entry
- The class path entry.loadLogChannel
- The log channel.Method Detail |
---|
public java.net.URL getURL()
public java.lang.String getName()
public java.lang.String getLocation()
public java.lang.String toString()
toString
in class java.lang.Object
public com.lutris.classloader.Resource getResource(java.lang.String name)
name
- The file name associated with the resource.
Resource
public boolean isZipFile()
public boolean isDirectory()
isZipFile
public boolean isLocal()
public boolean isRemote()
isLocal()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
cpe
- The class path entry to check for equality.
public java.util.zip.ZipFile getZipFile()
|
EAF 7.4 Util | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |