classpathhelper
Class Location

java.lang.Object
  extended byclasspathhelper.Location

public class Location
extends java.lang.Object

Class representing a location where classes can be loaded from. Locations use ClassStore as its DAO object, to actually retrieve bytes from.

Usage

Location objects are typically created by CGClassLoader and once obtained can be used to find aggregated information on dependencies, blocked classes, unresolved references or can be used to locate a specific ClassDetail object.

Implementation Notes

Internally this class synchronizes on the class loader's mutex it was created with.

Since:
1.0
Author:
bharris

Constructor Summary
Location(CGClassLoader cgClassLoader, ClassStore theStore)
           
 
Method Summary
 void addBlockedClass(java.lang.String className, boolean sameBytes)
          Deprecated. Use addBlockedContent(classpathhelper.ContentDescription, boolean)
 void addBlockedContent(ContentDescription contDesc, boolean sameBytes)
           
 boolean equals(java.lang.Object o)
           
 Package findPackage(java.lang.String packageName)
          Find a specific package at this location.
 java.lang.String[] getBlockedClassNames()
          Deprecated. Use getBlockedContents().
 java.lang.String[] getBlockedClassNamesWithDifferentByteCode()
          Deprecated. Use getBlockedClassNamesWithDifferentByteCode()
 ContentDescription[] getBlockedContents()
          Retrieves a list of blocked classes at this location.
 ContentDescription[] getBlockedContentsWithDifferentByteCode()
          Retrieves a list of blocked content at this location that have different bytes than the location where the actual class will be loaded from.
 ClassDescription[] getClassesThatDependOnLocation(java.lang.String location)
          Returns an array of class descriptions, of classes contained within this locatoin, that depend on the supplied location.
 ClassDescription[] getClassesThatWontLoad()
          Determines which classes loaded within this location will not load due to unresolved classes somewhere in its dependencies.
 CGClassLoader getClassLoader()
           
 java.lang.String[] getClassNames()
          Deprecated. Use getContents()
 java.lang.String[] getClassNamesThatDependOnLocation(java.lang.String location)
          Deprecated. Use getClassesThatDependOnLocation(java.lang.String).
 ClassStore getClassStore()
           
 ContentDescription[] getContents()
          Returns the contents at this location.
 ClassDescription[] getDependsOnClasses()
          Returns an array of class names that corresponds to the classes dependend on by classes stored at this location.
 ClassDescription[] getDependsOnClassesByLocation(java.lang.String location)
          Gets an array of class description that this location depends on by location.
 java.lang.String[] getDependsOnLocations()
          Method that returns the locations containing classes that classes in this location depend on.
 java.lang.String getLocationDescription()
           
 java.lang.String getLocationType()
          A String representing this location type.
 ClassDescription[] getNotFoundDependentClasses()
          Retrieves an array of class names corresponding to classes not found on the classpath, that are referenced by classes stored at this location.
 Package[] getPackages(boolean includeSub)
          Gets the packages in this location.
protected  Package[] getPackages(PackageStore packageCache, boolean includeSub)
          Internal method that looks up the packages.
protected  void getPackages(PackageStore packageCache, boolean includeSub, java.util.Set retVal)
          Internal method that searches through all content to determine the packages in this location.
 java.lang.String[] getReferredFromLocations(CGClassLoader startingClassLoader)
          Method that returns the locations that refer to this location.
 ClassDescription[] getReferredFromLocationsByLocation(CGClassLoader startingClassLoader, java.lang.String locationDescription)
          Classes from a specific location that refer to classes in this location.
 int hashCode()
           
 boolean isIgnored()
          Flag indicating whether or not this location is being ignored by the class loader.
 void setIgnored(boolean isIgnored)
          Sets the flag indicating whether or not this location is ignored by the class loader.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Location

public Location(CGClassLoader cgClassLoader,
                ClassStore theStore)
