Package org.hibernate.bytecode.buildtime
Class AbstractInstrumenter
java.lang.Object
org.hibernate.bytecode.buildtime.AbstractInstrumenter
- All Implemented Interfaces:
Instrumenter
- Direct Known Subclasses:
CGLIBInstrumenter,JavassistInstrumenter
Provides the basic templating of how instrumentation should occur.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classAllows control over what exacctly to transform.Nested classes/interfaces inherited from interface org.hibernate.bytecode.buildtime.Instrumenter
Instrumenter.Options -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractInstrumenter(Logger logger, Instrumenter.Options options) Creates the basic instrumentation strategy. -
Method Summary
Modifier and TypeMethodDescriptionprotected final booleancheckMagic(File file, long magic) voidThe main instrumentation entry point.protected abstract ClassDescriptorgetClassDescriptor(byte[] byecode) Given the bytecode of a java class, retrieve the descriptor for that class.protected abstract ClassTransformergetClassTransformer(ClassDescriptor descriptor, Set classNames) Create class transformer for the class.protected final booleanisClassFile(File file) Does this file represent a compiled class?protected final booleanDoes this file represent a zip file of some format?protected voidprocessClassFile(File file, Set classNames) Process a class file.protected voidprocessFile(File file, Set classNames) Actually process the file by applying instrumentation transformations to any classes it contains.protected voidprocessJarFile(File file, Set classNames) Process an archive file.
-
Field Details
-
logger
-
options
-
-
Constructor Details
-
AbstractInstrumenter
Creates the basic instrumentation strategy.- Parameters:
logger- The bridge to the environment's logging system.options- User-supplied options.
-
-
Method Details
-
getClassDescriptor
Given the bytecode of a java class, retrieve the descriptor for that class.- Parameters:
byecode- The class bytecode.- Returns:
- The class's descriptor
- Throws:
Exception- Indicates problems access the bytecode.
-
getClassTransformer
Create class transformer for the class.- Parameters:
descriptor- The descriptor of the class to be instrumented.classNames- The names of all classes to be instrumented; the "pipeline" if you will.- Returns:
- The transformer for the given class; may return null to indicate that transformation should be skipped (ala already instrumented).
-
execute
The main instrumentation entry point. Given a set of files, perform instrumentation on each discovered class file.- Specified by:
executein interfaceInstrumenter- Parameters:
files- The files.
-
isClassFile
Does this file represent a compiled class?- Parameters:
file- The file to check.- Returns:
- True if the file is a class; false otherwise.
- Throws:
IOException- Indicates problem access the file.
-
isJarFile
Does this file represent a zip file of some format?- Parameters:
file- The file to check.- Returns:
- True if the file is n archive; false otherwise.
- Throws:
IOException- Indicates problem access the file.
-
checkMagic
- Throws:
IOException
-
processFile
Actually process the file by applying instrumentation transformations to any classes it contains. Again, just like withcollectClassNames(java.io.File, java.util.Set)this method can handle both class and archive files. -
processClassFile
Process a class file. Delegated to fromprocessFile(java.io.File, java.util.Set)in the case of a class file. -
processJarFile
Process an archive file. Delegated to fromprocessFile(java.io.File, java.util.Set)in the case of an archive file.
-