Class AbstractClassFinder
java.lang.Object
org.ocpsoft.rewrite.annotation.scan.AbstractClassFinder
- All Implemented Interfaces:
org.ocpsoft.common.pattern.Weighted,ClassFinder
- Direct Known Subclasses:
WebClassesFinder,WebLibFinder
Base class for implementations of the
ClassFinder interface.- Author:
- Christian Kaltepoth
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ClassLoaderTheClassLoaderto get classes fromprotected final org.ocpsoft.logging.LoggerCommon logger for all implementationsprotected final PackageFilterThe filter for checking which classes to processprotected final jakarta.servlet.ServletContextTheServletContext -
Constructor Summary
ConstructorsConstructorDescriptionAbstractClassFinder(jakarta.servlet.ServletContext servletContext, ClassLoader classLoader, PackageFilter packageFilter, ByteCodeFilter byteCodeFilter) Initialization procedure -
Method Summary
Modifier and TypeMethodDescriptionprotected static StringgetClassName(String filename) Creates a FQCN from anURLrepresenting a.classfile.protected booleanmustProcessClass(String className) Checks if a supplied class has to be processed by checking the package name against thePackageFilter.protected voidprocessClass(String className, InputStream classFileStream, ClassVisitor visitor) Handle a single class to process.protected StringstripKnownPrefix(String str, String prefix) Strip everything up to and including a given prefix from a string.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ocpsoft.rewrite.annotation.spi.ClassFinder
findClassesMethods inherited from interface org.ocpsoft.common.pattern.Weighted
priority
-
Field Details
-
log
protected final org.ocpsoft.logging.Logger logCommon logger for all implementations -
servletContext
protected final jakarta.servlet.ServletContext servletContextTheServletContext -
classLoader
TheClassLoaderto get classes from -
packageFilter
The filter for checking which classes to process
-
-
Constructor Details
-
AbstractClassFinder
public AbstractClassFinder(jakarta.servlet.ServletContext servletContext, ClassLoader classLoader, PackageFilter packageFilter, ByteCodeFilter byteCodeFilter) Initialization procedure- Parameters:
servletContext- TheServletContextof the web application.classLoader- TheClassLoaderto use for loading classespackageFilter- ThePackageFilterused to check if a package has to be scanned.
-
-
Method Details
-
stripKnownPrefix
Strip everything up to and including a given prefix from a string.- Parameters:
str- The string to processprefix- The prefix- Returns:
- the stripped string or
nullif the prefix has not been found
-
getClassName
Creates a FQCN from an
URLrepresenting a.classfile.- Parameters:
url- The path of the class file- Returns:
- the FQCN of the class
-
mustProcessClass
Checks if a supplied class has to be processed by checking the package name against thePackageFilter.- Parameters:
className- FQCN of the class- Returns:
truefor classes to process,falsefor classes to ignore
-
processClass
Handle a single class to process. This method should only be called if the class name is accepted by the
PackageFilter.If
classFileStreamis notnullthe method will first try to check whether the class files may contain annotations by scanning it with theByteCodeFilter. If noInputStreamis supplied, this check will be skipped. After that the method will create an instance of the class and then callClassVisitor#visit(Class, org.ocpsoft.prettyfaces.annotation.PrettyConfig).Please not the the called of this method is responsible to close the supplied
InputStream!- Parameters:
className- The FQCN of the classclassFileStream- The Java class file of the class (may benull)visitor- the visitor
-