Parameters:
cgClassLoader - The ClassLoader this location is associated with.
theStore - The class store this location will use to obtain bytes from.
Since:
1.0
Method Detail

isIgnored

public boolean isIgnored()
Flag indicating whether or not this location is being ignored by the class loader.

Returns:
true If this location is ignored, otherwise false
Since:
1.0

setIgnored

public void setIgnored(boolean isIgnored)
Sets the flag indicating whether or not this location is ignored by the class loader. This flag is set if a CGClassLoaderFilter was supplied to this class loader and indicated that the class store associated with this location should be ignored.

Parameters:
isIgnored - The ignore flag (default is false).
Since:
1.0

addBlockedClass

public void addBlockedClass(java.lang.String className,
                            boolean sameBytes)
Deprecated. Use addBlockedContent(classpathhelper.ContentDescription, boolean)

Method called during construction to indicate one of this location's classes is blocked.

Parameters:
className - The class name that is blocked.
sameBytes - Flag indicating whether or not the blocked class has the same bytes.
Since:
1.0

addBlockedContent

public void addBlockedContent(ContentDescription contDesc,
                              boolean sameBytes)

getClassStore

public ClassStore getClassStore()
Returns:
The underlying class store used to retrieve bytes.
Since:
1.0

getClassLoader

public CGClassLoader getClassLoader()
Returns:
The Class Loader this location is associated with.
Since:
1.0

getLocationType

public java.lang.String getLocationType()
A String representing this location type.

Returns:
One of the following string values.
  • JAR
  • DIRECTORY
Since:
1.0

getLocationDescription

public java.lang.String getLocationDescription()
Returns:
The description of this location (typically a path to the location).
Since:
1.0

getReferredFromLocations

public java.lang.String[] getReferredFromLocations(CGClassLoader startingClassLoader)
Method that returns the locations that refer to this location. This method is quite expensive as it requires the entire class loader get resolved.

Parameters:
startingClassLoader - Since this method requires all classes are resolved, we need to supply the classloader we are starting with. A location can be referenced by classes from a descendent classloader.
Returns:
An array of location descriptions (typically paths).
Since:
1.0

getReferredFromLocationsByLocation

public ClassDescription[] getReferredFromLocationsByLocation(CGClassLoader startingClassLoader,
                                                             java.lang.String locationDescription)

Classes from a specific location that refer to classes in this location. This method is quite expensive as it requires all classes to be resolved.

Parameters:
startingClassLoader - Since this method requires all classes are resolved, we need to supply the classloader we are starting with. A location can be referenced by classes from a descendent classloader.
locationDescription - The location to take classes from.
Returns:
An array of class names from the supplied location that refer to classes in this location.
Since:
1.0

getDependsOnLocations

public java.lang.String[] getDependsOnLocations()
Method that returns the locations containing classes that classes in this location depend on.

Returns:
A string array of location descriptions.
Since:
1.0

getClassNames

public java.lang.String[] getClassNames()
Deprecated. Use getContents()

Retrieves the class names of the classes stored at this location.

Returns:
An array of class names.
Since:
1.0

getContents

public ContentDescription[] getContents()
Returns the contents at this location. Contents can either by classes or other content (such as properties files).

Returns:
An array of content descriptions.
Since:
1.1

getDependsOnClasses

public ClassDescription[] getDependsOnClasses()
Returns an array of class names that corresponds to the classes dependend on by classes stored at this location.

Returns:
An array of class names descriptions.
Since:
1.0

getDependsOnClassesByLocation

public ClassDescription[] getDependsOnClassesByLocation(java.lang.String location)
Gets an array of class description that this location depends on by location.

Parameters:
location - The location to find all the classes this location depends on.
Returns:
An array of class descriptions.
Since:
1.1

getNotFoundDependentClasses

public ClassDescription[] getNotFoundDependentClasses()
Retrieves an array of class names corresponding to classes not found on the classpath, that are referenced by classes stored at this location.

