|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.core.util.reflection.ClassFinder
This class implements the capability to search over the current classpath retrieving classes that implement a certain interface.
Copyright 2001 Sapient
Field Summary | |
protected Set |
classes
The set of classes found matching the provided criteria. |
protected long |
foundClasses
Tracks the count of classes found that match the provided criteria. |
protected String |
requiredPathSubstring
The required substring path criteria for this searcher |
protected Class |
superClass
The super class criteria |
Constructor Summary | |
ClassFinder()
Instantiates the type of MBeanHarvester that will return all classes in the entire classpath. |
|
ClassFinder(Class superClass)
Instantiates the type of MBeanHarvester that will return all classes that are assignable to the supplied class. |
|
ClassFinder(Class superClass,
String requiredPathSubstring)
Instantiates the type of MBeanHarvester that will return all classes that are assignable to the supplied class and are part of the supplied package. |
Method Summary | |
protected void |
addClassName(String className)
Adds a class name to the list of found classes if and only if it meets the configured requirements. |
Set |
getClasses()
Used to retrieve the results Set from this harvester's
search. |
protected String |
getClassName(String fileName)
Returns the Fully Qualified Class name of a class from it's path |
protected boolean |
isArchive(String name)
Looks at the name of a file to determine if it is an archive |
private void |
processFile(String base,
String current)
Recursively search through Directories with special checks to recognize zip and jar files. |
protected void |
processZip(ZipFile file)
Iterates through the files in a zip looking for files that may be classes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected long foundClasses
protected Class superClass
protected String requiredPathSubstring
protected Set classes
Constructor Detail |
public ClassFinder()
Instantiates the type of MBeanHarvester that will return all classes in the entire classpath.
public ClassFinder(Class superClass)
Instantiates the type of MBeanHarvester that will return all classes that are assignable to the supplied class. This would include all implementations of it, if it is an interface or it and all subclasses of it if it's a class.
superClass
- the Class that should be searched for along with
implementations and subclassespublic ClassFinder(Class superClass, String requiredPathSubstring)
Instantiates the type of MBeanHarvester that will return all classes
that are assignable to the supplied class and are part of the supplied
package. This would include all implementations of it, if it is an
interface or it and all subclasses of it if it's a class. The
supplied requiredPathSubstring must be part of the fully
qualified classname.
Parameters:
superClass
- the Class that should be searched for along with
implementations and subclasses
requiredPathSubstring
- the String part that must be found in the
classes FQN
Method Detail
addClassName
protected void addClassName(String className)
Adds a class name to the list of found classes if and only if it meets
the configured requirements.
- Parameters:
className
- the FQN String name of the class to add
getClasses
public Set getClasses()
Used to retrieve the results Set
from this harvester's
search.
- Returns:
- Set the set of classes that meet this harvester's requirements
processFile
private void processFile(String base,
String current)
- Recursively search through Directories with special checks to recognize
zip and jar files. (Zip and Jar files return true from
<File>.isDirectory())
- Parameters:
base
- the base file path to searchcurrent
- the current recursively searched file path being searched
isArchive
protected boolean isArchive(String name)
Looks at the name of a file to determine if it is an archive
- Parameters:
name
- the name of a file
- Returns:
- true if a file in the classpath is an archive
such as a Jar or Zip file
getClassName
protected String getClassName(String fileName)
Returns the Fully Qualified Class name of a class from it's path
- Parameters:
fileName
- the full path to a class
- Returns:
- the FQN of a class
processZip
protected void processZip(ZipFile file)
Iterates through the files in a zip looking for files that may be
classes. This is not recursive as zip's in zip's are not searched by the
classloader either.
- Parameters:
file
- The ZipFile to be searched
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright 1999-2003 Sapient Corporation. All Rights Reserved.