Returns:
An array of class names.
Since:
1.0

getClassesThatWontLoad

public ClassDescription[] getClassesThatWontLoad()
Determines which classes loaded within this location will not load due to unresolved classes somewhere in its dependencies.

Returns:
An array of descriptions of unloadable classes from this location.
Since:
1.1

getClassNamesThatDependOnLocation

public java.lang.String[] getClassNamesThatDependOnLocation(java.lang.String location)
Deprecated. Use getClassesThatDependOnLocation(java.lang.String).

Returns an array of class names, of classes contained within this location, that depend on the supplied location.

In other words, which classes from this location depend on the classes in the supplied location.

Parameters:
location - A location description (typically a path).
Returns:
An array of class names.
Since:
1.0

getClassesThatDependOnLocation

public ClassDescription[] getClassesThatDependOnLocation(java.lang.String location)

Returns an array of class descriptions, of classes contained within this locatoin, that depend on the supplied location.

In other words, which classes from this location depend on the classes in the supplied location.

Parameters:
location - A location description (typically a path).
Returns:
An array of class names.
Since:
1.1

getBlockedClassNames

public java.lang.String[] getBlockedClassNames()
Deprecated. Use getBlockedContents().

Retrieves a list of blocked classes at this location. Blocked classes at this location are located elsewhere on the classpath.

Returns:
An array of class names.
Since:
1.0

getBlockedContents

public ContentDescription[] getBlockedContents()
Retrieves a list of blocked classes at this location. Blocked classes at this location are located elsewhere on the classpath.

Returns:
An array of class descriptions.
Since:
1.1

getBlockedClassNamesWithDifferentByteCode

public java.lang.String[] getBlockedClassNamesWithDifferentByteCode()
Deprecated. Use getBlockedClassNamesWithDifferentByteCode()

Retrieves a list of blocked classes at this location that have different bytes than the location where the actual class will be loaded from.

Returns:
An array of class names.
Since:
1.0

getBlockedContentsWithDifferentByteCode

public ContentDescription[] getBlockedContentsWithDifferentByteCode()
Retrieves a list of blocked content at this location that have different bytes than the location where the actual class will be loaded from.

Returns:
An array of content descriptions.
Since:
1.1

getPackages

public Package[] getPackages(boolean includeSub)

Gets the packages in this location. The flag indicates whether or not to return extended packages or just immediate subpackages.

Note: If a package contains content like class a.b.c.SomeClasS this location contains packages a, a.b in addition to a.b.c. (includeSub flag determines what gets returned).

Parameters:
includeSub - If true packages such as a, a.b and a.b.c will be returned. If false only packages like a (immediate subpackages) will be returned.
Returns:
The packages in this location.
Since:
1.2

findPackage

public Package findPackage(java.lang.String packageName)
Find a specific package at this location.

Parameters:
packageName - The package name.
Returns:
The package or null if the package cannot be found at this location.
Since:
1.2

getPackages

protected Package[] getPackages(PackageStore packageCache,
                                boolean includeSub)
Internal method that looks up the packages. This method is the worker method for getPackages(boolean).

Parameters:
packageCache - The cache to lookup packages in.
includeSub - true to include extended sub packages, false if only root packages are needed.
Returns:
The packages at this location.
Since:
1.2

getPackages

protected void getPackages(PackageStore packageCache,
                           boolean includeSub,
                           java.util.Set retVal)
Internal method that searches through all content to determine the packages in this location. This method is used by getPackages(PackageStore, boolean) to build up its cache of content.

Parameters:
packageCache - The cache to look up items in.
includeSub - true to include extended sub packages, false if only root packages are needed.
retVal - The set that holds the results of repeated calls to this method.
Since:
1.2

toString

public java.lang.String toString()

equals

public boolean equals(java.lang.Object o)

hashCode

public int hashCode()